mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: "Jackson.lee" <jackson.lee@chipsnmedia.com>,
	mchehab@kernel.org,  hverkuil-cisco@xs4all.nl,
	bob.beckett@collabora.com
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	 lafley.kim@chipsnmedia.com, b-brnich@ti.com, hverkuil@xs4all.nl,
	 nas.chung@chipsnmedia.com, stable@vger.kernel.org
Subject: Re: [PATCH v1 5/7] media: chips-media: wave5: Defer job_finish() only when a DEC_PIC was queued
Date: Wed, 15 Jul 2026 22:13:40 -0400	[thread overview]
Message-ID: <0770f5e728a1497eece1458a62b2fd4f88933845.camel@collabora.com> (raw)
In-Reply-To: <20260626012232.111-6-jackson.lee@chipsnmedia.com>

[-- Attachment #1: Type: text/plain, Size: 3262 bytes --]

Le vendredi 26 juin 2026 à 10:22 +0900, Jackson.lee a écrit :
> From: Jackson Lee <jackson.lee@chipsnmedia.com>
> 
> Decoder instances sharing a VPU also share one v4l2_m2m job slot, released
> when the running context calls v4l2_m2m_job_finish(). While draining,
> device_run() defers job_finish() once EOS is sent (sent_eos), expecting a
> later finish_decode() (from a DEC_PIC completion IRQ) to release the slot.
> 
> But the m2m core checks job_ready() only when a job is queued, not when it
> is dispatched. A job queued while draining can run after finish_decode()
> has already moved the instance to STOP and sent EOS. device_run() then runs
> in STOP, issues no DEC_PIC, yet still skips job_finish() - so no IRQ, no
> finish_decode(), and the shared slot is leaked, stalling every instance.
> With several v4l2h264dec instances in parallel, GStreamer hangs at EOS.
> 
> Track whether the run actually queued a DEC_PIC (cmd_issued) and defer
> job_finish() only then. Otherwise finish the job immediately
> 
> Fixes: a176ac5e701f ("media: chips-media: wave5: Improve performance of decoder")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>

Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

> ---
>  .../media/platform/chips-media/wave5/wave5-vpu-dec.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> index 93f7b724d86c..f33c00cb801b 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> @@ -1655,6 +1655,7 @@ static void wave5_vpu_dec_device_run(void *priv)
>  	struct queue_status_info q_status;
>  	u32 fail_res = 0;
>  	int ret = 0;
> +	bool cmd_issued = false;
>  
>  	dev_dbg(inst->dev->dev, "%s: Fill the ring buffer with new bitstream data", __func__);
>  	pm_runtime_resume_and_get(inst->dev->dev);
> @@ -1752,6 +1753,7 @@ static void wave5_vpu_dec_device_run(void *priv)
>  			inst->retry = false;
>  			if (!inst->eos)
>  				inst->queuing_num--;
> +			cmd_issued = true;
>  		}
>  		break;
>  	default:
> @@ -1769,8 +1771,16 @@ static void wave5_vpu_dec_device_run(void *priv)
>  	 * in power and CPU time.
>  	 * If EOS is passed, device_run will not call job_finish no more, it is called
>  	 * only if HW is idle status in order to reduce overhead.
> +	 *
> +	 * Deferring job_finish() is only safe when this run actually queued a
> +	 * DEC_PIC command (cmd_issued): that guarantees a completion IRQ, and
> +	 * thus a later finish_decode(), will release the shared job slot. When
> +	 * device_run() is entered with no command to issue (e.g. a job that was
> +	 * queued while draining but reached the STOP state by the time it ran),
> +	 * no IRQ follows, so finish the job here to avoid leaking the slot and
> +	 * stalling every instance sharing the VPU.
>  	 */
> -	if (!inst->sent_eos)
> +	if (!inst->sent_eos || !cmd_issued)
>  		v4l2_m2m_job_finish(inst->v4l2_m2m_dev, m2m_ctx);
>  }
>  

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-07-16  2:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  1:22 [PATCH v1 0/7] bug fixes Jackson.lee
2026-06-26  1:22 ` [PATCH v1 1/7] media: chips-media: wave5: Guard bit depth check with initial_info_obtained Jackson.lee
2026-07-16  1:56   ` Nicolas Dufresne
2026-06-26  1:22 ` [PATCH v1 2/7] media: chips-media: wave5: Set inst->std during default format initialization Jackson.lee
2026-07-16  1:58   ` Nicolas Dufresne
2026-06-26  1:22 ` [PATCH v1 3/7] media: chips-media: wave5: avoid skipping device_run while VPU has work Jackson.lee
2026-07-16  2:00   ` Nicolas Dufresne
2026-06-26  1:22 ` [PATCH v1 4/7] media: chips-media: wave5: Add timeout while stop_streaming Jackson.lee
2026-07-16  2:08   ` Nicolas Dufresne
2026-06-26  1:22 ` [PATCH v1 5/7] media: chips-media: wave5: Defer job_finish() only when a DEC_PIC was queued Jackson.lee
2026-07-16  2:13   ` Nicolas Dufresne [this message]
2026-06-26  1:22 ` [PATCH v1 6/7] media: chips-media: wave5: Fix pipeline stall when queuing fails Jackson.lee
2026-07-16  2:14   ` Nicolas Dufresne
2026-06-26  1:22 ` [PATCH v1 7/7] media: chips-media: wave5: Resume device before setting EOS flag Jackson.lee
2026-07-16  2:18   ` Nicolas Dufresne
2026-07-16  6:16     ` jackson.lee

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=0770f5e728a1497eece1458a62b2fd4f88933845.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=b-brnich@ti.com \
    --cc=bob.beckett@collabora.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=hverkuil@xs4all.nl \
    --cc=jackson.lee@chipsnmedia.com \
    --cc=lafley.kim@chipsnmedia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nas.chung@chipsnmedia.com \
    --cc=stable@vger.kernel.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