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"	 <mchehab@kernel.org>,
	"hverkuil-cisco@xs4all.nl" <hverkuil-cisco@xs4all.nl>,
	 "bob.beckett@collabora.com"	 <bob.beckett@collabora.com>
Cc: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>,
	 "linux-kernel@vger.kernel.org"	 <linux-kernel@vger.kernel.org>,
	"lafley.kim" <lafley.kim@chipsnmedia.com>,
	 "b-brnich@ti.com"	 <b-brnich@ti.com>,
	"hverkuil@xs4all.nl" <hverkuil@xs4all.nl>,
	Nas Chung	 <nas.chung@chipsnmedia.com>
Subject: Re: [PATCH v3 0/4] Performance improvement of decoder
Date: Thu, 11 Sep 2025 08:23:28 -0400	[thread overview]
Message-ID: <e5f560b2e9edd6115f5c8904e1ca5730eac1c49f.camel@collabora.com> (raw)
In-Reply-To: <SLXP216MB11482E2C69022D56A2DE42CFED09A@SLXP216MB1148.KORP216.PROD.OUTLOOK.COM>

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

Hi Jackson,

Le jeudi 11 septembre 2025 à 02:04 +0000, jackson.lee a écrit :
> Hi Nicolas
> 
> > -----Original Message-----
> > From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
> > Sent: Wednesday, September 10, 2025 9:57 PM
> > 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
> > <lafley.kim@chipsnmedia.com>; b-brnich@ti.com; hverkuil@xs4all.nl; Nas
> > Chung <nas.chung@chipsnmedia.com>
> > Subject: Re: [PATCH v3 0/4] Performance improvement of decoder
> > 
> > Hi Jackson,
> > 
> > Le mercredi 10 septembre 2025 à 06:59 +0000, jackson.lee a écrit :
> > [...]
> > 
> > > I have reproduced the stall problem, I can see it with the latest
> > Gstreamer version.
> > > The root cause is we checked an incorrect return value while flushing,
> > so in spite of not finished flushing, the checking loop if the flushing
> > was finished was exited.
> > > When stop streaming was called and the instance queue count was 1,  the
> > checking function put infinite loop, so the stall problem happened.
> > > 
> > > The below patch should be needed.
> > > 
> > > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > > b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > > index edbe69540ef1..2e0128cd0e4d 100644
> > > --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > > @@ -52,6 +52,7 @@ int wave5_vpu_init_with_bitcode(struct device *dev,
> > > u8 *bitcode, size_t size)
> > >  int wave5_vpu_flush_instance(struct vpu_instance *inst)
> > >  {
> > >         int ret = 0;
> > > +       int mutex_ret = 0;
> > >         int retry = 0;
> > > 
> > >         ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> > > @@ -80,9 +81,9 @@ int wave5_vpu_flush_instance(struct vpu_instance
> > > *inst)
> > > 
> > >                         mutex_unlock(&inst->dev->hw_lock);
> > >                         wave5_vpu_dec_get_output_info(inst,
> > > &dec_info);
> > > -                       ret =
> > > mutex_lock_interruptible(&inst->dev->hw_lock);
> > > -                       if (ret)
> > > -                               return ret;
> > > +                       mutex_ret =
> > > +mutex_lock_interruptible(&inst->dev->hw_lock);
> > > +                       if (mutex_ret)
> > > +                               return mutex_ret;
> > >                         if (dec_info.index_frame_display > 0)
> > >                                 wave5_vpu_dec_set_disp_flag(inst,
> > > dec_info.index_frame_display);
> > >                 }
> > 
> > Good catch, unfortunately it does not completely fix the problem for me.
> > You can find a the end of this message the patch I actually tested. Note
> > I ,ove the mutex_ret in a close scope, and fixed other occurence of this
> > pattern, except one that I highlighted to you with a FIXME.
> > 
> > Some new information, I had this trace from GStreamer when the bug occured
> > on forward seeks (very rare):
> 
> " gst-play-1.0 --audiosink=fakesink --videosink=fakevideosink long-drc.h264"
> 
> When the above command is executed, to do forward seeks, I can use "shift key + '+'key " this key combination?

Note that I saw your next message stating you have managed to reproduce, this is
great.

The +/- changes the playback speed, if you did not enable instant rate changes,
this will effectively cause a seek, so its quite likely you can reproduce with
that way too.

What I was using is left/right arrows. I would just seek forward (right arrow)
close to the end, and then press and hold the left arrow till it reaches
position 0. Rince and repeat.

regards,
Nicolas

> 
> Thanks
> Jackson
> 
> > 
> > ** (gst-play-1.0:604): WARNING **: 00:03:59.965: v4l2h264dec0: Too old
> > frames, bug in decoder -- please file a bug
> > 
> > [root@jacinto nicolas]# echo w > /proc/sysrq-trigger [  335.116289] sysrq:
> > Show Blocked State
> > [  335.120054] task:typefind:sink   state:D stack:0     pid:607   tgid:604
> > ppid:543    task_flags:0x40044c flags:0x00000019
> > [  335.131147] Call trace:
> > [  335.133584]  __switch_to+0xf0/0x1c0 (T) [  335.137442]
> > __schedule+0x35c/0x9bc [  335.140935]  schedule+0x34/0x110 [  335.144162]
> > schedule_timeout+0x80/0x104 [  335.148081]
> > wait_for_completion_timeout+0x74/0x158
> > [  335.152955]  wave5_vpu_wait_interrupt+0x28/0x60 [wave5] [  335.158252]
> > wave5_vpu_dec_stop_streaming+0x68/0x28c [wave5] [  335.163915]
> > __vb2_queue_cancel+0x2c/0x2d4 [videobuf2_common] [  335.169668]
> > vb2_core_queue_release+0x20/0x74 [videobuf2_common] [  335.175678]
> > vb2_queue_release+0x10/0x1c [videobuf2_v4l2] [  335.181081]
> > v4l2_m2m_ctx_release+0x20/0x40 [v4l2_mem2mem] [  335.186567]
> > wave5_vpu_release_device+0x44/0x150 [wave5] [  335.191879]
> > wave5_vpu_dec_release+0x20/0x2c [wave5] [  335.196841]
> > v4l2_release+0xb4/0xf0 [videodev] [  335.201709]  __fput+0xd0/0x2e0
> > [  335.205090]  ____fput+0x14/0x20 [  335.208468]  task_work_run+0x64/0xd4
> > [  335.212164]  do_exit+0x240/0x8e0 [  335.215552]  do_group_exit+0x30/0xa4
> > [  335.219177]  get_signal+0x790/0x860 [  335.222676]  do_signal+0x94/0x394
> > [  335.225986]  do_notify_resume+0xd0/0x14c [  335.229910]
> > el0_svc+0xe4/0xe8 [  335.232967]  el0t_64_sync_handler+0xa0/0xe4
> > [  335.237154]  el0t_64_sync+0x198/0x19c
> > 
> > regards,
> > Nicolas
> > 
> > ---
> > 
> > diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > index edbe69540ef1e..2faca2eee41fe 100644
> > --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > @@ -77,12 +77,13 @@ int wave5_vpu_flush_instance(struct vpu_instance *inst)
> >                         return -ETIMEDOUT;
> >                 } else if (ret == -EBUSY) {
> >                         struct dec_output_info dec_info;
> > +                       int ret_mutex;
> > 
> >                         mutex_unlock(&inst->dev->hw_lock);
> >                         wave5_vpu_dec_get_output_info(inst, &dec_info);
> > -                       ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> > -                       if (ret)
> > -                               return ret;
> > +                       ret_mutex = mutex_lock_interruptible(&inst->dev-
> > > hw_lock);
> > +                       if (ret_mutex)
> > +                               return ret_mutex;
> >                         if (dec_info.index_frame_display > 0)
> >                                 wave5_vpu_dec_set_disp_flag(inst,
> > dec_info.index_frame_display);
> >                 }
> > @@ -222,6 +223,8 @@ int wave5_vpu_dec_close(struct vpu_instance *inst, u32
> > *fail_res)
> >         }
> > 
> >         do {
> > +               int ret_mutex;
> > +
> >                 ret = wave5_vpu_dec_finish_seq(inst, fail_res);
> >                 if (ret < 0 && *fail_res != WAVE5_SYSERR_VPU_STILL_RUNNING) {
> >                         dev_warn(inst->dev->dev, "dec_finish_seq timed out\n");
> > @@ -243,10 +246,10 @@ int wave5_vpu_dec_close(struct vpu_instance *inst,
> > u32 *fail_res)
> > 
> >                 mutex_unlock(&vpu_dev->hw_lock);
> >                 wave5_vpu_dec_get_output_info(inst, &dec_info);
> > -               ret = mutex_lock_interruptible(&vpu_dev->hw_lock);
> > -               if (ret) {
> > +               ret_mutex = mutex_lock_interruptible(&vpu_dev->hw_lock);
> > +               if (ret_mutex) {
> >                         pm_runtime_put_sync(inst->dev->dev);
> > -                       return ret;
> > +                       return ret_mutex;
> >                 }
> >         } while (ret != 0);
> > 
> > @@ -482,6 +485,7 @@ dma_addr_t wave5_vpu_dec_get_rd_ptr(struct
> > vpu_instance *inst)
> > 
> >         ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> >         if (ret)
> > +               // FIXME this return type is wrong
> >                 return ret;
> > 
> >         rd_ptr = wave5_dec_get_rd_ptr(inst);
> > nicolas@whitebuilder:~/Sources/TI/jacinto/linux$ git diff diff --git
> > a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > index edbe69540ef1e..2faca2eee41fe 100644
> > --- a/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > +++ b/drivers/media/platform/chips-media/wave5/wave5-vpuapi.c
> > @@ -77,12 +77,13 @@ int wave5_vpu_flush_instance(struct vpu_instance *inst)
> >                         return -ETIMEDOUT;
> >                 } else if (ret == -EBUSY) {
> >                         struct dec_output_info dec_info;
> > +                       int ret_mutex;
> > 
> >                         mutex_unlock(&inst->dev->hw_lock);
> >                         wave5_vpu_dec_get_output_info(inst, &dec_info);
> > -                       ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> > -                       if (ret)
> > -                               return ret;
> > +                       ret_mutex = mutex_lock_interruptible(&inst->dev-
> > > hw_lock);
> > +                       if (ret_mutex)
> > +                               return ret_mutex;
> >                         if (dec_info.index_frame_display > 0)
> >                                 wave5_vpu_dec_set_disp_flag(inst,
> > dec_info.index_frame_display);
> >                 }
> > @@ -222,6 +223,8 @@ int wave5_vpu_dec_close(struct vpu_instance *inst, u32
> > *fail_res)
> >         }
> > 
> >         do {
> > +               int ret_mutex;
> > +
> >                 ret = wave5_vpu_dec_finish_seq(inst, fail_res);
> >                 if (ret < 0 && *fail_res != WAVE5_SYSERR_VPU_STILL_RUNNING) {
> >                         dev_warn(inst->dev->dev, "dec_finish_seq timed out\n");
> > @@ -243,10 +246,10 @@ int wave5_vpu_dec_close(struct vpu_instance *inst,
> > u32 *fail_res)
> > 
> >                 mutex_unlock(&vpu_dev->hw_lock);
> >                 wave5_vpu_dec_get_output_info(inst, &dec_info);
> > -               ret = mutex_lock_interruptible(&vpu_dev->hw_lock);
> > -               if (ret) {
> > +               ret_mutex = mutex_lock_interruptible(&vpu_dev->hw_lock);
> > +               if (ret_mutex) {
> >                         pm_runtime_put_sync(inst->dev->dev);
> > -                       return ret;
> > +                       return ret_mutex;
> >                 }
> >         } while (ret != 0);
> > 
> > @@ -482,6 +485,7 @@ dma_addr_t wave5_vpu_dec_get_rd_ptr(struct
> > vpu_instance *inst)
> > 
> >         ret = mutex_lock_interruptible(&inst->dev->hw_lock);
> >         if (ret)
> > +               // FIXME this return type is wrong
> >                 return ret;
> > 
> >         rd_ptr = wave5_dec_get_rd_ptr(inst);

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

  reply	other threads:[~2025-09-11 12:23 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-23  0:21 Jackson.lee
2025-06-23  0:21 ` [PATCH v3 1/4] media: chips-media: wave5: Fix SError of kernel panic when closed Jackson.lee
2025-08-29 18:03   ` Nicolas Dufresne
2025-06-23  0:21 ` [PATCH v3 2/4] media: chips-media: wave5: Fix Null reference while testing fluster Jackson.lee
2025-08-29 18:13   ` Nicolas Dufresne
2025-09-09  3:43     ` jackson.lee
2025-06-23  0:21 ` [PATCH v3 3/4] media: chips-media: wave5: Add WARN_ON to check if dec_output_info is NULL Jackson.lee
2025-08-29 18:15   ` Nicolas Dufresne
2025-09-09  3:45     ` jackson.lee
2025-06-23  0:21 ` [PATCH v3 4/4] media: chips-media: wave5: Improve performance of decoder Jackson.lee
2025-08-29 18:01   ` Nicolas Dufresne
2025-09-09  1:42     ` jackson.lee
2025-09-16 11:21   ` Markus Elfring
2025-07-07  0:37 ` [PATCH v3 0/4] Performance improvement " jackson.lee
2025-08-12  7:51   ` jackson.lee
2025-08-29 15:40 ` Nicolas Dufresne
2025-09-09  6:16   ` jackson.lee
2025-09-09 21:33     ` Nicolas Dufresne
2025-09-10  6:59       ` jackson.lee
2025-09-10 12:56         ` Nicolas Dufresne
2025-09-11  2:04           ` jackson.lee
2025-09-11 12:23             ` Nicolas Dufresne [this message]
2025-09-11  4:40           ` jackson.lee
2025-09-15  7:33           ` jackson.lee
2025-09-15 20:14             ` Nicolas Dufresne
2025-09-16  0:40               ` 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=e5f560b2e9edd6115f5c8904e1ca5730eac1c49f.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 \
    /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

all inboxes | Powered by JetHome®