From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D504CC43334 for ; Tue, 7 Jun 2022 02:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233222AbiFGCRj (ORCPT ); Mon, 6 Jun 2022 22:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbiFGCRi (ORCPT ); Mon, 6 Jun 2022 22:17:38 -0400 Received: from mail1.bemta35.messagelabs.com (mail1.bemta35.messagelabs.com [67.219.250.112]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D4762459F for ; Mon, 6 Jun 2022 19:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1654568255; i=@motorola.com; bh=W8Xut5B2ldLtyMHJnZ+NRrhUWRnktVN3iU33lneyMzA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:In-Reply-To; b=Yiq/goH8gsvp7oHXw4N3eb4eU8Iy2bYVuXOG37BWvn19EXEgmH7CnQOAE6jpes4e+ sJ19olJkEQmc7WAVbPFpeMzRA7qHVlQv34pdhXGRxchqpmanzIH4XB2pcnDEQsTULE SBLLSh9Flfpi3UEkYRisSwmMMk5W5CvI9RbYUGYqYPIaXBGKoPgO3/rk0lvUJbB2/q DRqcVApPJAV6dwId154QLKBZKJqsEC+tlwQJWpKMmIMk5eScV3yWan9MhumnwPR9Zh yFcIzHmrlJO6b6p+vLRDOfgHW0JjPl73zX6nI5KJI4tlzB3kjdgmoHZg/23EghIraH vnbVuLa7G/SOg== X-Brightmail-Tracker: H4sIAAAAAAAAA+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AwAA X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-4.tower-636.messagelabs.com!1654568253!78417!1 X-Originating-IP: [104.232.228.21] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.86.7; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31532 invoked from network); 7 Jun 2022 02:17:34 -0000 Received: from unknown (HELO va32lpfpp01.lenovo.com) (104.232.228.21) by server-4.tower-636.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Jun 2022 02:17:34 -0000 Received: from va32lmmrp01.lenovo.com (va32lmmrp01.mot.com [10.62.177.113]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by va32lpfpp01.lenovo.com (Postfix) with ESMTPS id 4LHDXF5KbCzhSZf; Tue, 7 Jun 2022 02:17:33 +0000 (UTC) Received: from p1g3 (unknown [10.45.5.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp01.lenovo.com (Postfix) with ESMTPSA id 4LHDXF2hNHzf6f0; Tue, 7 Jun 2022 02:17:33 +0000 (UTC) Date: Mon, 6 Jun 2022 21:17:21 -0500 From: Dan Vacura To: Michael Grzeschik 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 Message-ID: References: <20220529223848.105914-1-m.grzeschik@pengutronix.de> <20220529223848.105914-2-m.grzeschik@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220529223848.105914-2-m.grzeschik@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 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 > > --- > 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 >