UPSTREAM: usb: gadget: uvc: increase worker prio to WQ_HIGHPRI

This patch is changing the simple workqueue in the gadget driver to be
allocated as async_wq with a higher priority. The pump worker, that is
filling the usb requests, will have a higher priority and will not be
scheduled away so often while the video stream is handled. This will
lead to fewer streaming underruns.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20220907215818.2670097-1-m.grzeschik@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit 9b91a65230)
Change-Id: I3a70591f53a4040c50d723784f5e520cf2d53d99
This commit is contained in:
Michael Grzeschik
2022-09-07 23:58:18 +02:00
committed by Tao Huang
parent 3afe252aa9
commit de7ec95b44
4 changed files with 13 additions and 3 deletions
+4
View File
@@ -1199,10 +1199,14 @@ static void uvc_function_unbind(struct usb_configuration *c,
{
struct usb_composite_dev *cdev = c->cdev;
struct uvc_device *uvc = to_uvc(f);
struct uvc_video *video = &uvc->video;
long wait_ret = 1;
uvcg_info(f, "%s()\n", __func__);
if (video->async_wq)
destroy_workqueue(video->async_wq);
/* If we know we're connected via v4l2, then there should be a cleanup
* of the device from userspace either via UVC_EVENT_DISCONNECT or
* though the video device removal uevent. Allow some time for the
+1
View File
@@ -87,6 +87,7 @@ struct uvc_video {
struct usb_ep *ep;
struct work_struct pump;
struct workqueue_struct *async_wq;
/* Frame parameters */
u8 bpp;
+1 -1
View File
@@ -174,7 +174,7 @@ uvc_v4l2_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
return ret;
if (uvc->state == UVC_STATE_STREAMING)
schedule_work(&video->pump);
queue_work(video->async_wq, &video->pump);
return ret;
}
+7 -2
View File
@@ -249,7 +249,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
spin_unlock_irqrestore(&video->req_lock, flags);
if (uvc->state == UVC_STATE_STREAMING)
schedule_work(&video->pump);
queue_work(video->async_wq, &video->pump);
}
static int
@@ -446,7 +446,7 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
} else
video->encode = uvc_video_encode_isoc;
schedule_work(&video->pump);
queue_work(video->async_wq, &video->pump);
return ret;
}
@@ -460,6 +460,11 @@ int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc)
spin_lock_init(&video->req_lock);
INIT_WORK(&video->pump, uvcg_video_pump);
/* Allocate a work queue for asynchronous video pump handler. */
video->async_wq = alloc_workqueue("uvcgadget", WQ_UNBOUND | WQ_HIGHPRI, 0);
if (!video->async_wq)
return -EINVAL;
video->uvc = uvc;
video->fcc = V4L2_PIX_FMT_YUYV;
video->bpp = 16;