Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4261386rwd; Sun, 4 Jun 2023 01:06:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6E0MHLYa5eThfzdB+FMtYtshDyy522g41rgtsB7sT8Qdku5WnyAK/+Yq47PYl0r7/xdI5F X-Received: by 2002:a17:902:9a47:b0:1ad:e2b6:d2a0 with SMTP id x7-20020a1709029a4700b001ade2b6d2a0mr4289445plv.11.1685865978276; Sun, 04 Jun 2023 01:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685865978; cv=none; d=google.com; s=arc-20160816; b=Mg391NzxOlYujZRntyemABfpJ0DIYeRcnL6ogP4fG56Bb9xNjY2cOzOhOVKiv34KoD e0jJkY3xqNy3yslWmdgg+0H0qLspACzZPyAn/yxY+cOjXnN3bsj+hh9BjRW+d9Ko49LU v/vjhJeRI3QNLbj/+SPRFGGBv95J6ALutGIyj0IeZlYZ60jJFB80gpKXxoS0tnXuUUEs cpEjyktP3vuEYwI8COlPdFy8irsDHPStlWkZoZG4UWOP/NI3mEZKqgVlbuIrETIR3zBI WDKw2eJYslM0C/hmhVy3EvagzKe9mxNIk7KQ6EZ1AK4lhsGoH5y2FaRq3AwtUbLDCzJk ttHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rG6mMT5GW8xyc+Ou4h3u8TP5AAvgSzVNnEKQxijXpa4=; b=zLREbSyGzieU3r4VvA/88yEC3wKKalhqj+4ksQEYVL0HOeEzQ3GsEsm3VHnkS2nayu Nq0I0PEC7odGK2NufhGOigIprxwC/iz5M7Veit4+eJacq7zD6SoW9tdJzV+XAjgpx+9+ JCPRzr22QqOMGpJex/34tEH18vNLvP4XYXrLZVq0dw4b1Q5Ctpbzt/4Pqy7jSitDFt7I xGHvOvVPv8z74CoYqNnrDvuIoG+QwpGvspqZMeB5cg+KbWeJX3ltNT/sSNCNvU0CqBUI tjwOhoGSUmYs7eqPHqgixy6rTGfjFlbCu5tnJAoKU+fK0ytudHk9fiFryYn47+lcu5KV qCYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=lqofZ1VV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a170902b78b00b001ae6948b4a0si3557506pls.501.2023.06.04.01.06.06; Sun, 04 Jun 2023 01:06:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=lqofZ1VV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229997AbjFDHyL (ORCPT + 99 others); Sun, 4 Jun 2023 03:54:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbjFDHyJ (ORCPT ); Sun, 4 Jun 2023 03:54:09 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FC62B3; Sun, 4 Jun 2023 00:54:07 -0700 (PDT) Received: from pendragon.ideasonboard.com (om126166129043.28.openmobile.ne.jp [126.166.129.43]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9597C2CF; Sun, 4 Jun 2023 09:53:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1685865221; bh=/nSLdYk7pwOVXOtvyS+KoDrIoZI/A0nO6LauFex2Dxw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lqofZ1VV7WZR33FGxXVDIWtAs9WaF9nVharc1GRQgiSaLkqCJu39S1P66uu22WYMF kxRVilZ8XMZm9cwOSnOH1pzR3Tl52OyOOoNTZEEVaasaUTagDZzcrokvZDZcuKYBLV UucDew2b1rKqPrENvba0zl3dTJs/OMY7hUoxQ6vk= Date: Sun, 4 Jun 2023 10:54:04 +0300 From: Laurent Pinchart To: Avichal Rakesh Cc: dan.scally@ideasonboard.com, thinh.nguyen@synopsys.com, etalvala@google.com, gregkh@linuxfoundation.org, jchowdhary@google.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v3] usb: gadget: uvc: clean up comments and styling in video_pump Message-ID: <20230604075404.GA28735@pendragon.ideasonboard.com> References: <20230602211602.3b7rfa252wliiszp@synopsys.com> <20230602220455.313801-1-arakesh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230602220455.313801-1-arakesh@google.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Avichal, Thank you for the patch. On Fri, Jun 02, 2023 at 03:04:55PM -0700, Avichal Rakesh wrote: > This patch elaborates on some of the edge cases handled by > video_pump around setting no_interrupt flag, and brings the > code style in line with rest of the file. > > Link: https://lore.kernel.org/20230602151916.GH26944@pendragon.ideasonboard.com/ > Signed-off-by: Avichal Rakesh Reviewed-by: Laurent Pinchart > --- > Changelog: > v2: > - Updated commit message to make it clear that userspace application is not > required to match the ISOC rate. > - Styling and comment revision based on review > v3: > - Rebased on to Greg's usb-next where v1 had already merged > - Updated commit message to match the actual changes after rebase. > > > drivers/usb/gadget/function/uvc_video.c | 38 ++++++++++++++++--------- > 1 file changed, 25 insertions(+), 13 deletions(-) > > diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c > index e81865978299..91af3b1ef0d4 100644 > --- a/drivers/usb/gadget/function/uvc_video.c > +++ b/drivers/usb/gadget/function/uvc_video.c > @@ -382,13 +382,13 @@ static void uvcg_video_pump(struct work_struct *work) > { > struct uvc_video *video = container_of(work, struct uvc_video, pump); > struct uvc_video_queue *queue = &video->queue; > + /* video->max_payload_size is only set when using bulk transfer */ > + bool is_bulk = video->max_payload_size; > struct usb_request *req = NULL; > struct uvc_buffer *buf; > unsigned long flags; > + bool buf_done; > int ret; > - bool buf_int; > - /* video->max_payload_size is only set when using bulk transfer */ > - bool is_bulk = video->max_payload_size; > > while (video->ep->enabled) { > /* > @@ -414,20 +414,19 @@ static void uvcg_video_pump(struct work_struct *work) > > if (buf != NULL) { > video->encode(req, video, buf); > - /* Always interrupt for the last request of a video buffer */ > - buf_int = buf->state == UVC_BUF_STATE_DONE; > + buf_done = buf->state == UVC_BUF_STATE_DONE; > } else if (!(queue->flags & UVC_QUEUE_DISCONNECTED) && !is_bulk) { > /* > * No video buffer available; the queue is still connected and > - * we're traferring over ISOC. Queue a 0 length request to > + * we're transferring over ISOC. Queue a 0 length request to > * prevent missed ISOC transfers. > */ > req->length = 0; > - buf_int = false; > + buf_done = false; > } else { > /* > - * Either queue has been disconnected or no video buffer > - * available to bulk transfer. Either way, stop processing > + * Either the queue has been disconnected or no video buffer > + * available for bulk transfer. Either way, stop processing > * further. > */ > spin_unlock_irqrestore(&queue->irqlock, flags); > @@ -435,11 +434,24 @@ static void uvcg_video_pump(struct work_struct *work) > } > > /* > - * With usb3 we have more requests. This will decrease the > - * interrupt load to a quarter but also catches the corner > - * cases, which needs to be handled. > + * With USB3 handling more requests at a higher speed, we can't > + * afford to generate an interrupt for every request. Decide to > + * interrupt: > + * > + * - When no more requests are available in the free queue, as > + * this may be our last chance to refill the endpoint's > + * request queue. > + * > + * - When this is request is the last request for the video > + * buffer, as we want to start sending the next video buffer > + * ASAP in case it doesn't get started already in the next > + * iteration of this loop. > + * > + * - Four times over the length of the requests queue (as > + * indicated by video->uvc_num_requests), as a trade-off > + * between latency and interrupt load. > */ > - if (list_empty(&video->req_free) || buf_int || > + if (list_empty(&video->req_free) || buf_done || > !(video->req_int_count % > DIV_ROUND_UP(video->uvc_num_requests, 4))) { > video->req_int_count = 0; -- Regards, Laurent Pinchart