From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"laurent.pinchart@ideasonboard.com"
<laurent.pinchart@ideasonboard.com>,
"dan.scally@ideasonboard.com" <dan.scally@ideasonboard.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: Re: [PATCH] usb: gadget: uvc: reduce the request size to increase the throughput
Date: Fri, 10 Nov 2023 22:42:51 +0000 [thread overview]
Message-ID: <20231110224147.vranz2blmbpnsol7@synopsys.com> (raw)
In-Reply-To: <20231110021655.cgj2lk62p4ez7zhp@synopsys.com>
On Fri, Nov 10, 2023, Thinh Nguyen wrote:
> Hi,
>
> On Fri, Nov 10, 2023, Michael Grzeschik wrote:
> > One misconception of queueing request to the usb gadget controller is,
> > that the amount of data that one usb_request is representing is the same
> > as the hardware is able to transfer in one interval.
> >
> > This exact idea applies to the uvc_video gadget that assumes that the
> > request needs to have the size as the gadgets bandwidth parameters are
> > configured with. (maxpacket, multiplier and burst)
> >
> > Although it is actually no problem for the hardware to queue a big
> > request, in the case of isochronous transfers it is impractical to queue
> > big amount of data per request to the hardware. Especially if the
> > necessary bandwidth was increased on purpose to maintain high amounts of
> > data.
> >
> > E.g. in the dwc3-controller it has the negative impact that the endpoint
> > FIFO will not be filled fast enough by the internal hardware engine.
> > Since each transfer buffer (TRB) represents one big request, the
> > hardware will need a long time to prefill the hardware FIFO. This can be
> > avoided by queueing more smaller requests which will then lead to
> > smaller TRBs which the hardware engine can keep up with.
>
> Just want to clarify here to avoid any confusion, the hardware TX FIFO
> size is relatively small, usually can be smaller than the TRB. It should
> be fine whether the TRB is larger or smaller than the FIFO size. The
> hardware does not "prefill" the FIFO. It just fills whichever TRB it's
> currently processing (I think you may be mixing up with TRB cache).
>
> The performance impact from this change is to reduce the USB bandwidth
> usage. The current calculation in uvc function can use 48KB/uframe for
> each request in SuperSpeed, the max size for isoc in SuperSpeed. I know
> many hosts can't handle this kind of transfer rate from their hardware.
> (e.g. It gets worse when scheduling transfers for multiple endpoints and
> under multiple tier hubs).
>
> The bandwidth can be impacted by multiple factors and not just from the
> gadget side as noted in the discussion before.
>
> >
> > This patch is simply dropping the maxburst as an multiplier for the size
> > calculation and therefor decreases the overall maximum request size.
> >
> > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> > ---
> > This patch is created as an result from the discussion in the following thread:
> >
> > https://urldefense.com/v3/__https://lore.kernel.org/linux-usb/20231031231841.dbhtrgqounu2rvgn@synopsys.com/__;!!A4F2R9G_pg!fTaIo4tDljSbEvUY5SZLkNvKWcz0YeN0Ekzs0CPWyD73RGRmErRC2frODFgnMB1M4Nse0oKKgwxC65gePhGAtauKJq1Vnzlj$
> >
> > drivers/usb/gadget/function/uvc_queue.c | 1 -
> > drivers/usb/gadget/function/uvc_video.c | 1 -
> > 2 files changed, 2 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
> > index 0aa3d7e1f3cc32..1d3c3c09ff97cb 100644
> > --- a/drivers/usb/gadget/function/uvc_queue.c
> > +++ b/drivers/usb/gadget/function/uvc_queue.c
> > @@ -55,7 +55,6 @@ static int uvc_queue_setup(struct vb2_queue *vq,
> > sizes[0] = video->imagesize;
> >
> > req_size = video->ep->maxpacket
> > - * max_t(unsigned int, video->ep->maxburst, 1)
>
> I think you're reducing a bit too much here? Also, take advantage of
> burst. So, perhaps keep request size to max(16K, MPS * maxburst)?
I mean to potentially cap at 16K, it didn't translate correctly to
code.... I meant something like this:
max_size = mult * maxburst * MPS;
clamp(max_size, mult * MPS, 16K);
>
> Can be more or less depending on how much video data is needed to
> transfer over a video frame.
Can the uvc gadget figure out the max video data over a video frame? Or
is it not available at this layer? I figure different setup requires
more video data payload.
If we have this info, then you can properly cap the request size.
Thanks,
Thinh
next prev parent reply other threads:[~2023-11-10 22:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 22:12 DWC3-Gadget: Flickering with ISOC Streaming (UVC) while multiplier set on Superspeed Michael Grzeschik
2023-09-01 1:35 ` Thinh Nguyen
2023-09-03 22:41 ` Michael Grzeschik
2023-09-04 0:42 ` Michael Grzeschik
2023-09-06 0:44 ` Thinh Nguyen
2023-09-06 6:40 ` Michael Grzeschik
2023-09-06 0:41 ` Thinh Nguyen
2023-09-06 7:18 ` Michael Grzeschik
2023-09-06 23:05 ` Thinh Nguyen
2023-09-06 23:09 ` Thinh Nguyen
2023-09-07 21:00 ` Michael Grzeschik
2023-09-07 23:33 ` Thinh Nguyen
2023-10-30 12:18 ` Michael Grzeschik
2023-10-31 23:18 ` Thinh Nguyen
2023-11-09 23:33 ` [PATCH] usb: gadget: uvc: reduce the request size to increase the throughput Michael Grzeschik
2023-11-10 2:16 ` Thinh Nguyen
2023-11-10 22:42 ` Thinh Nguyen [this message]
2023-11-13 8:43 ` Michael Grzeschik
2023-11-17 2:39 ` Thinh Nguyen
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=20231110224147.vranz2blmbpnsol7@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=dan.scally@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
/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