From patchwork Sun Dec 20 09:31:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346264 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3611111jai; Sun, 20 Dec 2020 01:34:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwlT0wlOFImdSGXv+VLKkOQKkkkSNJ2tuYFSRH3I9LGwOxITIWD6KfFZ9lcP6UxtX2nw5Jg X-Received: by 2002:a05:6402:a45:: with SMTP id bt5mr11781409edb.130.1608456894072; Sun, 20 Dec 2020 01:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456894; cv=none; d=google.com; s=arc-20160816; b=Io8h5N8HN/C0nFCqgLNVlTSA7yNMc6yBKGUbuX6XlnEUSURnPdCSBi+STx/dZyLopc lqw1kj5CtlZ/m24L73kMi7V5Yl/Vi+lXZrnyPpGRipQ85nlN5JHUaBU6NahyRMH9fEz5 +qxxHNXVtEq87ADUd/9BdEJEjwiVWx3b9jupKHrD36lKig/8EG6bDuccOiI9ZW1qyZSR EMDOfYuZN6VSSxSGqWESkz1hWIwBT+4NXxUs81XlsRdOBzV5mjmgJrfw9pMjFjfhPKUv fYnHXg0wzfJnSDii4MsxurqjBGz1G1OqbQFtzwCV+F+UXPRIC1/q2vYoPgYO3wZw9I/h 1LyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=6aeKehIdQ3xcJ7hMUC4Ib4NuGjCL36W4Z1hVfxcOU/w=; b=iCts21WoueVNeJGqSl9mlHfx66jnt7fo02RZ7x0hex8/BjVJi3FtCc8670qQuptH39 HufydHAw44Cn/rvuW/pQzkrD7pGrGVdLNHIKbzL/WW5ZeIzywni/cLGwSL30HTAqlssm 9nScULWXxPCHl19EUaDzMhLFtDf0fgW0KhqVk9EB8h5l8GebNgtil9n33bfcr7TM5Wd9 O9NiOTHgnY4o+DZwhAM1S3O5Sum04Etxz+P6ZCttJEtRj8fh4eUTOtirXV1uiwWzAmri 5lg8Y/I4dScrL5R55FjhhkNuCf/g6ek99v/7vNi0KyP5nvsTrQLaaszxUSp41uF7vLPP kc+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AKMIpW0t; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg19si7151815ejc.365.2020.12.20.01.34.53; Sun, 20 Dec 2020 01:34:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AKMIpW0t; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727319AbgLTJdi (ORCPT + 15 others); Sun, 20 Dec 2020 04:33:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727120AbgLTJdd (ORCPT ); Sun, 20 Dec 2020 04:33:33 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2C72C061248 for ; Sun, 20 Dec 2020 01:32:51 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id c7so6740550edv.6 for ; Sun, 20 Dec 2020 01:32:51 -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=6aeKehIdQ3xcJ7hMUC4Ib4NuGjCL36W4Z1hVfxcOU/w=; b=AKMIpW0t/uOojgm3AC0fIqDChEHOQJp3IGk02LFscyCN8TyKCv6Gd/MwhcCsKfLSLA 4eY1vGAWnuBrPs0pHHeraBgoDBT6gy97vHve1DoV6Tkbid/C3qlD0Fevwh35Eb9k+0Vr L7Q2DDOUylBLELF+kDHhy32M/TlIhYpjl5uprRs7JazqJ2RtdzxZCIh3w/vs/3c1FzYu q3rnBdPyCZnV4lSZK7plEqKtppcDfdjd8BKc6ragOGBoqfVfAhwu5AHhw8XLDOKueT90 AcyoEnL6pOIyWRC/MB2jFtfLibw0e5Mu9diVYT7RExfPJ+h1S4Kedh/eV3/y1zXCujGs n4fA== 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=6aeKehIdQ3xcJ7hMUC4Ib4NuGjCL36W4Z1hVfxcOU/w=; b=RyZx/aqX3GeZN5gIIApnepLcE2pUS2sPJxXR384fn4tTPIzr1gqunfPc9OmJnVQ8bL mHmCpaz75qeO4WyvIpJrAAYp4TM6jYy3fvPdpQWQtPmBkXJ0CnZuXz9tirR8wTs42pEd bcqtmQrT/yPIiseZCSTuOdoJby68hBKrwt8WkZtig3in6sRW4aMq5Sm/wEdB7FFDHkfF gJ6HDq96hQ9eEz4jr+A+hId5mg5Tu1HbQs3WETC7knPaYHcNZC0DJZqsZfYxxHBL7Cud 49yln0Zk2kjBMl8zlj3/eWw8rywjSl5Y3+l0tctz1nMrJ0P1qrF3BqDfwBh+Tuwm/aBm NvPQ== X-Gm-Message-State: AOAM530mzqt+jox0UQSOFkBpeIlerRwCnmOHIBpfrl0vace9vj1sx+uZ Txf+XY7nkGCLji9/4+hg/058Vg== X-Received: by 2002:a05:6402:17cb:: with SMTP id s11mr11401957edy.119.1608456770484; Sun, 20 Dec 2020 01:32:50 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:50 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 1/5] venus: vdec: Fix non reliable setting of LAST flag Date: Sun, 20 Dec 2020 11:31:26 +0200 Message-Id: <20201220093130.10177-2-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-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 | 45 ++++++++++++--------- 3 files changed, 33 insertions(+), 23 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index f03ed427accd..db0e6738281e 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -285,7 +285,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 { @@ -350,7 +349,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; @@ -413,7 +412,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 8488411204c3..eb94e167e282 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -917,10 +917,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; @@ -948,6 +944,8 @@ static int vdec_start_capture(struct venus_inst *inst) venus_pm_load_scale(inst); + inst->next_buf_last = false; + ret = hfi_session_continue(inst); if (ret) goto free_dpb_bufs; @@ -988,6 +986,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) @@ -1081,9 +1080,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; @@ -1207,9 +1204,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); } @@ -1253,13 +1269,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 }; @@ -1359,12 +1368,9 @@ static void vdec_event_change(struct venus_inst *inst, */ if (!sufficient && inst->codec_state == VENUS_DEC_STATE_DRC) { - 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) @@ -1413,8 +1419,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 Sun Dec 20 09:31:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanimir Varbanov X-Patchwork-Id: 346279 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, 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 E35FDC3527A for ; Sun, 20 Dec 2020 09:34:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B437223121 for ; Sun, 20 Dec 2020 09:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727489AbgLTJe1 (ORCPT ); Sun, 20 Dec 2020 04:34:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbgLTJeO (ORCPT ); Sun, 20 Dec 2020 04:34:14 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41D14C0611CC for ; Sun, 20 Dec 2020 01:32:55 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id b2so6779969edm.3 for ; Sun, 20 Dec 2020 01:32:55 -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=xJWHNxMCkDCEyrMRNKllf8ulu4dBqb0sn+GPkcIS48k=; b=F4B8GnMtgYPmuWkyGKdO+mCwavMP7yX8XX8leC8vRBx6ryHCxdwHnB5xhAa8IGmsrw 1wKmH2uyBlf86AIAwJANVDnEe/4XF9IH6vcJ97OjaSVc8uvR/DujyaytMaUYiupB0K16 MqDdLk+qZmpj81I7IWzUz6AWPEgNvfWeyfl/+ZkSzG2WMMLVbvO0KXlA2Aueh+CVpV0m unsIJUixZU7n75wbXhtGnwhl33pcyYNa2m3lu3fbdBwrRZybM5J/lxUGDGDHSJx21KQJ NoD4q4Nj5YhHpGh40Hlc3OmSIgG6qJNkfeZAXUgJp+Fvl+L39n+y8LMDw3ws/Q8derws 8MMg== 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=xJWHNxMCkDCEyrMRNKllf8ulu4dBqb0sn+GPkcIS48k=; b=CXMZPefWYldhwEa+Nr1Mb76qjN9WVex0UF4OgzYbkEzAh4F6gl5HA3Xyf/D6CkKHRm tUxiFqkZZEFZ6XQ9EspcU7dxRO9y/nqJsoFBSmQrvYwq6HGtELpa6z0yxzZACjSU9H3k iqsMDn4dm5tY1T45xzxb7JYtqsqk2TWFWDWOsZ7Llz4Wp321GnXJ+RKVrb/ysb6zdRrh VFEvfKLkOEec3uyTAEVbbo+JJhVZmx0sx939btBKQdq9lpEKaZGqcxnp7NM19/nTd7Ov iFPxFvpr9d1cWPl3x3dUYX/Wb4SzSD0bc+vmx6RPEDVvHCJKaSTK/AUjs8HVgrDIxG6M pUEg== X-Gm-Message-State: AOAM530xAgWeIdPO9zpN4pS2rgwWcsYO1oqyWJ/PsiLFPGvlKyRIIElU lJh217m1aSsI83S11LQoGEpH9A== X-Google-Smtp-Source: ABdhPJxr2vhEN0iJvtSS0+v3ybxAE/PDGojn5P72QUuDhfNqlV0hZEz8m4srPO/70HzDfhu36ulLsQ== X-Received: by 2002:a05:6402:491:: with SMTP id k17mr6139719edv.342.1608456774044; Sun, 20 Dec 2020 01:32:54 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:53 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 3/5] venus: helpers: Lock outside of buffer queue helper Date: Sun, 20 Dec 2020 11:31:28 +0200 Message-Id: <20201220093130.10177-4-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-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 4ce23c2fc6eb..9f2c7b3e7d4c 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -1241,9 +1241,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 1c61602c5de1..4ecf78e30b59 100644 --- a/drivers/media/platform/qcom/venus/venc.c +++ b/drivers/media/platform/qcom/venus/venc.c @@ -929,13 +929,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, From patchwork Sun Dec 20 09:31: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: 346268 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp3611163jai; Sun, 20 Dec 2020 01:34:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTmLVT5cUFeYzHkheUAkkJjpHXYcn7Sc1lCe5TAO2cGLugXCWPO/U2+T8lkWit9imJ0JRT X-Received: by 2002:a17:906:e28c:: with SMTP id gg12mr11644329ejb.74.1608456898713; Sun, 20 Dec 2020 01:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456898; cv=none; d=google.com; s=arc-20160816; b=IiOqHr0PeGB95QEw6CDDS6A7TlSq42+x9BgzrCS6jjdElutb9KDuwi8MqUS/MnXEjt Z+rTwbeU2Nx/A319z1zP33ce9F3DdQYpujs6wDxq3brsHwGFbki3rOT2KR2qCML4N7Wo Jw61kY+2tx8tlzwcOD5oTjXxl0p3kynDwyZAbvRqNUtUkd14Zu7QNoltcs1PYMz1xp+6 PFFMy1fmwKNjvFYAs1K9GZSmT3+gQVJJ7kDX+AmPnx+26X/FlhS3PbUCS3I2473HAzlF FqDcDnZrTbSgcdEq1rJVgskC40WQwU4XJH2auKYJAB3Zzz4vhGyTv5808qR0BAJfiVJu A21g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=FN/bEnipr2y9sCYb7N5bkHhgN7bbMj0oywhCqcGevOA=; b=Nj2lGSChog0xCnNmMClEPjFWH74N06BtrDvRd6GwI/GM4NIqa7srxLqMgpLc04acAI UQsLOaW0wvgMFK14Ac0YsASP4S98OAvaPsegO7f+XB4zXK8jkAdqTAFGiuhtvVZQQFNI cXYkYdhNqZPunYcUrr1cT8gTDBsmL2ywlvHcMQmmBvUR6mxF7w2APMQEfs0rwUxLJCM/ lW6dRRwkEQudpMyTZcppYjvKPutMyq5CtEL1g7VXgkIKuWmUT0jgcY/KSGXtk5b1rKAc oO3BNiwrH9ylsozw9d9yorFFQMY4G7yVOvHWtC9Y9N/eBX3BCAB71HTj84ADTbI6TdHc WSmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v8peECqP; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jg19si7151815ejc.365.2020.12.20.01.34.58; Sun, 20 Dec 2020 01:34:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v8peECqP; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727534AbgLTJeb (ORCPT + 15 others); Sun, 20 Dec 2020 04:34:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727514AbgLTJea (ORCPT ); Sun, 20 Dec 2020 04:34:30 -0500 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ABD5C0611BB for ; Sun, 20 Dec 2020 01:32:58 -0800 (PST) Received: by mail-ed1-x531.google.com with SMTP id g24so6746650edw.9 for ; Sun, 20 Dec 2020 01:32:58 -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=FN/bEnipr2y9sCYb7N5bkHhgN7bbMj0oywhCqcGevOA=; b=v8peECqPJNg/N1Yfh3YW+bJ2bILnI7awKKkhkrReWPnl/5fCBwvh+TNnZL67PVh4Kn XSAEFs4KQysDNHgmyqYGHyUw9GcCBRNi1aPsjDTCeVlZATkgeAjb+lT79oiyCzXQ/9cR xscBUogVFwPiyRmtTZVALTDMzdaDCcOASaVV16cYXs0Sev/lOcwrihNeYZz0iM6rlqMv bQdRfPQBffPJG8gSggx//jcGxC7PYp65g0iXUT5Uf6/wINmN4ZbWmA3a4eXu+qPI8nbT DfY0pWzvnr0zzb05kzuox4X9DfH5M7uCS7OBQf3tn+Sn1PPAhi/TBPLK/G0bft3s7/JR rdjQ== 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=FN/bEnipr2y9sCYb7N5bkHhgN7bbMj0oywhCqcGevOA=; b=F1HGGxfCVMk9DrS2mtW3ifNybaP6RH5KiCNbjMN0e9PfQ/vUb6+pfjhF8j/xf3hCgB +4640qYvtimkU7Lu6t0LQzSav3T5BnqwesIyH5g9ekcsQU7skoj77t2ZmPgnLqoOa4TX yH6pQQJZy1UjRR4es+TSS+YH8sPMuakraV2YcbDq+Xpoc+B26u581v9xOupa6ILiyZaf ICeqWJGv4TX5U/wJW1yatwVmfedNGD7C5qrYGavcTSXfV/m2oU2T3QqlQOzUizxbuNfD yaAE1ZWHzewj280dxwofWojHjVnE9zVI4soRH5y5wsu7NuzbffYHg+qBCZRFAeZpUVrP k46g== X-Gm-Message-State: AOAM530kyghz2AEF73qp7iroHenKCPzTx6OckOSDSKP5E6DIeYRS8xWc CtV1+H2TqQrdBSYUoeqanEuOWQ== X-Received: by 2002:a05:6402:2292:: with SMTP id cw18mr11885156edb.336.1608456777231; Sun, 20 Dec 2020 01:32:57 -0800 (PST) Received: from localhost.localdomain (hst-221-118.medicom.bg. [84.238.221.118]) by smtp.gmail.com with ESMTPSA id z12sm7769814ejr.17.2020.12.20.01.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Dec 2020 01:32:56 -0800 (PST) From: Stanimir Varbanov To: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vgarodia@codeaurora.org, acourbot@chromium.org, Fritz Koenig , Stanimir Varbanov Subject: [PATCH v2 5/5] venus: vdec: Handle DRC after drain Date: Sun, 20 Dec 2020 11:31:30 +0200 Message-Id: <20201220093130.10177-6-stanimir.varbanov@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201220093130.10177-1-stanimir.varbanov@linaro.org> References: <20201220093130.10177-1-stanimir.varbanov@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Fritz Koenig If the DRC is near the end of the stream the client may send a V4L2_DEC_CMD_STOP before the DRC occurs. V4L2_DEC_CMD_STOP puts the driver into the VENUS_DEC_STATE_DRAIN state. DRC must be aware so that after the DRC event the state can be restored correctly. Signed-off-by: Fritz Koenig Signed-off-by: Stanimir Varbanov --- Changes since v2 (from Fritz): - moved state transition from vdec_event_notify to vdec_event_change. drivers/media/platform/qcom/venus/core.h | 1 + drivers/media/platform/qcom/venus/vdec.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/media/platform/qcom/venus/core.h b/drivers/media/platform/qcom/venus/core.h index db0e6738281e..765ab7ed881b 100644 --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -413,6 +413,7 @@ struct venus_inst { unsigned int core_acquired: 1; unsigned int bit_depth; bool next_buf_last; + bool drain_active; }; #define IS_V1(core) ((core)->res->hfi_version == HFI_VERSION_1XX) diff --git a/drivers/media/platform/qcom/venus/vdec.c b/drivers/media/platform/qcom/venus/vdec.c index d27f4fd0ca01..6cc35ffe2d6e 100644 --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -519,8 +519,10 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) ret = hfi_session_process_buf(inst, &fdata); - if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING) + if (!ret && inst->codec_state == VENUS_DEC_STATE_DECODING) { inst->codec_state = VENUS_DEC_STATE_DRAIN; + inst->drain_active = true; + } } unlock: @@ -969,9 +971,13 @@ static int vdec_start_capture(struct venus_inst *inst) inst->codec_state = VENUS_DEC_STATE_DECODING; + if (inst->drain_active) + inst->codec_state = VENUS_DEC_STATE_DRAIN; + inst->streamon_cap = 1; inst->sequence_cap = 0; inst->reconfig = false; + inst->drain_active = false; return 0; @@ -1097,6 +1103,7 @@ static int vdec_stop_capture(struct venus_inst *inst) fallthrough; case VENUS_DEC_STATE_DRAIN: inst->codec_state = VENUS_DEC_STATE_STOPPED; + inst->drain_active = false; fallthrough; case VENUS_DEC_STATE_SEEK: vdec_cancel_dst_buffers(inst); @@ -1296,8 +1303,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, v4l2_event_queue_fh(&inst->fh, &ev); - if (inst->codec_state == VENUS_DEC_STATE_DRAIN) + if (inst->codec_state == VENUS_DEC_STATE_DRAIN) { + inst->drain_active = false; inst->codec_state = VENUS_DEC_STATE_STOPPED; + } } if (!bytesused) @@ -1373,6 +1382,7 @@ static void vdec_event_change(struct venus_inst *inst, inst->codec_state = VENUS_DEC_STATE_CAPTURE_SETUP; break; case VENUS_DEC_STATE_DECODING: + case VENUS_DEC_STATE_DRAIN: inst->codec_state = VENUS_DEC_STATE_DRC; break; default: