From patchwork Mon Sep 28 16:44:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 249887 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 01BD0C4727E for ; Mon, 28 Sep 2020 16:45:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA7AD21548 for ; Mon, 28 Sep 2020 16:45:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="q+r+9RW4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbgI1QpB (ORCPT ); Mon, 28 Sep 2020 12:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbgI1Qo7 (ORCPT ); Mon, 28 Sep 2020 12:44:59 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41E7BC061755 for ; Mon, 28 Sep 2020 09:44:58 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id l17so2076213edq.12 for ; Mon, 28 Sep 2020 09:44:58 -0700 (PDT) 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=vCrCOuKF54mJwr9lBbJX2s9NMzS+YPosoi7yr81uyOQ=; b=q+r+9RW4KfO6h7wzZK3YbNglxI9qZlRaGK7V/C3TNNVrzT9x2bVFbZi+NprmtQER5I gZwDZ3An94VPEMiJ1wZ2TrHgtjXTPBdKy4VH3MT/dHQyzSTqX942LQhsKxr8A3wb2OZB 5ia71BXBvJrjXLWxgpXhhMOpl7lJGQxNgzcZpu568t9bCTqJI3BHVjxvwGgNo2Dlxrig 7oQg850GBoEYvnoUO+wsMFXT2D/LKZOQxdAHeUJy7S1u84JGyxeSzHPALHknBmVdS9tX Vds+GmOSOCjhzabVKggA3F3jCRfP/hM7NgHzjTYYoTS3hI8iUhQWJ7mp2+dv3wXu9yLX xjFQ== 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=vCrCOuKF54mJwr9lBbJX2s9NMzS+YPosoi7yr81uyOQ=; b=MdbP/v/b/LWjQ3GFagz0hNU7hh7CiLMDDQ5PF0rtv02BsHTbxn8erm1MEMMfr3vO0M obu6JnUHxT49oNUuJlUxqus/EZB/7UcIPgpHmOGtYOvfGJ3XWsrvFShOKppHUBL8MV5k 1dVFeDWSRXXohOJbBmvhcxO58RIq/GgnCnWJwbOcSTv74RIfpYeqfyQqLNKAKEPpPaB1 k+MG0yIOaJr2pJG2i09e8TDTkMRyT/OC4JDGUIqqwxiEUXa3iVdfKjuhkb5bFlSUes4O a3fMal8za1JdxlM/IAAsbXqL1nyq3lrgLf4LbJuf6icWvo9D6WLWI8zbEkwqUDPxN/Os Z8ig== X-Gm-Message-State: AOAM533JylzQCZZ+13LDiJDZ3CbVIP8Q2Tmosjy8734ovpMgV6gBKGZy zuMQwIRi1BPeJF18N+OGfD1D1g== X-Google-Smtp-Source: ABdhPJx4oek9IVKTvdsvad7NHvBClhcg9RKrvYZggDX853RgqSAPBqxQku7WqtO0KBlm2dMLseoTmA== X-Received: by 2002:aa7:d043:: with SMTP id n3mr2626502edo.243.1601311496944; Mon, 28 Sep 2020 09:44:56 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id nh1sm1912594ejb.21.2020.09.28.09.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 09:44:56 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH 1/3] venus: vdec: Fix non reliable setting of LAST flag Date: Mon, 28 Sep 2020 19:44:29 +0300 Message-Id: <20200928164431.21884-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928164431.21884-1-stanimir.varbanov@linaro.org> References: <20200928164431.21884-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In real use of dynamic-resolution-change it is observed that the LAST buffer flag (which marks the last decoded buffer with the resolution before the resolution-change event) is not reliably set. Fix this by set the LAST buffer flag on next queued capture buffer after the resolution-change event. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/core.h | 5 +- drivers/media/platform/qcom/venus/helpers.c | 6 +++ drivers/media/platform/qcom/venus/vdec.c | 52 ++++++++++++--------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index 7b79a33dc9d6..e30eeaf0ada9 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -274,7 +274,6 @@ enum venus_dec_state { VENUS_DEC_STATE_DRAIN = 5, VENUS_DEC_STATE_DECODING = 6, VENUS_DEC_STATE_DRC = 7, - VENUS_DEC_STATE_DRC_FLUSH_DONE = 8, }; struct venus_ts_metadata { @@ -339,7 +338,7 @@ struct venus_ts_metadata { * @priv: a private for HFI operations callbacks * @session_type: the type of the session (decoder or encoder) * @hprop: a union used as a holder by get property - * @last_buf: last capture buffer for dynamic-resoluton-change + * @next_buf_last: a flag to mark next queued capture buffer as last */ struct venus_inst { struct list_head list; @@ -401,7 +400,7 @@ struct venus_inst { union hfi_get_property hprop; unsigned int core_acquired: 1; unsigned int bit_depth; - struct vb2_buffer *last_buf; + bool next_buf_last; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 50439eb1ffea..5ca3920237c5 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1347,6 +1347,12 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) v4l2_m2m_buf_queue(m2m_ctx, vbuf); + /* Skip processing queued capture buffers after LAST flag */ + if (inst->session_type == VIDC_SESSION_TYPE_DEC && + V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type) && + inst->codec_state == VENUS_DEC_STATE_DRC) + goto unlock; + cache_payload(inst, vb); if (inst->session_type == VIDC_SESSION_TYPE_ENC && diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index ea13170a6a2c..c11bdf3ca21b 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -914,10 +914,6 @@ static int vdec_start_capture(struct venus_inst *inst) return 0; reconfigure: - ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, true); - if (ret) - return ret; - ret = vdec_output_conf(inst); if (ret) return ret; @@ -954,6 +950,7 @@ static int vdec_start_capture(struct venus_inst *inst) inst->streamon_cap = 1; inst->sequence_cap = 0; inst->reconfig = false; + inst->next_buf_last = false; return 0; @@ -985,6 +982,7 @@ static int vdec_start_output(struct venus_inst *inst) venus_helper_init_instance(inst); inst->sequence_out = 0; inst->reconfig = false; + inst->next_buf_last = false; ret = vdec_set_properties(inst); if (ret) @@ -1078,9 +1076,7 @@ static int vdec_stop_capture(struct venus_inst *inst) inst->codec_state = VENUS_DEC_STATE_STOPPED; break; case VENUS_DEC_STATE_DRC: - WARN_ON(1); - fallthrough; - case VENUS_DEC_STATE_DRC_FLUSH_DONE: + ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, true); inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; venus_helper_free_dpb_bufs(inst); break; @@ -1204,9 +1200,28 @@ static void vdec_buf_cleanup(struct vb2_buffer *vb) static void vdec_vb2_buf_queue(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); + static const struct v4l2_event eos = { .type = V4L2_EVENT_EOS }; vdec_pm_get_put(inst); + mutex_lock(&inst->lock); + + if (inst->next_buf_last && V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type) && + inst->codec_state == VENUS_DEC_STATE_DRC) { + vbuf->flags |= V4L2_BUF_FLAG_LAST; + vbuf->sequence = inst->sequence_cap++; + vbuf->field = V4L2_FIELD_NONE; + vb2_set_plane_payload(vb, 0, 0); + v4l2_m2m_buf_done(vbuf, VB2_BUF_STATE_DONE); + v4l2_event_queue_fh(&inst->fh, &eos); + inst->next_buf_last = false; + mutex_unlock(&inst->lock); + return; + } + + mutex_unlock(&inst->lock); + venus_helper_vb2_buf_queue(vb); } @@ -1250,13 +1265,6 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, vb->timestamp = timestamp_us * NSEC_PER_USEC; vbuf->sequence = inst->sequence_cap++; - if (inst->last_buf == vb) { - inst->last_buf = NULL; - vbuf->flags |= V4L2_BUF_FLAG_LAST; - vb2_set_plane_payload(vb, 0, 0); - vb->timestamp = 0; - } - if (vbuf->flags & V4L2_BUF_FLAG_LAST) { const struct v4l2_event ev = { .type = V4L2_EVENT_EOS }; @@ -1344,13 +1352,14 @@ static void vdec_event_change(struct venus_inst *inst, struct vb2_v4l2_buffer *last; int ret; - last = v4l2_m2m_last_dst_buf(inst->m2m_ctx); - if (last) - inst->last_buf = &last->vb2_buf; + inst->next_buf_last = true; - ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, false); - if (ret) - dev_dbg(dev, VDBGH "flush output error %d\n", ret); + last = v4l2_m2m_last_dst_buf(inst->m2m_ctx); + if (last) { + ret = hfi_session_flush(inst, HFI_FLUSH_OUTPUT, false); + if (ret) + dev_dbg(dev, VDBGH "flush output error %d\n", ret); + } } inst->reconfig = true; @@ -1395,8 +1404,7 @@ static void vdec_event_notify(struct venus_inst *inst, u32 event, static void vdec_flush_done(struct venus_inst *inst) { - if (inst->codec_state == VENUS_DEC_STATE_DRC) - inst->codec_state = VENUS_DEC_STATE_DRC_FLUSH_DONE; + dev_dbg(inst->core->dev_dec, VDBGH "flush done\n"); } static const struct hfi_inst_ops vdec_hfi_ops = { From patchwork Mon Sep 28 16:44:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 292614 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 48C06C2D0A8 for ; Mon, 28 Sep 2020 16:45:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 12CFE2100A for ; Mon, 28 Sep 2020 16:45:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="tpOXtrfJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbgI1QpA (ORCPT ); Mon, 28 Sep 2020 12:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbgI1QpA (ORCPT ); Mon, 28 Sep 2020 12:45:00 -0400 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 D0B01C0613D3 for ; Mon, 28 Sep 2020 09:44:59 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id n22so2107467edt.4 for ; Mon, 28 Sep 2020 09:44:59 -0700 (PDT) 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=pNVoDDa73nLv4JDe00OIrDQno9iqywhjci+yCQnsgFM=; b=tpOXtrfJ6VqKQbgemY+gWrkkQCg60SFpahEx9UlUfOhYznIaJBHKAbmD86vO8D9gjW hbTzMywGKfc5142bxSp8+CKOk+zrz2lCn3l7X1ltMDfbDCbQow65cXIMp1vOJYxjGh4u wApZ2aX/WzHbv2Tx6FUiiXpZUVScY6FX+kVjtWG+iGhPoysVdt1z8YCQm0e5GMoe8tpF dJn7aJ/92C2WXAL2xRIKmS3Tjiv4CzEqc83fF9JaoKSGm8M2LFeWSEDNwsCg46v+n2Rz o+ok4U7iN83/jquRfOaOJ8dQHN713fE3u4Zsu0j3sZt6uCftmfj3Kceqyfr4gVedSENw +rPQ== 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=pNVoDDa73nLv4JDe00OIrDQno9iqywhjci+yCQnsgFM=; b=Lu6NB/z3+T2sQhgXs2h85EcBfwPqIW+9XxUGqwTj3I50eEKUigleCcqRfKLVaCkWEU uQ/jHCGEIbC+f6dfADW1I89hk+CVqln3REX/0X/G/wswDBAjTxJeC2lDppPrzGTMSa2K /3krEBZvMsB9k88Q67LwuktHFG1FZQ9MytnG3ejYZVFKdBf3XY7t1RAfgyGM/1kuNoUw TKV0VvA7taOt6rYkqz+UwM5okI7od3bpZcAL4hkZuYTsXEVoe6hn+eYx2XXuOTb+i8iA 5t7mQCbqtcqOF5uTCgESaETecZFzDLJ/YxxDNmtVj9ioQH0gvq4HstoUNjvT08EqQuUr USug== X-Gm-Message-State: AOAM531YAWGn4jtFTKDPlGmvmMPa1plBxH2E5PnUM441jNMg8/vh9fpg 2kUKQoHHKEhGCNx7B4GItn4F7g== X-Google-Smtp-Source: ABdhPJzGN/BdbHToPVEP3Bq5YaaCW7Rm5XJzg8OCwOnaScyigFfzB88+QpaFm1QnzMtleDWBxdP/AA== X-Received: by 2002:a05:6402:10c6:: with SMTP id p6mr2804428edu.76.1601311498558; Mon, 28 Sep 2020 09:44:58 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id nh1sm1912594ejb.21.2020.09.28.09.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 09:44:58 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH 2/3] venus: vdec: Make decoder return LAST flag for sufficient event Date: Mon, 28 Sep 2020 19:44:30 +0300 Message-Id: <20200928164431.21884-3-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928164431.21884-1-stanimir.varbanov@linaro.org> References: <20200928164431.21884-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This makes the decoder to behaives equally for sufficient and insufficient events. After this change the LAST buffer flag will be set when the new resolution (in dynamic-resolution-change state) is smaller then the old bitstream resolution. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/vdec.c | 41 ++++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index c11bdf3ca21b..c006401255dc 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -634,6 +634,7 @@ static int vdec_output_conf(struct venus_inst *inst) { struct venus_core *core = inst->core; struct hfi_enable en = { .enable = 1 }; + struct hfi_buffer_requirements bufreq; u32 width = inst->out_width; u32 height = inst->out_height; u32 out_fmt, out2_fmt; @@ -709,6 +710,22 @@ static int vdec_output_conf(struct venus_inst *inst) } if (IS_V3(core) || IS_V4(core)) { + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT, &bufreq); + if (ret) + return ret; + + if (bufreq.size > inst->output_buf_size) + return -EINVAL; + + if (inst->dpb_fmt) { + ret = venus_helper_get_bufreq(inst, HFI_BUFFER_OUTPUT2, &bufreq); + if (ret) + return ret; + + if (bufreq.size > inst->output2_buf_size) + return -EINVAL; + } + if (inst->output2_buf_size) { ret = venus_helper_set_bufsize(inst, inst->output2_buf_size, @@ -1327,19 +1344,15 @@ static void vdec_event_change(struct venus_inst *inst, dev_dbg(dev, VDBGM "event %s sufficient resources (%ux%u)\n", sufficient ? "" : "not", ev_data->width, ev_data->height); - if (sufficient) { - hfi_session_continue(inst); - } else { - switch (inst->codec_state) { - case VENUS_DEC_STATE_INIT: - inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; - break; - case VENUS_DEC_STATE_DECODING: - inst->codec_state = VENUS_DEC_STATE_DRC; - break; - default: - break; - } + switch (inst->codec_state) { + case VENUS_DEC_STATE_INIT: + inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; + break; + case VENUS_DEC_STATE_DECODING: + inst->codec_state = VENUS_DEC_STATE_DRC; + break; + default: + break; } /* @@ -1348,7 +1361,7 @@ static void vdec_event_change(struct venus_inst *inst, * itself doesn't mark the last decoder output buffer with HFI EOS flag. */ - if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) { + if (inst->codec_state == VENUS_DEC_STATE_DRC) { struct vb2_v4l2_buffer *last; int ret; From patchwork Mon Sep 28 16:44:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 292615 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=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 34624C2D0A8 for ; Mon, 28 Sep 2020 16:45:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE1A521548 for ; Mon, 28 Sep 2020 16:45:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jAg4HwOA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726615AbgI1QpG (ORCPT ); Mon, 28 Sep 2020 12:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgI1QpB (ORCPT ); Mon, 28 Sep 2020 12:45:01 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85A27C0613CE for ; Mon, 28 Sep 2020 09:45:01 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id gx22so9505990ejb.5 for ; Mon, 28 Sep 2020 09:45:01 -0700 (PDT) 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=3TY70mrl16JaQxxZ4/GyqEClhKIDlyWn3cWhVRTCx/M=; b=jAg4HwOA8V0hDv7VAH72gwxC7xRztKPm0/hXDMY4Gx7OPZkKPj2RfbzSpfXYwklev+ fBucSHj6SYnj6YvbG35cZ4VcXc4n1Cdfb2Vj5Jjwjd3/n/vEi1NEJNpAzfmmSBaNutn4 T1cZz7HkOiP2/aolE96WtjEwLMJQeZoeYDtbQqw1W/66mDE57fI3nnWpkZzyLQV2mG+D GdxH8vN6dquf1IEr5cfjC6Kcj7vncBvHxoBUJ/zEajh/ijjqqFsYWp4AXHJ/MheCS3nX JFdMACk9YVMX/hgMxTBDifKOc9j+qeSRCJkc6F18lAsN+qUhG41AVQSQX4qFhDsLnMb1 4rxg== 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=3TY70mrl16JaQxxZ4/GyqEClhKIDlyWn3cWhVRTCx/M=; b=FLFq4OlyOlJnTgB2sVyUI/KKUjCC2acEuPQ7iw04TEW7l438Z4l7vFj9/YE5yaciey rhhn4wnlVvZVxL3ZDkJeYGZ0giAZq58/NOzWj/hC2BX1qtGevNVtXiWFbYYPRC9MsIPl G9c/klL1emagbJZYzYVziHeU7+JQmX4K3Zz3chVTEfFTlZJoXWO5ByOzjpvFt99qFnpl yZKLEYfErBKGxYLOGBR7u9Zza9mZNow6zwfCLpw4Y9P58gMmgPc0YHpWkqF7Ek5z1TVR IE4S61iRJOaQJkJDbWzEWpowNETrDf5Wnwpoi8aNZH/AwVjQdoKvsZe5dfuDtoee951u hmnQ== X-Gm-Message-State: AOAM530KLWKIa1arqFrTUCX8DdhRyi9zIiIwt6Rk2ynb7BkuDzHGizS1 WjxyieUErl6EkQDJbiv+WZ6PEQ== X-Google-Smtp-Source: ABdhPJznyUxh2GhH2l2Ggevd+n4Gz21ilSpQaAQxejxJyIu1YgKNCOVrLrCzasHQGVWIhjypxXcGOA== X-Received: by 2002:a17:906:2655:: with SMTP id i21mr2425348ejc.511.1601311500159; Mon, 28 Sep 2020 09:45:00 -0700 (PDT) Received: from localhost.localdomain ([195.24.90.54]) by smtp.gmail.com with ESMTPSA id nh1sm1912594ejb.21.2020.09.28.09.44.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 09:44:59 -0700 (PDT) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vikash Garodia , Alexandre Courbot , Mansur Alisha Shaik , Stanimir Varbanov Subject: [PATCH 3/3] venus: helpers: Lock outside of buffer queue helper Date: Mon, 28 Sep 2020 19:44:31 +0300 Message-Id: <20200928164431.21884-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200928164431.21884-1-stanimir.varbanov@linaro.org> References: <20200928164431.21884-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org After adding more logic in vdec buf_queue vb2 op it is not practical to have two lock/unlock for one decoder buf_queue. So move the instance lock in encoder and decoder vb2 buf_queue operations. Signed-off-by: Stanimir Varbanov --- drivers/media/platform/qcom/venus/helpers.c | 11 +++-------- drivers/media/platform/qcom/venus/vdec.c | 3 +-- drivers/media/platform/qcom/venus/venc.c | 11 ++++++++++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/qcom/venus/helpers.c b/drivers/media/platform/qcom/venus/helpers.c index 5ca3920237c5..2b6925b6c274 100644 --- a/drivers/media/platform/qcom/venus/helpers.c +++ b/drivers/media/platform/qcom/venus/helpers.c @@ -1343,34 +1343,29 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb) struct v4l2_m2m_ctx *m2m_ctx = inst->m2m_ctx; int ret; - mutex_lock(&inst->lock); - v4l2_m2m_buf_queue(m2m_ctx, vbuf); /* Skip processing queued capture buffers after LAST flag */ if (inst->session_type == VIDC_SESSION_TYPE_DEC && V4L2_TYPE_IS_CAPTURE(vb->vb2_queue->type) && inst->codec_state == VENUS_DEC_STATE_DRC) - goto unlock; + return; cache_payload(inst, vb); if (inst->session_type == VIDC_SESSION_TYPE_ENC && !(inst->streamon_out && inst->streamon_cap)) - goto unlock; + return; if (vb2_start_streaming_called(vb->vb2_queue)) { ret = is_buf_refed(inst, vbuf); if (ret) - goto unlock; + return; ret = session_process_buf(inst, vbuf); if (ret) return_buf_error(inst, vbuf); } - -unlock: - mutex_unlock(&inst->lock); } EXPORT_SYMBOL_GPL(venus_helper_vb2_buf_queue); diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index c006401255dc..044d50f217ce 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1237,9 +1237,8 @@ static void vdec_vb2_buf_queue(struct vb2_buffer *vb) return; } - mutex_unlock(&inst->lock); - venus_helper_vb2_buf_queue(vb); + mutex_unlock(&inst->lock); } static const struct vb2_ops vdec_vb2_ops = { diff --git a/drivers/media/platform/qcom/venus/venc.c b/drivers/media/platform/qcom/venus/venc.c index f8b1484e7dcd..f7fb6e362521 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -900,13 +900,22 @@ static int venc_start_streaming(struct vb2_queue *q, unsigned int count) return ret; } +static void venc_vb2_buf_queue(struct vb2_buffer *vb) +{ + struct venus_inst *inst = vb2_get_drv_priv(vb->vb2_queue); + + mutex_lock(&inst->lock); + venus_helper_vb2_buf_queue(vb); + mutex_unlock(&inst->lock); +} + static const struct vb2_ops venc_vb2_ops = { .queue_setup = venc_queue_setup, .buf_init = venus_helper_vb2_buf_init, .buf_prepare = venus_helper_vb2_buf_prepare, .start_streaming = venc_start_streaming, .stop_streaming = venus_helper_vb2_stop_streaming, - .buf_queue = venus_helper_vb2_buf_queue, + .buf_queue = venc_vb2_buf_queue, }; static void venc_buf_done(struct venus_inst *inst, unsigned int buf_type,