diff mbox series

[RESEND] usb: gadget: uvc: queue pump work in uvcg_video_enable()

Message ID 20240814112537.2608949-1-xu.yang_2@nxp.com
State New
Headers show
Series [RESEND] usb: gadget: uvc: queue pump work in uvcg_video_enable() | expand

Commit Message

Xu Yang Aug. 14, 2024, 11:25 a.m. UTC
Since commit "6acba0345b68 usb:gadget:uvc Do not use worker thread to pump
isoc usb requests", pump work could only be queued in uvc_video_complete()
and uvc_v4l2_qbuf(). If VIDIOC_QBUF is executed before VIDIOC_STREAMON,
we can only depend on uvc_video_complete() to queue pump work. However,
this requires some free requests in req_ready list. If req_ready list is
empty all the time, pump work will never be queued and video datas will
never be pumped to usb controller. Actually, this situation could happen
when run uvc-gadget with static image:

$ ./uvc-gadget -i 1080p.jpg uvc.0

When capture image from this device, the user app will always block there.

The issue is uvc driver has queued video buffer before streamon, but the
req_ready list is empty all the time after streamon. This will queue pump
work in uvcg_video_enable() to fill some request to req_ready list so the
uvc device could work properly.

Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
Cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
 drivers/usb/gadget/function/uvc_video.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Greg Kroah-Hartman Aug. 14, 2024, 11:47 a.m. UTC | #1
On Wed, Aug 14, 2024 at 07:25:37PM +0800, Xu Yang wrote:
> Since commit "6acba0345b68 usb:gadget:uvc Do not use worker thread to pump
> isoc usb requests", pump work could only be queued in uvc_video_complete()
> and uvc_v4l2_qbuf(). If VIDIOC_QBUF is executed before VIDIOC_STREAMON,
> we can only depend on uvc_video_complete() to queue pump work. However,
> this requires some free requests in req_ready list. If req_ready list is
> empty all the time, pump work will never be queued and video datas will
> never be pumped to usb controller. Actually, this situation could happen
> when run uvc-gadget with static image:
> 
> $ ./uvc-gadget -i 1080p.jpg uvc.0
> 
> When capture image from this device, the user app will always block there.
> 
> The issue is uvc driver has queued video buffer before streamon, but the
> req_ready list is empty all the time after streamon. This will queue pump
> work in uvcg_video_enable() to fill some request to req_ready list so the
> uvc device could work properly.
> 
> Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> ---
>  drivers/usb/gadget/function/uvc_video.c | 1 +
>  1 file changed, 1 insertion(+)

Why is this a RESEND?  What happened to the first one to require this?

thanks,

greg k-h
Greg Kroah-Hartman Aug. 14, 2024, 2:10 p.m. UTC | #2
On Wed, Aug 14, 2024 at 09:48:02PM +0800, Xu Yang wrote:
> On Wed, Aug 14, 2024 at 01:47:23PM +0200, Greg KH wrote:
> > On Wed, Aug 14, 2024 at 07:25:37PM +0800, Xu Yang wrote:
> > > Since commit "6acba0345b68 usb:gadget:uvc Do not use worker thread to pump
> > > isoc usb requests", pump work could only be queued in uvc_video_complete()
> > > and uvc_v4l2_qbuf(). If VIDIOC_QBUF is executed before VIDIOC_STREAMON,
> > > we can only depend on uvc_video_complete() to queue pump work. However,
> > > this requires some free requests in req_ready list. If req_ready list is
> > > empty all the time, pump work will never be queued and video datas will
> > > never be pumped to usb controller. Actually, this situation could happen
> > > when run uvc-gadget with static image:
> > > 
> > > $ ./uvc-gadget -i 1080p.jpg uvc.0
> > > 
> > > When capture image from this device, the user app will always block there.
> > > 
> > > The issue is uvc driver has queued video buffer before streamon, but the
> > > req_ready list is empty all the time after streamon. This will queue pump
> > > work in uvcg_video_enable() to fill some request to req_ready list so the
> > > uvc device could work properly.
> > > 
> > > Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > > ---
> > >  drivers/usb/gadget/function/uvc_video.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > 
> > Why is this a RESEND?  What happened to the first one to require this?
> 
> I accidentally forgot to cc usb maillist in previous one. So I resend it.

Please always tell us why you are doing something, otherwise we have no
idea :(
Xu Yang Aug. 15, 2024, 2:02 a.m. UTC | #3
On Wed, Aug 14, 2024 at 04:10:53PM +0200, Greg KH wrote:
> On Wed, Aug 14, 2024 at 09:48:02PM +0800, Xu Yang wrote:
> > On Wed, Aug 14, 2024 at 01:47:23PM +0200, Greg KH wrote:
> > > On Wed, Aug 14, 2024 at 07:25:37PM +0800, Xu Yang wrote:
> > > > Since commit "6acba0345b68 usb:gadget:uvc Do not use worker thread to pump
> > > > isoc usb requests", pump work could only be queued in uvc_video_complete()
> > > > and uvc_v4l2_qbuf(). If VIDIOC_QBUF is executed before VIDIOC_STREAMON,
> > > > we can only depend on uvc_video_complete() to queue pump work. However,
> > > > this requires some free requests in req_ready list. If req_ready list is
> > > > empty all the time, pump work will never be queued and video datas will
> > > > never be pumped to usb controller. Actually, this situation could happen
> > > > when run uvc-gadget with static image:
> > > > 
> > > > $ ./uvc-gadget -i 1080p.jpg uvc.0
> > > > 
> > > > When capture image from this device, the user app will always block there.
> > > > 
> > > > The issue is uvc driver has queued video buffer before streamon, but the
> > > > req_ready list is empty all the time after streamon. This will queue pump
> > > > work in uvcg_video_enable() to fill some request to req_ready list so the
> > > > uvc device could work properly.
> > > > 
> > > > Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests")
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> > > > ---
> > > >  drivers/usb/gadget/function/uvc_video.c | 1 +
> > > >  1 file changed, 1 insertion(+)
> > > 
> > > Why is this a RESEND?  What happened to the first one to require this?
> > 
> > I accidentally forgot to cc usb maillist in previous one. So I resend it.
> 
> Please always tell us why you are doing something, otherwise we have no
> idea :(

Okay, understand.

Thanks,
Xu Yang
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index d41f5f31dadd..a9edd60fbbf7 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -753,6 +753,7 @@  int uvcg_video_enable(struct uvc_video *video)
 	video->req_int_count = 0;
 
 	uvc_video_ep_queue_initial_requests(video);
+	queue_work(video->async_wq, &video->pump);
 
 	return ret;
 }