Devicetree
 help / color / mirror / Atom feed
From: Vikash Garodia <quic_vgarodia@quicinc.com>
To: Dikshita Agarwal <quic_dikshita@quicinc.com>,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Stefan Schmidt <stefan.schmidt@linaro.org>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>,
	<linux-media@vger.kernel.org>, <linux-arm-msm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<20250417-topic-sm8x50-iris-v10-v7-0-f020cb1d0e98@linaro.org>,
	<20250424-qcs8300_iris-v5-0-f118f505c300@quicinc.com>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH v2 17/23] media: iris: Track flush responses to prevent premature completion
Date: Wed, 30 Apr 2025 16:10:44 +0530	[thread overview]
Message-ID: <578305fc-fe93-2ef4-908a-d728a5ae6485@quicinc.com> (raw)
In-Reply-To: <20250428-qcom-iris-hevc-vp9-v2-17-3a6013ecb8a5@quicinc.com>



On 4/28/2025 2:59 PM, Dikshita Agarwal wrote:
> Currently, two types of flush commands are queued to the firmware,
> the first flush queued as part of sequence change, does not wait for a
> response, while the second flush queued as part of stop, expects a
> completion response before proceeding further.
> 
> Due to timing issue, the flush response corresponding to the first
> command could arrive after the second flush is issued. This casuses the
> driver to incorrectly assume that the second flush has completed,
> leading to the premature signaling of flush_completion.
> 
> To address this, introduce a counter to track the number of pending
> flush responses and signal flush completion only when all expected
> responses are received.
> 
> Cc: stable@vger.kernel.org
> Fixes: 11712ce70f8e ("media: iris: implement vb2 streaming ops")
> Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
> ---
>  .../media/platform/qcom/iris/iris_hfi_gen1_command.c    |  4 +++-
>  .../media/platform/qcom/iris/iris_hfi_gen1_response.c   | 17 +++++++++++------
>  drivers/media/platform/qcom/iris/iris_instance.h        |  2 ++
>  3 files changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> index f9f3e2d2ce29..ef3ca676d2ea 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c
> @@ -208,8 +208,10 @@ static int iris_hfi_gen1_session_stop(struct iris_inst *inst, u32 plane)
>  		flush_pkt.flush_type = flush_type;
>  
>  		ret = iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.size);
> -		if (!ret)
> +		if (!ret) {
> +			inst->flush_responses_pending++;
>  			ret = iris_wait_for_session_response(inst, true);
> +		}
>  	}
>  
>  	return ret;
> diff --git a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
> index dfca45d85759..01338baf3788 100644
> --- a/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
> +++ b/drivers/media/platform/qcom/iris/iris_hfi_gen1_response.c
> @@ -207,7 +207,8 @@ static void iris_hfi_gen1_event_seq_changed(struct iris_inst *inst,
>  		flush_pkt.shdr.hdr.pkt_type = HFI_CMD_SESSION_FLUSH;
>  		flush_pkt.shdr.session_id = inst->session_id;
>  		flush_pkt.flush_type = HFI_FLUSH_OUTPUT;
> -		iris_hfi_queue_cmd_write(inst->core, &flush_pkt, flush_pkt.shdr.hdr.size);
> +		if (!iris_hfi_queue_cmd_write(inst->core, &flush_pkt, flush_pkt.shdr.hdr.size))
> +			inst->flush_responses_pending++;
>  	}
>  
>  	iris_vdec_src_change(inst);
> @@ -408,7 +409,9 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
>  		flush_pkt.shdr.hdr.pkt_type = HFI_CMD_SESSION_FLUSH;
>  		flush_pkt.shdr.session_id = inst->session_id;
>  		flush_pkt.flush_type = HFI_FLUSH_OUTPUT;
> -		iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.size);
> +		if (!iris_hfi_queue_cmd_write(core, &flush_pkt, flush_pkt.shdr.hdr.size))
> +			inst->flush_responses_pending++;
> +
>  		iris_inst_sub_state_change_drain_last(inst);
>  
>  		return;
> @@ -570,7 +573,6 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
>  	const struct iris_hfi_gen1_response_pkt_info *pkt_info;
>  	struct device *dev = core->dev;
>  	struct hfi_session_pkt *pkt;
> -	struct completion *done;
>  	struct iris_inst *inst;
>  	bool found = false;
>  	u32 i;
> @@ -631,9 +633,12 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
>  			if (shdr->error_type != HFI_ERR_NONE)
>  				iris_inst_change_state(inst, IRIS_INST_ERROR);
>  
> -			done = pkt_info->pkt == HFI_MSG_SESSION_FLUSH ?
> -				&inst->flush_completion : &inst->completion;
> -			complete(done);
> +			if (pkt_info->pkt == HFI_MSG_SESSION_FLUSH) {
> +				if (--inst->flush_responses_pending <= 0)
No need to check for < 0 condition as its an unsigned int. Signal when equals 0.

With above change, mark
Reviewed-by: Vikash Garodia <quic_vgarodia@quicinc.com>

> +					complete(&inst->flush_completion);
> +			} else {
> +				complete(&inst->completion);
> +			}
>  		}
>  		mutex_unlock(&inst->lock);
>  
> diff --git a/drivers/media/platform/qcom/iris/iris_instance.h b/drivers/media/platform/qcom/iris/iris_instance.h
> index 5150237f0020..9ed197799ee7 100644
> --- a/drivers/media/platform/qcom/iris/iris_instance.h
> +++ b/drivers/media/platform/qcom/iris/iris_instance.h
> @@ -27,6 +27,7 @@
>   * @crop: structure of crop info
>   * @completion: structure of signal completions
>   * @flush_completion: structure of signal completions for flush cmd
> + * @flush_responses_pending: counter to track number of pending flush responses
>   * @fw_caps: array of supported instance firmware capabilities
>   * @buffers: array of different iris buffers
>   * @fw_min_count: minimnum count of buffers needed by fw
> @@ -59,6 +60,7 @@ struct iris_inst {
>  	struct iris_hfi_rect_desc	crop;
>  	struct completion		completion;
>  	struct completion		flush_completion;
> +	u32				flush_responses_pending;
>  	struct platform_inst_fw_cap	fw_caps[INST_FW_CAP_MAX];
>  	struct iris_buffers		buffers[BUF_TYPE_MAX];
>  	u32				fw_min_count;
> 

  reply	other threads:[~2025-04-30 10:41 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28  9:28 [PATCH v2 00/23] Add support for HEVC and VP9 codecs in decoder Dikshita Agarwal
2025-04-28  9:28 ` [PATCH v2 01/23] media: iris: Skip destroying internal buffer if not dequeued Dikshita Agarwal
2025-04-29  9:24   ` Vikash Garodia
2025-04-29  9:27     ` Vikash Garodia
2025-04-29 11:07     ` Dikshita Agarwal
2025-04-29  9:43   ` Bryan O'Donoghue
2025-04-29 10:58     ` Dikshita Agarwal
2025-04-29 12:47   ` Nicolas Dufresne
2025-04-30  5:38     ` Dikshita Agarwal
2025-04-30  7:22       ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 02/23] media: iris: Update CAPTURE format info based on OUTPUT format Dikshita Agarwal
2025-04-29  9:29   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 03/23] media: iris: Add handling for corrupt and drop frames Dikshita Agarwal
2025-04-29  9:35   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 04/23] media: iris: Avoid updating frame size to firmware during reconfig Dikshita Agarwal
2025-04-29  9:50   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 05/23] media: iris: Send V4L2_BUF_FLAG_ERROR for buffers with 0 filled length Dikshita Agarwal
2025-04-29 10:00   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 06/23] media: iris: Drop port check for session property response Dikshita Agarwal
2025-04-29 10:04   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 07/23] media: iris: Add handling for no show frames Dikshita Agarwal
2025-04-29 10:06   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 08/23] media: iris: Improve last flag handling Dikshita Agarwal
2025-04-29 10:17   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 09/23] media: iris: Skip flush on first sequence change Dikshita Agarwal
2025-04-29 10:19   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 10/23] media: iris: Prevent HFI queue writes when core is in deinit state Dikshita Agarwal
2025-04-29 10:23   ` Vikash Garodia
2025-04-28  9:28 ` [PATCH v2 11/23] media: iris: Remove redundant buffer count check in stream off Dikshita Agarwal
2025-04-29 10:24   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 12/23] media: iris: Remove deprecated property setting to firmware Dikshita Agarwal
2025-04-29 10:26   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 13/23] media: iris: Fix missing function pointer initialization Dikshita Agarwal
2025-04-29 10:30   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 14/23] media: iris: Fix NULL pointer dereference Dikshita Agarwal
2025-04-28  9:40   ` Dan Carpenter
2025-04-28 12:10     ` Dikshita Agarwal
2025-04-28 12:38       ` Dan Carpenter
2025-04-29 10:31   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 15/23] media: iris: Fix typo in depth variable Dikshita Agarwal
2025-04-29 10:32   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 16/23] media: iris: Add a comment to explain usage of MBPS Dikshita Agarwal
2025-04-29 10:34   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 17/23] media: iris: Track flush responses to prevent premature completion Dikshita Agarwal
2025-04-30 10:40   ` Vikash Garodia [this message]
2025-04-28  9:29 ` [PATCH v2 18/23] media: iris: Fix buffer preparation failure during resolution change Dikshita Agarwal
2025-04-29 10:46   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 19/23] media: iris: Add HEVC and VP9 formats for decoder Dikshita Agarwal
2025-04-30 10:29   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 20/23] media: iris: Add platform capabilities for HEVC and VP9 decoders Dikshita Agarwal
2025-04-30 10:30   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 21/23] media: iris: Set mandatory properties " Dikshita Agarwal
2025-04-30 10:32   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 22/23] media: iris: Add internal buffer calculation " Dikshita Agarwal
2025-04-30 10:33   ` Vikash Garodia
2025-04-28  9:29 ` [PATCH v2 23/23] media: iris: Add codec specific check for VP9 decoder drain handling Dikshita Agarwal
2025-04-30 10:35   ` Vikash Garodia
2025-04-28 11:07 ` [PATCH v2 00/23] Add support for HEVC and VP9 codecs in decoder Dmitry Baryshkov
2025-04-28 12:11   ` Dikshita Agarwal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=578305fc-fe93-2ef4-908a-d728a5ae6485@quicinc.com \
    --to=quic_vgarodia@quicinc.com \
    --cc=20250417-topic-sm8x50-iris-v10-v7-0-f020cb1d0e98@linaro.org \
    --cc=20250424-qcs8300_iris-v5-0-f118f505c300@quicinc.com \
    --cc=andersson@kernel.org \
    --cc=bryan.odonoghue@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=hverkuil@xs4all.nl \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_dikshita@quicinc.com \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stefan.schmidt@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox