From: Dan Vacura <w36195@motorola.com>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: linux-usb@vger.kernel.org, balbi@kernel.org,
paul.elder@ideasonboard.com, kieran.bingham@ideasonboard.com,
nicolas@ndufresne.ca, laurent.pinchart@ideasonboard.com,
kernel@pengutronix.de
Subject: Re: [PATCH v2 1/3] usb: gadget: uvc: calculate the number of request depending on framesize
Date: Mon, 6 Jun 2022 21:17:21 -0500 [thread overview]
Message-ID: <Yp61Me25lBbyGsc8@p1g3> (raw)
In-Reply-To: <20220529223848.105914-2-m.grzeschik@pengutronix.de>
Hi Michael,
On Mon, May 30, 2022 at 12:38:46AM +0200, Michael Grzeschik wrote:
> The current limitation of possible number of requests being handled is
> dependent on the gadget speed. It makes more sense to depend on the
> typical frame size when calculating the number of requests. This patch
> is changing this and is using the previous limits as boundaries for
> reasonable minimum and maximum number of requests.
>
> For a 1080p jpeg encoded video stream with a maximum imagesize of
> e.g. 800kB with a maxburst of 8 and an multiplier of 1 the resulting
> number of requests is calculated to 49.
>
> 800768 1
> nreqs = ------ * -------------- ~= 49
> 2 (1024 * 8 * 1)
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Thanks for the patch. This improves the usb2 performance on our
android 5.10 kernel with dwc3 controller. Any reason to not cc stable
lines? This does help older releases as well.
Tested-by: Dan Vacura <w36195@motorola.com>
>
> ---
> v1 -> v2: - using clamp instead of min/max
> - added calculation example to description
> - commented the additional division by two in the code
>
> drivers/usb/gadget/function/uvc_queue.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
> index d25edc3d2174e1..eb9bd9d32cd056 100644
> --- a/drivers/usb/gadget/function/uvc_queue.c
> +++ b/drivers/usb/gadget/function/uvc_queue.c
> @@ -44,7 +44,8 @@ static int uvc_queue_setup(struct vb2_queue *vq,
> {
> struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
> struct uvc_video *video = container_of(queue, struct uvc_video, queue);
> - struct usb_composite_dev *cdev = video->uvc->func.config->cdev;
> + unsigned int req_size;
> + unsigned int nreq;
>
> if (*nbuffers > UVC_MAX_VIDEO_BUFFERS)
> *nbuffers = UVC_MAX_VIDEO_BUFFERS;
> @@ -53,10 +54,16 @@ static int uvc_queue_setup(struct vb2_queue *vq,
>
> sizes[0] = video->imagesize;
>
> - if (cdev->gadget->speed < USB_SPEED_SUPER)
> - video->uvc_num_requests = 4;
> - else
> - video->uvc_num_requests = 64;
> + req_size = video->ep->maxpacket
> + * max_t(unsigned int, video->ep->maxburst, 1)
> + * (video->ep->mult);
> +
> + /* We divide by two, to increase the chance to run
> + * into fewer requests for smaller framesizes.
> + */
> + nreq = DIV_ROUND_UP(DIV_ROUND_UP(sizes[0], 2), req_size);
> + nreq = clamp(nreq, 4U, 64U);
> + video->uvc_num_requests = nreq;
>
> return 0;
> }
> --
> 2.30.2
>
next prev parent reply other threads:[~2022-06-07 2:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-29 22:38 [PATCH v2 0/3] usb: gadget: uvc: fixes and improvements Michael Grzeschik
2022-05-29 22:38 ` [PATCH v2 1/3] usb: gadget: uvc: calculate the number of request depending on framesize Michael Grzeschik
2022-06-07 2:17 ` Dan Vacura [this message]
2022-05-29 22:38 ` [PATCH v2 2/3] usb: gadget: uvc: increase worker prio to WQ_HIGHPRI Michael Grzeschik
2022-05-29 22:38 ` [PATCH v2 3/3] usb: gadget: uvc: call uvc uvcg_warn on completed status instead of uvcg_info Michael Grzeschik
2022-06-10 9:51 ` [PATCH v2 0/3] usb: gadget: uvc: fixes and improvements Greg KH
2022-06-10 9:52 ` Greg KH
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=Yp61Me25lBbyGsc8@p1g3 \
--to=w36195@motorola.com \
--cc=balbi@kernel.org \
--cc=kernel@pengutronix.de \
--cc=kieran.bingham@ideasonboard.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-usb@vger.kernel.org \
--cc=m.grzeschik@pengutronix.de \
--cc=nicolas@ndufresne.ca \
--cc=paul.elder@ideasonboard.com \
/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