usb: gadget: uvc: rework to enqueue in pump worker from encoded queue
authorMichael Grzeschik <m.grzeschik@pengutronix.de>
Wed, 16 Oct 2024 13:58:08 +0000 (15:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 06:42:22 +0000 (08:42 +0200)
commitf0bbfbd16b3b67106535299d6a9ca3a5565494a6
treec2d3d0f13a1dcfe8ce8d4bebcb4f0b57415bb311
parentdc97c956a4703de61cfa8ebe6285d5c7274ef8fd
usb: gadget: uvc: rework to enqueue in pump worker from encoded queue

We install an kthread with pfifo priority that is iterating over all
prepared requests and keeps the isoc queue busy. This way it will be
scheduled with the same priority as the interrupt handler.

As the kthread is triggered with video_enable it will immediately
queue some zero length requests into the hw if there is no buffer data
available. It also watches the level of needed zero length requests in
the hardware not to fall under the UVCG_REQ_MAX_ZERO_COUNT threshold.
This way we can drop the function uvc_video_ep_queue_initial_requests
entirely.

By using the kthread to do the actual request handling the interrupt
handler will not be running into the time consuming and eventually
locking work of actually enqueueing the requests back into its own
pipeline. This work can now even be scheduled on another cpu.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Link: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v7-3-e224bb1035f0@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_uvc.c
drivers/usb/gadget/function/uvc.h
drivers/usb/gadget/function/uvc_video.c