From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Michael Grzeschik <m.grzeschik@pengutronix.de>
Cc: linux-usb@vger.kernel.org, balbi@kernel.org,
paul.elder@ideasonboard.com, kernel@pengutronix.de,
nicolas@ndufresne.ca, kieran.bingham@ideasonboard.com
Subject: Re: [PATCH 2/5] usb: gadget: uvc: calculate the number of request depending on framesize
Date: Tue, 19 Apr 2022 23:46:44 +0300 [thread overview]
Message-ID: <Yl8ftLtM4hOIVf/s@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220402233914.3625405-3-m.grzeschik@pengutronix.de>
Hi Michael,
Thank you for the patch.
On Sun, Apr 03, 2022 at 01:39:11AM +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.
What are typical values you get for the number of requests in your use
cases with this change ? Could you mention them in the commit message ?
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> ---
> drivers/usb/gadget/function/uvc_queue.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c
> index cfa0ac4adb04d5..2a091cf07981e1 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,14 @@ 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);
> +
> + nreq = DIV_ROUND_UP(DIV_ROUND_UP(sizes[0], 2), req_size);
Where does the division by 2 come from ?
> + nreq = min_t(unsigned int, nreq, 64);
> + nreq = max_t(unsigned int, nreq, 4);
You can use clamp():
video->uvc_num_requests = clamp(nreq, 4U, 64U);
> + video->uvc_num_requests = nreq;
>
> return 0;
> }
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2022-04-19 20:46 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-02 23:39 [PATCH 0/5] usb: gadget: uvc: fixes and improvements Michael Grzeschik
2022-04-02 23:39 ` [PATCH 1/5] usb: gadget: uvc: reset bytesused on queue cancel Michael Grzeschik
2022-04-05 8:43 ` Sergey Shtylyov
2022-04-05 15:01 ` Dan Vacura
2022-04-06 8:26 ` Michael Grzeschik
2022-04-02 23:39 ` [PATCH 2/5] usb: gadget: uvc: calculate the number of request depending on framesize Michael Grzeschik
2022-04-19 20:46 ` Laurent Pinchart [this message]
2022-05-08 22:48 ` Michael Grzeschik
2022-04-02 23:39 ` [PATCH 3/5] usb: gadget: uvc: increase worker prio to WQ_HIGHPRI Michael Grzeschik
2022-04-19 20:46 ` Laurent Pinchart
2022-04-29 18:51 ` Dan Vacura
2022-04-29 20:01 ` Michael Grzeschik
2022-05-02 9:00 ` Michael Grzeschik
2022-05-06 21:49 ` Dan Vacura
2022-09-28 20:12 ` Laurent Pinchart
2022-04-02 23:39 ` [PATCH 4/5] usb: gadget: uvc: call uvc uvcg_warn on completed status instead of uvcg_info Michael Grzeschik
2022-04-19 20:47 ` Laurent Pinchart
2022-04-02 23:39 ` [PATCH 5/5] usb: gadget: uvc: stop the pump on more conditions Michael Grzeschik
2022-04-04 11:30 ` kernel test robot
2022-04-04 13:07 ` Michael Grzeschik
2022-04-19 14:21 ` 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=Yl8ftLtM4hOIVf/s@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=balbi@kernel.org \
--cc=kernel@pengutronix.de \
--cc=kieran.bingham@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;
as well as URLs for NNTP newsgroup(s).