From patchwork Fri Dec 4 10:01:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11951327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75AB8C4167B for ; Fri, 4 Dec 2020 10:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3651F22838 for ; Fri, 4 Dec 2020 10:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387949AbgLDKDf (ORCPT ); Fri, 4 Dec 2020 05:03:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387941AbgLDKDe (ORCPT ); Fri, 4 Dec 2020 05:03:34 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1804FC061A54 for ; Fri, 4 Dec 2020 02:02:08 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id jx16so7802543ejb.10 for ; Fri, 04 Dec 2020 02:02:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/YIHndOkuyRiMsQ82HY4dIjLYZOfc93bxXe51T4cmZ0=; b=SRePSCV6dz/lPsfZpnayLbYuACan0Ha9kwWTtbojMk2TVx94Q4AWxd+nN89U92fo2e KBOYsAucPT7TB7pAYI4G2DalZBdokr0qh1VpG9IVDSp6Luu1ivRc3jHMUQZMxhl+gzpi ELt9tBDEDw2e2Jw6/IlJATISL5JmxFf8Dnn9htD85ANTnLeDbBkb3T3z7TFoh/DVdCBP Z0LF0rH1/VW1Pi96MU9RAsdjonSsXOHB6/xZDBKrb9zHG42F31UC1D/v57cof3WE24Ks RE2F0YU4xTr3dF5CIkN4PNi6OTKMo1dvjd/I1xlWFtMqBEos1ENrZQjpfUlTiX4+1umu ReYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/YIHndOkuyRiMsQ82HY4dIjLYZOfc93bxXe51T4cmZ0=; b=LgTX6Src2wpabsLv9zXicl4EUYWFTICSP5gozitEhNzB5qzsrIPgzDttxR0jm7C2Pq 9HFFE2HgD0mEkjADMHOGKzQWyafE1Ixp7GvzXAvciWLNFL0BaSyIB6yBV3H+3PoRMYEu hfWw/naZODKrp2YZwaJqRB6GmeKda6EBtaQ6mOPVBgczw+TbOYWkwbkJJgTS6jOivWG1 MVk4qU+2/kVmS+GUrN4pofHNCYYPaETFpjiT4UASORzyIb0TKnwXV//6+SAoCiTqMXdD zlOz803zogj/ZrcuY67k95tuCZKP/T3oKGHRypFx4Tk3vUmrTLmu2RAA6nu1xk5t3BWS jAwA== X-Gm-Message-State: AOAM533fMIEbJ8hpX8A8piit+iLJDbLl6eNQ24VC8SwguKHQ7+O3MBa/ mAZWAIujT71LYTfliHWdyT6BsA3K6TxYiOKe X-Google-Smtp-Source: ABdhPJwt47TT2pE0CfJCXX6fJWbJF9jQccoVT07xLymtWur80cupOsS2gxLsYMO75QF0OrzZry8RQQ== X-Received: by 2002:a17:906:e082:: with SMTP id gh2mr6080367ejb.406.1607076126537; Fri, 04 Dec 2020 02:02:06 -0800 (PST) Received: from localhost.localdomain (hst-221-106.medicom.bg. [84.238.221.106]) by smtp.gmail.com with ESMTPSA id p35sm3238242edd.58.2020.12.04.02.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 02:02:06 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dikshita@codeaurora.org, Alexandre Courbot , Vikash Garodia , Stanimir Varbanov Subject: [PATCH v2 1/4] venus: venc: Init the session only once in queue_setup Date: Fri, 4 Dec 2020 12:01:36 +0200 Message-Id: <20201204100139.6216-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201204100139.6216-1-stanimir.varbanov@linaro.org> References: <20201204100139.6216-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Init the hfi session only once in queue_setup and also cover that with inst->lock. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/venc.c | 85 ++++++++++++++++++------ 1 file changed, 64 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index 1c61602c5de1..e0053cc1b7eb 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -725,7 +725,9 @@ static int venc_init_session(struct venus_inst *inst) int ret; ret = hfi_session_init(inst, inst->fmt_cap->pixfmt); - if (ret) + if (ret == -EINVAL) + return 0; + else if (ret) return ret; ret = venus_helper_set_input_resolution(inst, inst->width, @@ -762,17 +764,13 @@ static int venc_out_num_buffers(struct venus_inst *inst, unsigned int *num) struct hfi_buffer_requirements bufreq; int ret; - ret = venc_init_session(inst); + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); if (ret) return ret; - ret = venus_helper_get_bufreq(inst, HFI_BUFFER_INPUT, &bufreq); - *num = bufreq.count_actual; - hfi_session_deinit(inst); - - return ret; + return 0; } static int venc_queue_setup(struct vb2_queue *q, @@ -781,7 +779,7 @@ static int venc_queue_setup(struct vb2_queue *q, { struct venus_inst *inst = vb2_get_drv_priv(q); unsigned int num, min = 4; - int ret = 0; + int ret; if (*num_planes) { if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE && @@ -803,6 +801,13 @@ static int venc_queue_setup(struct vb2_queue *q, return 0; } + mutex_lock(&inst->lock); + ret = venc_init_session(inst); + mutex_unlock(&inst->lock); + + if (ret) + return ret; + switch (q->type) { case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: *num_planes = inst->fmt_out->num_planes; @@ -838,6 +843,49 @@ static int venc_queue_setup(struct vb2_queue *q, return ret; } +static int venc_buf_init(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + + inst->buf_count++; + + return venus_helper_vb2_buf_init(vb); +} + +static void venc_release_session(struct venus_inst *inst) +{ + int ret; + + mutex_lock(&inst->lock); + + ret = hfi_session_deinit(inst); + if (ret || inst->session_error) + hfi_session_abort(inst); + + mutex_unlock(&inst->lock); + + venus_pm_load_scale(inst); + INIT_LIST_HEAD(&inst->registeredbufs); + venus_pm_release_core(inst); +} + +static void venc_buf_cleanup(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); + struct venus_buffer *buf = to_venus_buffer(vbuf); + + mutex_lock(&inst->lock); + if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + if (!list_empty(&inst->registeredbufs)) + list_del_init(&buf->reg_list); + mutex_unlock(&inst->lock); + + inst->buf_count--; + if (!inst->buf_count) + venc_release_session(inst); +} + static int venc_verify_conf(struct venus_inst *inst) { enum hfi_version ver = inst->core->res->hfi_version; @@ -888,38 +936,32 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) inst->sequence_cap = 0; inst->sequence_out = 0; - ret = venc_init_session(inst); - if (ret) - goto bufs_done; - ret = venus_pm_acquire_core(inst); if (ret) - goto deinit_sess; + goto error; ret = venc_set_properties(inst); if (ret) - goto deinit_sess; + goto error; ret = venc_verify_conf(inst); if (ret) - goto deinit_sess; + goto error; ret = venus_helper_set_num_bufs(inst, inst->num_input_bufs, inst->num_output_bufs, 0); if (ret) - goto deinit_sess; + goto error; ret = venus_helper_vb2_start_streaming(inst); if (ret) - goto deinit_sess; + goto error; mutex_unlock(&inst->lock); return 0; -deinit_sess: - hfi_session_deinit(inst); -bufs_done: +error: venus_helper_buffers_done(inst, q->type, VB2_BUF_STATE_QUEUED); if (q->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) inst->streamon_out = 0; @@ -931,7 +973,8 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) static const struct vb2_ops venc_vb2_ops = { .queue_setup = venc_queue_setup, - .buf_init = venus_helper_vb2_buf_init, + .buf_init = venc_buf_init, + .buf_cleanup = venc_buf_cleanup, .buf_prepare = venus_helper_vb2_buf_prepare, .start_streaming = venc_start_streaming, .stop_streaming = venus_helper_vb2_stop_streaming, From patchwork Fri Dec 4 10:01:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11951325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ECB7C2BBCD for ; Fri, 4 Dec 2020 10:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1170322838 for ; Fri, 4 Dec 2020 10:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387870AbgLDKDa (ORCPT ); Fri, 4 Dec 2020 05:03:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387837AbgLDKD2 (ORCPT ); Fri, 4 Dec 2020 05:03:28 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D873BC08C5F2 for ; Fri, 4 Dec 2020 02:02:09 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id d18so5201142edt.7 for ; Fri, 04 Dec 2020 02:02:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LyeOql6QYmpd/1nhWP8WR5ehn5BlBeFQlh24gAVBRhU=; b=qgzeAQEaUfEMnYTzNM6py9Wnux2p0x09OoGjBhg6NOU+FMrXss1qgfQ2Uo9T7VGEFY 16Bg01jAAwONWqA+zIP0xQdFQ+WuV9G5+CWhheMyc0v/q9uLo9HhQldX2zN2V6chcSSs NFQ4OVqUn8nKlV5wiYdOnU+C7sXxPsTFJXehDaoz0XvfMVi8MDhNjTnuqxKT6/GjUOpj 5BipSy7smzfy9UHC2OpEr3RC/830bP9YW0DDPkivv2ZAoPd+i7x4Jbt/HrXKB6oWCXdI dcTHH0KTii8Jlnw61wrgR7lo7b6KuMu49VfvcBxEtQfd7RTrsAhboI0uD0dojTGwgNjp fDjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LyeOql6QYmpd/1nhWP8WR5ehn5BlBeFQlh24gAVBRhU=; b=lE/cqxA+iJI+BX43qIoo1nvBLs1Ejdsl3rvW2mJyeMq4Gwvnie8aojtLN9U5CMaMM1 foBxuQYYVwuP3zzDC0svbOwXhptUcBTaWNh4kAwCqsAaEbq7/qo/WDBU4Mvl0nTpm2QA xRXcS8ZgwxrMgdU6r5a0o8vlQgf6FvArr5Bv+5qOaj+13m/xU5wzCrXVcaOwmbBqJGiR iS8RrelK4ln+pWE2gn5Ym+wwbWykyonwj4bBXNEoxV/XqXgc9dYcr6opy7zeDld6bbF4 mww9Myhs7ihy8yDQ4G4YcHbh9j8lslu1bUkGHV53S8WtdR5a091bZhdVk1dQ39j6BTJq xPXQ== X-Gm-Message-State: AOAM531hpuLvrD3vjwVx+295pkrgXoefgvDCykMouruhnXBkVmPVNSr6 Ile6QSF4wQBmdV08gy6ubiklYwCgRAGG08WV X-Google-Smtp-Source: ABdhPJz/Sxg/WJbiIXiuRLe60U4NP4zuCBjEEmLjA7ER1WbD/7Lje9Cv0tsJd0eR4snOoctKKAK0DQ== X-Received: by 2002:a50:b941:: with SMTP id m59mr6871336ede.371.1607076128347; Fri, 04 Dec 2020 02:02:08 -0800 (PST) Received: from localhost.localdomain (hst-221-106.medicom.bg. [84.238.221.106]) by smtp.gmail.com with ESMTPSA id p35sm3238242edd.58.2020.12.04.02.02.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 02:02:07 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dikshita@codeaurora.org, Alexandre Courbot , Vikash Garodia , Stanimir Varbanov Subject: [PATCH v2 2/4] venus: Limit HFI sessions to the maximum supported Date: Fri, 4 Dec 2020 12:01:37 +0200 Message-Id: <20201204100139.6216-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201204100139.6216-1-stanimir.varbanov@linaro.org> References: <20201204100139.6216-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Currently we rely on firmware to return error when we reach the maximum supported number of sessions. But this errors are happened at reqbuf time which is a bit later. The more reasonable way looks like is to return the error on driver open. To achieve that modify hfi_session_create to return error when we reach maximum count of sessions and thus refuse open. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/hfi.c | 16 +++++++++++++--- drivers/media/platform/qcom/venus/hfi_parser.c | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f03ed427accd..775d7bf6587d 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -96,6 +96,7 @@ struct venus_format { #define MAX_CAP_ENTRIES 32 #define MAX_ALLOC_MODE_ENTRIES 16 #define MAX_CODEC_NUM 32 +#define MAX_SESSIONS 16 struct raw_formats { u32 buftype; diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 638ed5cfe05e..8786609d269e 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -175,6 +175,8 @@ static int wait_session_msg(struct venus_inst *inst) int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) { struct venus_core *core = inst->core; + bool max; + int ret; if (!ops) return -EINVAL; @@ -184,11 +186,19 @@ int hfi_session_create(struct venus_inst *inst, const struct hfi_inst_ops *ops) inst->ops = ops; mutex_lock(&core->lock); - list_add_tail(&inst->list, &core->instances); - atomic_inc(&core->insts_count); + + max = atomic_add_unless(&core->insts_count, 1, + core->max_sessions_supported); + if (!max) { + ret = -EAGAIN; + } else { + list_add_tail(&inst->list, &core->instances); + ret = 0; + } + mutex_unlock(&core->lock); - return 0; + return ret; } EXPORT_SYMBOL_GPL(hfi_session_create); diff --git a/drivers/media/platform/qcom/venus/hfi_parser.c b/drivers/media/platform/qcom/venus/hfi_parser.c index 363ee2a65453..52898633a8e6 100644 --- a/drivers/media/platform/qcom/venus/hfi_parser.c +++ b/drivers/media/platform/qcom/venus/hfi_parser.c @@ -276,6 +276,9 @@ u32 hfi_parser(struct venus_core *core, struct venus_inst *inst, void *buf, words_count--; } + if (!core->max_sessions_supported) + core->max_sessions_supported = MAX_SESSIONS; + parser_fini(inst, codecs, domain); return HFI_ERR_NONE; From patchwork Fri Dec 4 10:01:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11951331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA4EAC0018C for ; Fri, 4 Dec 2020 10:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 835B1227C3 for ; Fri, 4 Dec 2020 10:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387939AbgLDKDi (ORCPT ); Fri, 4 Dec 2020 05:03:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387969AbgLDKDh (ORCPT ); Fri, 4 Dec 2020 05:03:37 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5761FC08E860 for ; Fri, 4 Dec 2020 02:02:12 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id r5so5172681eda.12 for ; Fri, 04 Dec 2020 02:02:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QyipFjHgAmocE8ormLtvsmE4o3Jh7LHKovtmyPj5YlM=; b=ZBf9b1W6r6l4f2RQfTOX0527qxCRZgPZInel8c4Q3Gj3IbZSvLi0LqxtupwL0sXUHd ehbvyWp7+aGYI2XDYwTSmR99t9iAqNd9XhFBuFquRE4Gd1HFYJZnZLOdoGikFj1aXRel NER8UoatYNhrNWio8TbZbi9T+zBPqz+02hgOQBz6g9AaAnGsIJE3AMNFogRW4MyxYsjV +Y8dMGWhm5Y/2cNmXMrJ9sCpNzKdDxLJp6B46NMkzdhJjiyP9Doox6bsRM5XATY7lf0/ bTA0u5OfG0oIUiHrJwm2VyURrlHLVlVHbA17tm8R5rEAnCUA7PmEqwKMvQgot/VxbGG+ fosg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QyipFjHgAmocE8ormLtvsmE4o3Jh7LHKovtmyPj5YlM=; b=X7XjTWgi+7r/ZnqD00Ais8/DLDuUVoXSCs5czhcJCdY1dxVwo+Roe7tu/rJE5e9vaB sOQH4zaSVhj4cg3+CVSont1EsBIftCzLj8dMiS3AdAtoMMpIUMhlulGoIePQILdiXMXS FTiEkXGcNWJ23WEJg2At38+KeM9VmyrJd6nOuk/lf2W/2eBe7/jivBO99V0x9+nMwlce 8whvbRKCBsQyXPDjzFg+DfoUjuHyfAA3oCTQ1OUxiK5gVe5/bYt9cKJAUs2vcnyO1/mc QPTw106JoOyzlEHS6VHuvL++9LOta1Oyp01RlyM/yhY7BaOcsBr/s9SHYM6W+jGNUdKU Q0CA== X-Gm-Message-State: AOAM533icHesqPoAptqltekbUvswYcrSF50FVQhwQBMWalsgMvJT/pus eGtG9XpYrpLb+0uDj2u1aTeGeYjHzLX/Q41/ X-Google-Smtp-Source: ABdhPJyYTg8kwFLyrDBUIa+TKRZpk9wxumWXzQyNxJGm+Yh/z6nP9bGPgalMXl24jQ3598vQ84NwNA== X-Received: by 2002:a05:6402:1b1e:: with SMTP id by30mr5474668edb.75.1607076130701; Fri, 04 Dec 2020 02:02:10 -0800 (PST) Received: from localhost.localdomain (hst-221-106.medicom.bg. [84.238.221.106]) by smtp.gmail.com with ESMTPSA id p35sm3238242edd.58.2020.12.04.02.02.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 02:02:10 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dikshita@codeaurora.org, Alexandre Courbot , Vikash Garodia , Stanimir Varbanov Subject: [PATCH v2 3/4] media: venus: request for interrupt from venus Date: Fri, 4 Dec 2020 12:01:38 +0200 Message-Id: <20201204100139.6216-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201204100139.6216-1-stanimir.varbanov@linaro.org> References: <20201204100139.6216-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Vikash Garodia For synchronous commands, update the message queue variable. This would inform video firmware to raise interrupt on host CPU whenever there is a response for such commands. Signed-off-by: Vikash Garodia Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi_venus.c | 77 +++++++++++-------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c index 4be4a75ddcb6..3d16afc461bb 100644 --- a/drivers/media/platform/qcom/venus/hfi_venus.c +++ b/drivers/media/platform/qcom/venus/hfi_venus.c @@ -372,7 +372,7 @@ static void venus_soft_int(struct venus_hfi_device *hdev) } static int venus_iface_cmdq_write_nolock(struct venus_hfi_device *hdev, - void *pkt) + void *pkt, bool sync) { struct device *dev = hdev->core->dev; struct hfi_pkt_hdr *cmd_packet; @@ -394,18 +394,29 @@ static int venus_iface_cmdq_write_nolock(struct venus_hfi_device *hdev, return ret; } + if (sync) { + /* + * Inform video hardware to raise interrupt for synchronous + * commands + */ + queue = &hdev->queues[IFACEQ_MSG_IDX]; + queue->qhdr->rx_req = 1; + /* ensure rx_req is updated in memory */ + wmb(); + } + if (rx_req) venus_soft_int(hdev); return 0; } -static int venus_iface_cmdq_write(struct venus_hfi_device *hdev, void *pkt) +static int venus_iface_cmdq_write(struct venus_hfi_device *hdev, void *pkt, bool sync) { int ret; mutex_lock(&hdev->lock); - ret = venus_iface_cmdq_write_nolock(hdev, pkt); + ret = venus_iface_cmdq_write_nolock(hdev, pkt, sync); mutex_unlock(&hdev->lock); return ret; @@ -428,7 +439,7 @@ static int venus_hfi_core_set_resource(struct venus_core *core, u32 id, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -778,7 +789,7 @@ static int venus_sys_set_debug(struct venus_hfi_device *hdev, u32 debug) pkt_sys_debug_config(pkt, HFI_DEBUG_MODE_QUEUE, debug); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -795,7 +806,7 @@ static int venus_sys_set_coverage(struct venus_hfi_device *hdev, u32 mode) pkt_sys_coverage_config(pkt, mode); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -816,7 +827,7 @@ static int venus_sys_set_idle_message(struct venus_hfi_device *hdev, pkt_sys_idle_indicator(pkt, enable); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -834,7 +845,7 @@ static int venus_sys_set_power_control(struct venus_hfi_device *hdev, pkt_sys_power_control(pkt, enable); - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -885,14 +896,14 @@ static int venus_sys_set_default_properties(struct venus_hfi_device *hdev) return ret; } -static int venus_session_cmd(struct venus_inst *inst, u32 pkt_type) +static int venus_session_cmd(struct venus_inst *inst, u32 pkt_type, bool sync) { struct venus_hfi_device *hdev = to_hfi_priv(inst->core); struct hfi_session_pkt pkt; pkt_session_cmd(&pkt, pkt_type, inst); - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, sync); } static void venus_flush_debug_queue(struct venus_hfi_device *hdev) @@ -922,7 +933,7 @@ static int venus_prepare_power_collapse(struct venus_hfi_device *hdev, pkt_sys_pc_prep(&pkt); - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); if (ret) return ret; @@ -1064,13 +1075,13 @@ static int venus_core_init(struct venus_core *core) venus_set_state(hdev, VENUS_STATE_INIT); - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); if (ret) return ret; pkt_sys_image_version(&version_pkt); - ret = venus_iface_cmdq_write(hdev, &version_pkt); + ret = venus_iface_cmdq_write(hdev, &version_pkt, false); if (ret) dev_warn(dev, "failed to send image version pkt to fw\n"); @@ -1099,7 +1110,7 @@ static int venus_core_ping(struct venus_core *core, u32 cookie) pkt_sys_ping(&pkt, cookie); - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, false); } static int venus_core_trigger_ssr(struct venus_core *core, u32 trigger_type) @@ -1112,7 +1123,7 @@ static int venus_core_trigger_ssr(struct venus_core *core, u32 trigger_type) if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, false); } static int venus_session_init(struct venus_inst *inst, u32 session_type, @@ -1130,7 +1141,7 @@ static int venus_session_init(struct venus_inst *inst, u32 session_type, if (ret) goto err; - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, true); if (ret) goto err; @@ -1151,7 +1162,7 @@ static int venus_session_end(struct venus_inst *inst) dev_warn(dev, "fw coverage msg ON failed\n"); } - return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_END); + return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_END, true); } static int venus_session_abort(struct venus_inst *inst) @@ -1160,7 +1171,7 @@ static int venus_session_abort(struct venus_inst *inst) venus_flush_debug_queue(hdev); - return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_ABORT); + return venus_session_cmd(inst, HFI_CMD_SYS_SESSION_ABORT, true); } static int venus_session_flush(struct venus_inst *inst, u32 flush_mode) @@ -1173,22 +1184,22 @@ static int venus_session_flush(struct venus_inst *inst, u32 flush_mode) if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, true); } static int venus_session_start(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_START); + return venus_session_cmd(inst, HFI_CMD_SESSION_START, true); } static int venus_session_stop(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_STOP); + return venus_session_cmd(inst, HFI_CMD_SESSION_STOP, true); } static int venus_session_continue(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_CONTINUE); + return venus_session_cmd(inst, HFI_CMD_SESSION_CONTINUE, false); } static int venus_session_etb(struct venus_inst *inst, @@ -1205,7 +1216,7 @@ static int venus_session_etb(struct venus_inst *inst, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); } else if (session_type == VIDC_SESSION_TYPE_ENC) { struct hfi_session_empty_buffer_uncompressed_plane0_pkt pkt; @@ -1213,7 +1224,7 @@ static int venus_session_etb(struct venus_inst *inst, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, &pkt); + ret = venus_iface_cmdq_write(hdev, &pkt, false); } else { ret = -EINVAL; } @@ -1232,7 +1243,7 @@ static int venus_session_ftb(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, false); } static int venus_session_set_buffers(struct venus_inst *inst, @@ -1252,7 +1263,7 @@ static int venus_session_set_buffers(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, false); } static int venus_session_unset_buffers(struct venus_inst *inst, @@ -1272,17 +1283,17 @@ static int venus_session_unset_buffers(struct venus_inst *inst, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, true); } static int venus_session_load_res(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_LOAD_RESOURCES); + return venus_session_cmd(inst, HFI_CMD_SESSION_LOAD_RESOURCES, true); } static int venus_session_release_res(struct venus_inst *inst) { - return venus_session_cmd(inst, HFI_CMD_SESSION_RELEASE_RESOURCES); + return venus_session_cmd(inst, HFI_CMD_SESSION_RELEASE_RESOURCES, true); } static int venus_session_parse_seq_hdr(struct venus_inst *inst, u32 seq_hdr, @@ -1299,7 +1310,7 @@ static int venus_session_parse_seq_hdr(struct venus_inst *inst, u32 seq_hdr, if (ret) return ret; - ret = venus_iface_cmdq_write(hdev, pkt); + ret = venus_iface_cmdq_write(hdev, pkt, false); if (ret) return ret; @@ -1320,7 +1331,7 @@ static int venus_session_get_seq_hdr(struct venus_inst *inst, u32 seq_hdr, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, false); } static int venus_session_set_property(struct venus_inst *inst, u32 ptype, @@ -1339,7 +1350,7 @@ static int venus_session_set_property(struct venus_inst *inst, u32 ptype, if (ret) return ret; - return venus_iface_cmdq_write(hdev, pkt); + return venus_iface_cmdq_write(hdev, pkt, false); } static int venus_session_get_property(struct venus_inst *inst, u32 ptype) @@ -1352,7 +1363,7 @@ static int venus_session_get_property(struct venus_inst *inst, u32 ptype) if (ret) return ret; - return venus_iface_cmdq_write(hdev, &pkt); + return venus_iface_cmdq_write(hdev, &pkt, true); } static int venus_resume(struct venus_core *core) From patchwork Fri Dec 4 10:01:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 11951329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFF15C1B087 for ; Fri, 4 Dec 2020 10:04:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A541622838 for ; Fri, 4 Dec 2020 10:04:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387983AbgLDKDi (ORCPT ); Fri, 4 Dec 2020 05:03:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387902AbgLDKDd (ORCPT ); Fri, 4 Dec 2020 05:03:33 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC4EAC08E863 for ; Fri, 4 Dec 2020 02:02:13 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id g20so7858857ejb.1 for ; Fri, 04 Dec 2020 02:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fik6fEowz12+2Ryuqjd810QUwD4ENaiIRDI49CE7Imo=; b=s0IPi2BAvrZXVg6MFhcozWTscLQzWG5DFcmiVlxDGmRFk0HHGu3rKsyxBoR2ctJDmS ybNq+4AZfWqrIOWlOwMMn9ypj6s/3xIywX/t+a5UUsOdWxhzpUNYUhXAEX4nOrMahzgl E2HbZZoHFdF9h0xQq7Ot8KVfRHaHcNhyfGw5gHPcN4Img0/YCjUtf2LlRFhe+ypQTA15 B/498boF+b3BY6jxxh1TnBalh1CtYptZLZF36jb5L6n7/fNUlHZolwjUIMDfEqW+QuC1 XZ7+YsaRBQJbZvr5SdtIoyuQXN+LxAxCAykzXM6hSWoNG7VV1IVkuB8tPfN783mK4Qyw zwEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fik6fEowz12+2Ryuqjd810QUwD4ENaiIRDI49CE7Imo=; b=qg5eXu/lK8TF6vR8crKy3RkDERRGquzmDVib7Vvyz8+Ec55O7ZEAM9LQKHlcTHqE18 M4NqI6kOYnHe6tgwNfxwAj4jcaz/OhfWPtR/c9hWPANHoLAA3hV9iaUQJPecIFtfV1PM dnNt/cUpj+RPH73n2q9tzsRldhXnPFR6sb0nAMdlGrfHo2RMc3ZItHZ+tH10NCGfjtS1 IJshjBhGLstvhI/Ecn1ltjRoacUaS7uSnaATijp+GdNjuOgW9GaHsBvCY4zirhVV/jVx 9tuBS1CSk7iOt2eGo1ElLs4pSoBxdqhJAeFshx7/HZ9isap1jUDAnOlbDNILxXWeu5uF RM2w== X-Gm-Message-State: AOAM530ZUNfsGQfVquDFRkBx46tiCHXMgd96nVEFR6Q5405lw2WeLq6k QngelqrNPYaiMkxiBFWDilSFNkmdk6SjNN66 X-Google-Smtp-Source: ABdhPJx6JYmI+hOefPFTpkOizK3567s+04FShF8enu15CF/OdVhVGAL1qWVPO77wZleP+ulEo6irpw== X-Received: by 2002:a17:906:7aca:: with SMTP id k10mr6229230ejo.215.1607076132455; Fri, 04 Dec 2020 02:02:12 -0800 (PST) Received: from localhost.localdomain (hst-221-106.medicom.bg. [84.238.221.106]) by smtp.gmail.com with ESMTPSA id p35sm3238242edd.58.2020.12.04.02.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 02:02:11 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: dikshita@codeaurora.org, Alexandre Courbot , Vikash Garodia , Stanimir Varbanov Subject: [PATCH v2 4/4] venus: hfi: Correct session init return error Date: Fri, 4 Dec 2020 12:01:39 +0200 Message-Id: <20201204100139.6216-5-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201204100139.6216-1-stanimir.varbanov@linaro.org> References: <20201204100139.6216-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The hfi_session_init can be called many times and it returns EINVAL when the session was already initialized. This error code (EINVAL) is confusing for the callers. Change hfi_session_init to return EALREADY error code when the session has been already initialized. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/hfi.c | 2 +- drivers/media/platform/qcom/venus/vdec.c | 2 +- drivers/media/platform/qcom/venus/venc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/qcom/venus/hfi.c b/drivers/media/platform/qcom/venus/hfi.c index 8786609d269e..0f2482367e06 100644 --- a/drivers/media/platform/qcom/venus/hfi.c +++ b/drivers/media/platform/qcom/venus/hfi.c @@ -221,7 +221,7 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt) mutex_unlock(&core->lock); if (inst->state != INST_UNINIT) - return -EINVAL; + return -EALREADY; inst->hfi_codec = to_codec_type(pixfmt); reinit_completion(&inst->done); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index 8488411204c3..5337387eef27 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -741,7 +741,7 @@ static int vdec_session_init(struct venus_inst *inst) int ret; ret = hfi_session_init(inst, inst->fmt_out->pixfmt); - if (ret == -EINVAL) + if (ret == -EALREADY) return 0; else if (ret) return ret; diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index e0053cc1b7eb..cb8ff10e38c7 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -725,7 +725,7 @@ static int venc_init_session(struct venus_inst *inst) int ret; ret = hfi_session_init(inst, inst->fmt_cap->pixfmt); - if (ret == -EINVAL) + if (ret == -EALREADY) return 0; else if (ret) return ret;