All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Grzeschik <m.grzeschik@pengutronix.de>
To: linux-usb@vger.kernel.org
Cc: balbi@kernel.org, laurent.pinchart@ideasonboard.com,
	paul.elder@ideasonboard.com, kernel@pengutronix.de,
	caleb.connolly@ideasonboard.com
Subject: [PATCH v2 5/7] usb: gadget: uvc: only pump video data if necessary
Date: Sun,  3 Oct 2021 22:29:37 +0200	[thread overview]
Message-ID: <20211003202939.306-6-m.grzeschik@pengutronix.de> (raw)
In-Reply-To: <20211003202939.306-1-m.grzeschik@pengutronix.de>

If the streaming endpoint is not enabled, the worker has nothing to do.
In the case it still got enqueued, this patch ensueres that it will bail
out without handling any data.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
v2: - added reviewed by

 drivers/usb/gadget/function/uvc_video.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index ccee35177411d..152647495fa61 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -335,12 +335,12 @@ 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;
-	struct usb_request *req;
+	struct usb_request *req = NULL;
 	struct uvc_buffer *buf;
 	unsigned long flags;
 	int ret;
 
-	while (1) {
+	while (video->ep->enabled) {
 		/* Retrieve the first available USB request, protected by the
 		 * request lock.
 		 */
@@ -390,6 +390,9 @@ static void uvcg_video_pump(struct work_struct *work)
 		video->req_int_count++;
 	}
 
+	if (!req)
+		return;
+
 	spin_lock_irqsave(&video->req_lock, flags);
 	list_add_tail(&req->list, &video->req_free);
 	spin_unlock_irqrestore(&video->req_lock, flags);
-- 
2.30.2


  parent reply	other threads:[~2021-10-03 20:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-03 20:29 [PATCH v2 0/7] usb: gadget: uvc: smaller fixes for stability Michael Grzeschik
2021-10-03 20:29 ` [PATCH v2 1/7] usb: gadget: uvc: consistently use define for headerlen Michael Grzeschik
2021-10-03 20:29 ` [PATCH v2 2/7] usb: gadget: uvc: rename function to be more consistent Michael Grzeschik
2021-10-03 20:29 ` [PATCH v2 3/7] usb: gadget: uvc: test if ep->desc is valid on ep_queue Michael Grzeschik
2021-10-03 20:29 ` [PATCH v2 4/7] usb: gadget: uvc: only schedule stream in streaming state Michael Grzeschik
2021-10-03 20:29 ` Michael Grzeschik [this message]
2021-10-03 20:29 ` [PATCH v2 6/7] usb: gadget: uvc: ensure the vdev is unset Michael Grzeschik
2021-10-03 20:29 ` [PATCH v2 7/7] usb: gadget: udc: ensure the gadget is still available Michael Grzeschik
2021-10-04 22:43 ` [PATCH v2 0/7] usb: gadget: uvc: smaller fixes for stability Laurent Pinchart

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=20211003202939.306-6-m.grzeschik@pengutronix.de \
    --to=m.grzeschik@pengutronix.de \
    --cc=balbi@kernel.org \
    --cc=caleb.connolly@ideasonboard.com \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-usb@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.