linux-media.vger.kernel.org archive mirror
 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,
	sebastian.fricke@collabora.com,  bob.beckett@collabora.com,
	dafna.hirschfeld@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
Subject: Re: [PATCH v2 6/7] media: chips-media: wave5: Reduce high CPU load
Date: Fri, 23 May 2025 13:43:19 -0400	[thread overview]
Message-ID: <f94e84af0a6ea09fd111f5a1ec9b0fadc9f6d4de.camel@collabora.com> (raw)
In-Reply-To: <20250522072606.51-7-jackson.lee@chipsnmedia.com>

Hi,

Le jeudi 22 mai 2025 à 16:26 +0900, Jackson.lee a écrit :
> From: Jackson Lee <jackson.lee@chipsnmedia.com>
> 
> Since applying changes for performance improvement of decoder,
> there was a problem related to high CPU load.
> CPU load was more than 4 times when comparing CPU load.
> The root cause was the device_run was called many times even if
> there was no bitstream which should be queued.

You should squash this.

Nicolas

> 
> Signed-off-by: Jackson Lee <jackson.lee@chipsnmedia.com>
> Signed-off-by: Nas Chung <nas.chung@chipsnmedia.com>
> ---
>  .../media/platform/chips-media/wave5/wave5-vpu-dec.c | 12 +++++++++---
>  .../media/platform/chips-media/wave5/wave5-vpuapi.h  |  1 +
>  2 files changed, 10 insertions(+), 3 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 719c5527eb7f..421a9e1a6f15 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c
> @@ -1280,10 +1280,13 @@ static void wave5_vpu_dec_buf_queue(struct vb2_buffer *vb)
>  		__func__, vb->type, vb->index, vb2_plane_size(&vbuf->vb2_buf, 0),
>  		vb2_plane_size(&vbuf->vb2_buf, 1), vb2_plane_size(&vbuf->vb2_buf, 2));
>  
> -	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)
> +	if (vb->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
> +		if (inst->empty_queue)
> +			inst->empty_queue = false;
>  		wave5_vpu_dec_buf_queue_src(vb);
> -	else if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
> +	} else if (vb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
>  		wave5_vpu_dec_buf_queue_dst(vb);
> +	}
>  }
>  
>  static int wave5_vpu_dec_allocate_ring_buffer(struct vpu_instance *inst)
> @@ -1474,6 +1477,7 @@ static void wave5_vpu_dec_stop_streaming(struct vb2_queue *q)
>  
>  	dev_dbg(inst->dev->dev, "%s: type: %u\n", __func__, q->type);
>  	pm_runtime_resume_and_get(inst->dev->dev);
> +	inst->empty_queue = false;
>  
>  	while (check_cmd) {
>  		struct queue_status_info q_status;
> @@ -1592,6 +1596,7 @@ static void wave5_vpu_dec_device_run(void *priv)
>  				inst->queuing_num == 0 &&
>  				inst->state == VPU_INST_STATE_PIC_RUN) {
>  			dev_dbg(inst->dev->dev, "%s: no bitstream for feeding, so skip ", __func__);
> +			inst->empty_queue = true;
>  			goto finish_job_and_return;
>  		}
>  	}
> @@ -1737,7 +1742,8 @@ static int wave5_vpu_dec_job_ready(void *priv)
>  				"No capture buffer ready to decode!\n");
>  			break;
>  		} else if (!wave5_is_draining_or_eos(inst) &&
> -			   !v4l2_m2m_num_src_bufs_ready(m2m_ctx)) {
> +			   (!v4l2_m2m_num_src_bufs_ready(m2m_ctx) ||
> +			    inst->empty_queue)) {
>  			dev_dbg(inst->dev->dev,
>  				"No bitstream data to decode!\n");
>  			break;
> diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h b/drivers/media/platform/chips-media/wave5/wave5-
> vpuapi.h
> index fd0aef0bac4e..f2596af08cdf 100644
> --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h
> +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.h
> @@ -821,6 +821,7 @@ struct vpu_instance {
>  	bool retry; /* retry to feed bitstream if failure reason is WAVE5_SYSERR_QUEUEING_FAIL*/
>  	int queuing_num; /* check if there is input buffer or not */
>  	struct mutex feed_lock; /* lock for feeding bitstream buffers */
> +	bool empty_queue;
>  	struct vpu_buf bitstream_vbuf;
>  	dma_addr_t last_rd_ptr;
>  	size_t remaining_consumed_bytes;

  reply	other threads:[~2025-05-23 17:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22  7:25 [PATCH v2 0/7] Performance improvement of decoder Jackson.lee
2025-05-22  7:26 ` [PATCH v2 1/7] media: chips-media: wave5: Fix Null reference while testing fluster Jackson.lee
2025-05-23 17:20   ` Nicolas Dufresne
2025-05-27  4:05     ` jackson.lee
2025-05-27 12:57       ` Nicolas Dufresne
2025-05-22  7:26 ` [PATCH v2 2/7] media: chips-media: wave5: Improve performance of decoder Jackson.lee
2025-05-23 17:39   ` Nicolas Dufresne
2025-05-27  4:58     ` jackson.lee
2025-05-28 13:46       ` Nicolas Dufresne
2025-06-04  4:09         ` jackson.lee
2025-06-04 13:47           ` Nicolas Dufresne
2025-06-05  4:50             ` jackson.lee
2025-06-05 13:28               ` Nicolas Dufresne
2025-06-09  8:47                 ` jackson.lee
2025-05-30 14:33       ` Nicolas Dufresne
2025-05-22  7:26 ` [PATCH v2 3/7] media: chips-media: wave5: Fix not to be closed Jackson.lee
2025-05-22  7:26 ` [PATCH v2 4/7] media: chips-media: wave5: Use spinlock whenever statue is changed Jackson.lee
2025-05-23 17:41   ` Nicolas Dufresne
2025-05-27  5:02     ` jackson.lee
2025-05-28 13:49       ` Nicolas Dufresne
2025-05-22  7:26 ` [PATCH v2 5/7] media: chips-media: wave5: Fix not to free resources normally when instance was destroyed Jackson.lee
2025-05-23 17:42   ` Nicolas Dufresne
2025-05-27  5:04     ` jackson.lee
2025-05-22  7:26 ` [PATCH v2 6/7] media: chips-media: wave5: Reduce high CPU load Jackson.lee
2025-05-23 17:43   ` Nicolas Dufresne [this message]
2025-05-27  5:05     ` jackson.lee
2025-05-22  7:26 ` [PATCH v2 7/7] media: chips-media: wave5: Fix SError of kernel panic when closed Jackson.lee
2025-05-23 17:48   ` Nicolas Dufresne
2025-05-27  5:07     ` 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=f94e84af0a6ea09fd111f5a1ec9b0fadc9f6d4de.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=b-brnich@ti.com \
    --cc=bob.beckett@collabora.com \
    --cc=dafna.hirschfeld@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=sebastian.fricke@collabora.com \
    /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;
as well as URLs for NNTP newsgroup(s).