mbox series

[v6,0/9] usb: gadget: uvc: effectively fill the udc isoc pipeline with available video buffers and fixes

Message ID 20240403-uvc_request_length_by_interval-v6-0-08c05522e1f5@pengutronix.de (mailing list archive)
Headers show
Series usb: gadget: uvc: effectively fill the udc isoc pipeline with available video buffers and fixes | expand

Message

Michael Grzeschik Sept. 29, 2024, 6:59 p.m. UTC
This patch series is improving the size calculation and allocation of
the uvc requests. Using the selected frame duration of the stream it is
possible to calculate the number of requests based on the interval
length.

It also precalculates the request length based on the actual per frame
size for compressed formats.

For this calculations to work it was needed to rework the request
queueing by moving the encoding to one extra thread (in this case we
chose the qbuf) context.

Next it was needed to move the actual request enqueueing to one extra
thread which is kept busy to fill the isoc queue in the udc.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
Changes in v6:
- fixes in: ("usb: gadget: uvc: add trace of enqueued and completed requests")
- Link to v5: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v5-0-2de78794365c@pengutronix.de

Changes in v5:
- dropped: ('usb: gadget: uvc: remove pump worker and enqueue all buffers per frame in qbuf')
- squashed ('usb: gadget: uvc: rework to enqueue in pump worker from encoded queue') and ('usb: gadget: uvc: remove uvc_video_ep_queue_initial_requests'))
- squashed ('usb: gadget: uvc: set req_size once when the vb2 queue is calculated') and ('usb: gadget: uvc: set req_size and n_requests based on the frame interval')
- replaced ('usb: gadget: uvc: add min g_ctrl vidioc and set min buffs to 4') with ('usb: gadget: uvc: set nbuffers to minimum STREAMING_MIN_BUFFERS in uvc_queue_setup')
- added ('usb: gadget: uvc: wake pump everytime we update the free list')
- added ('usb: gadget: uvc: add trace of enqueued and completed requests')
- added ('usb: gadget: uvc: dont call usb_composite_setup_continue when not streamin')
- some patch reordering
- Link to v4: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v4-0-ca22f334226e@pengutronix.de

Changes in v4:
- fixed exit path in uvc_enqueue_buffer on loop break
- Link to v3: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v3-0-4da7033dd488@pengutronix.de

Changes in v3:
- Added more patches necessary to properly rework the request queueing
- Link to v2: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v2-0-12690f7a2eff@pengutronix.de

Changes in v2:
- added header size into calculation of request size
- Link to v1: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v1-0-9436c4716233@pengutronix.de

---
Michael Grzeschik (9):
      usb: gadget: uvc: wake pump everytime we update the free list
      usb: gadget: uvc: only enqueue zero length requests in potential underrun
      usb: gadget: uvc: rework to enqueue in pump worker from encoded queue
      usb: gadget: uvc: add g_parm and s_parm for frame interval
      usb: gadget: uvc: set req_size and n_requests based on the frame interval
      usb: gadget: uvc: set req_length based on payload by nreqs instead of req_size
      usb: gadget: uvc: set nbuffers to minimum STREAMING_MIN_BUFFERS in uvc_queue_setup
      usb: gadget: uvc: add trace of enqueued and completed requests
      usb: gadget: uvc: dont call usb_composite_setup_continue when not streaming

 drivers/usb/gadget/function/Makefile    |   3 +
 drivers/usb/gadget/function/f_uvc.c     |   2 +
 drivers/usb/gadget/function/uvc.h       |  13 ++
 drivers/usb/gadget/function/uvc_queue.c |  26 ++--
 drivers/usb/gadget/function/uvc_queue.h |   2 +
 drivers/usb/gadget/function/uvc_trace.c |  11 ++
 drivers/usb/gadget/function/uvc_trace.h |  60 ++++++++
 drivers/usb/gadget/function/uvc_v4l2.c  |  55 +++++++
 drivers/usb/gadget/function/uvc_video.c | 264 +++++++++++++++++++-------------
 9 files changed, 316 insertions(+), 120 deletions(-)
---
base-commit: 68d4209158f43a558c5553ea95ab0c8975eab18c
change-id: 20240403-uvc_request_length_by_interval-a7efd587d963

Best regards,

Comments

Greg KH Oct. 16, 2024, 8:47 a.m. UTC | #1
On Sun, Sep 29, 2024 at 08:59:20PM +0200, Michael Grzeschik wrote:
> This patch series is improving the size calculation and allocation of
> the uvc requests. Using the selected frame duration of the stream it is
> possible to calculate the number of requests based on the interval
> length.
> 
> It also precalculates the request length based on the actual per frame
> size for compressed formats.
> 
> For this calculations to work it was needed to rework the request
> queueing by moving the encoding to one extra thread (in this case we
> chose the qbuf) context.
> 
> Next it was needed to move the actual request enqueueing to one extra
> thread which is kept busy to fill the isoc queue in the udc.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
> Changes in v6:
> - fixes in: ("usb: gadget: uvc: add trace of enqueued and completed requests")
> - Link to v5: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v5-0-2de78794365c@pengutronix.de

Breaks the build for me:

In file included from drivers/usb/gadget/function/uvc_trace.h:60,
                 from drivers/usb/gadget/function/uvc_trace.c:11:
./include/trace/define_trace.h:95:42: fatal error: ./uvc_trace.h: No such file or directory
   95 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
      |                                          ^

what did you build this against?

thanks,

greg k-h
Michael Grzeschik Oct. 16, 2024, 2 p.m. UTC | #2
On Wed, Oct 16, 2024 at 10:47:00AM +0200, Greg Kroah-Hartman wrote:
>On Sun, Sep 29, 2024 at 08:59:20PM +0200, Michael Grzeschik wrote:
>> This patch series is improving the size calculation and allocation of
>> the uvc requests. Using the selected frame duration of the stream it is
>> possible to calculate the number of requests based on the interval
>> length.
>>
>> It also precalculates the request length based on the actual per frame
>> size for compressed formats.
>>
>> For this calculations to work it was needed to rework the request
>> queueing by moving the encoding to one extra thread (in this case we
>> chose the qbuf) context.
>>
>> Next it was needed to move the actual request enqueueing to one extra
>> thread which is kept busy to fill the isoc queue in the udc.
>>
>> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>> ---
>> Changes in v6:
>> - fixes in: ("usb: gadget: uvc: add trace of enqueued and completed requests")
>> - Link to v5: https://lore.kernel.org/r/20240403-uvc_request_length_by_interval-v5-0-2de78794365c@pengutronix.de
>
>Breaks the build for me:
>
>In file included from drivers/usb/gadget/function/uvc_trace.h:60,
>                 from drivers/usb/gadget/function/uvc_trace.c:11:
>./include/trace/define_trace.h:95:42: fatal error: ./uvc_trace.h: No such file or directory
>   95 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
>      |                                          ^
>
>what did you build this against?

I somehow managed to drop the CFLAGS for the uvc_trace.o
which was "CFLAGS_uvc_trace.o         := -I$(src)"

This was just fixed in v7. Please try that one:

https://lore.kernel.org/all/20240403-uvc_request_length_by_interval-v7-0-e224bb1035f0@pengutronix.de/

Thanks for testing this,
Michael