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 4/7] media: chips-media: wave5: Add timeout while stop_streaming
Date: Wed, 15 Jul 2026 22:08:27 -0400	[thread overview]
Message-ID: <0c2e1bd0ef223abea99d7b6f1ca0f7fc805fe47f.camel@collabora.com> (raw)
In-Reply-To: <20260626012232.111-5-jackson.lee@chipsnmedia.com>

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

Le vendredi 26 juin 2026 à 10:22 +0900, Jackson.lee a écrit :
> From: Jackson Lee <jackson.lee@chipsnmedia.com>
> 
> When stop_streaming is called, an infinite loop may occur in some cases.
> Add a bounded poll of the queue status: loop until the queues drain,
> sleeping briefly between polls, and bail out once VPU_DEC_STOP_TIMEOUT
> elapses.
> 
> Fixes: 9707a6254a8a ("media: chips-media: wave5: Add the v4l2 layer")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>

This is not the nicest thing to do, but I don't really have a better idea. We'd
need something from the firmware to signal this instead. The code was clearly
prone to spinning and CPU hugging, even if the HW was behaving, so I'll admit
this is an improvement.

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

> ---
>  .../platform/chips-media/wave5/wave5-vpu-dec.c    | 15 +++++++++------
>  .../platform/chips-media/wave5/wave5-vpuconfig.h  |  2 +-
>  2 files changed, 10 insertions(+), 7 deletions(-)
> 
> 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 6c6e86b09b40..93f7b724d86c 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> @@ -5,6 +5,7 @@
>   * Copyright (C) 2021-2023 CHIPS&MEDIA INC
>   */
>  
> +#include <linux/delay.h>
>  #include <linux/pm_runtime.h>
>  #include "wave5-helper.h"
>  
> @@ -1537,15 +1538,15 @@ static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
>  {
>  	struct vpu_instance *inst = vb2_get_drv_priv(q);
>  	struct v4l2_m2m_ctx *m2m_ctx = inst->v4l2_fh.m2m_ctx;
> -
> -	bool check_cmd = TRUE;
> +	unsigned long timeout;
>  
>  	dev_dbg(inst->dev->dev, "%s: type: %u\n", __func__, q->type);
>  	pm_runtime_resume_and_get(inst->dev->dev);
>  	inst->empty_queue = true;
> -	while (check_cmd) {
> +
> +	timeout = jiffies + msecs_to_jiffies(VPU_DEC_STOP_TIMEOUT);
> +	while (true) {
>  		struct queue_status_info q_status;
> -		struct dec_output_info dec_output_info;
>  
>  		wave5_vpu_dec_give_command(inst, DEC_GET_QUEUE_STATUS, &q_status);
>  		if ((inst->state == VPU_INST_STATE_STOP ||
> @@ -1554,8 +1555,10 @@ static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
>  			q_status.report_queue_count == 0)
>  			break;
>  
> -		if (wave5_vpu_dec_get_output_info(inst, &dec_output_info))
> -			dev_dbg(inst->dev->dev, "there is no output info\n");
> +		if (time_after(jiffies, timeout))
> +			break;
> +
> +		usleep_range(1000, 2000);
>  	}
>  
>  	v4l2_m2m_update_stop_streaming_state(m2m_ctx, q);
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h b/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h
> index 4ebd48d5550e..e04f2dbf3b65 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuconfig.h
> @@ -59,7 +59,7 @@
>  //  application specific configuration
>  #define VPU_ENC_TIMEOUT                 60000
>  #define VPU_DEC_TIMEOUT                 60000
> -#define VPU_DEC_STOP_TIMEOUT            10
> +#define VPU_DEC_STOP_TIMEOUT            300
>  
>  // for WAVE encoder
>  #define USE_SRC_PRP_AXI         0

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

  reply	other threads:[~2026-07-16  2:08 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 [this message]
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
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=0c2e1bd0ef223abea99d7b6f1ca0f7fc805fe47f.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

powered by JetHome