Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3404121pxu; Sun, 20 Dec 2020 01:35:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyC34CYNpaHov4k2ekwXbWt62MS1pf8T6o7Yr18b21JpcAPg40tBH+OVHcnqNzK85pBHQiA X-Received: by 2002:a05:6402:1383:: with SMTP id b3mr11582462edv.100.1608456941858; Sun, 20 Dec 2020 01:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608456941; cv=none; d=google.com; s=arc-20160816; b=p5BL2EtZxrkbFENVbPbZLfEjV0k4XPh9ybYzKDqdd68xR8hTGY9J2GqR9AocBX/0BU cyY2UMHJmgjOo29bzfWcJ967wlzPVJLRv3Npfy52k3TvRnA0jpppqYoUabwxREkTtrpz 5VreLpAzYhsMvu4+HearY/pEk6La+x+QsxuYViB2vrHSbhjSGs1v9BzsuD/i8kfge6z/ YWnFEbs2k2mxEChwJgaZzd7PMSapy3Z3PU/r/Vk70k9k6hYTxVlxZC87G2PI2Y9M4Ct2 l2R6Qj+0NhAz5SvLKbMNWW4GW2caJsH/07YwdhNubINxGjvDqsQLnzy5ukuZQqz94jO7 1axA== 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=rAo2fXa8Elw/K/5ZhyKWx1mIcN2LFjjrqhXfC+sFR5mZA6HzBRM83zabfNoK7gbFbr F6WUOblSOLs/cwWUm83ThrN3N7oMD1D/uWF7Dk3DLbVQ+hYdYQe7/rEBpqkSPIPdXM23 +oDj/UgzTCDDNz7Ng3Wy/cy8Gn/mGERccfVXknho+CwlXK7BXg2ZbsPUVKG3jU02QB/X 6ZmXyQSYqczAGT/vKs8sk70mTzREl2msgob0AhS+GK/6PZ1ploUgUkWnwSEoZpEcX+kA Q9qtxA1rSrAmwPMMmxdg1o7Rn4CJnfVAFoWPnpPh1EG3WNJvxJmASHmfHqXZcRpbxVL7 WojA== 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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 o21si9376069edi.210.2020.12.20.01.35.19; Sun, 20 Dec 2020 01:35:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727120AbgLTJdi (ORCPT + 99 others); Sun, 20 Dec 2020 04:33:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727109AbgLTJdd (ORCPT ); Sun, 20 Dec 2020 04:33:33 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF5B2C061285 for ; Sun, 20 Dec 2020 01:32:51 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id r5so6712005eda.12 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=pb+StZUva0BQ474znDmpkLpQ1Nsgxz5+pB0laxuWx7YVz/CFlT2Oo/hG4RZThxe/D5 2geOBb5JMI2jjVDeOXTDjytyZMe/ZdPVdRhQguXX8JE5mOrs35zo2ftGBwHk37pQ6Y6A ltcm1uaZXRCtuQRvpmBKb2jxwJJ+WWpJZc7v0769SqNDwDo3q2ZrhtA72B2OjBul+ums l9dWucqcnbyGlj5qs93Dm5Gg//Ej1/1+/LaDgXfscCqfLSMpUskUbrunpXHllgxHQzV5 jG++Oj1HHZ0wgk5L2Kn5oryZg37ppBBFylsA4z+p1gittB9ln6hnJn7SCc5+WH+valGs pmHg== X-Gm-Message-State: AOAM531xuxjcKaZTFg/3eeU5VJ+JQ1IuZZHUJJoWMlO/td3xf7P74r7C aIRJI3aCACLtJQA27Y/VFWe3KQ== 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-kernel@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(-) 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 = { -- 2.17.1