From: Daniel Scally <dan.scally@ideasonboard.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Daniel Scally <dan.scally@ideasonboard.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org
Subject: [PATCH] usb: gadget: uvc: Move usb_ep_disable() to uvcg_video_enable()
Date: Thu, 15 Jun 2023 10:34:06 +0100 [thread overview]
Message-ID: <20230615093406.80195-1-dan.scally@ideasonboard.com> (raw)
Currently the UVC Gadget's .set_alt() callback disables the USB
endpoint, following which a V4L2 event is queued that closes
down the workqueue. This ordering results in repeated calls to
usb_ep_queue() from the workqueue whilst usb_ep_disable() is
running - behaviour that the documentation for usb_ep_disable()
specifically prohibits.
Move the call to usb_ep_disable() until after cancel_work_sync(),
which will guarantee the endpoint is no longer in use when
usb_ep_disable() is called.
Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>
---
drivers/usb/gadget/function/f_uvc.c | 3 ---
drivers/usb/gadget/function/uvc_video.c | 4 ++++
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 5e919fb65833..4b91bd572a83 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -337,9 +337,6 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
if (uvc->state != UVC_STATE_STREAMING)
return 0;
- if (uvc->video.ep)
- usb_ep_disable(uvc->video.ep);
-
memset(&v4l2_event, 0, sizeof(v4l2_event));
v4l2_event.type = UVC_EVENT_STREAMOFF;
v4l2_event_queue(&uvc->vdev, &v4l2_event);
diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index 91af3b1ef0d4..c7e38fa26492 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -499,6 +499,10 @@ int uvcg_video_enable(struct uvc_video *video, int enable)
if (!enable) {
cancel_work_sync(&video->pump);
+
+ if (video->ep)
+ usb_ep_disable(video->ep);
+
uvcg_queue_cancel(&video->queue, 0);
for (i = 0; i < video->uvc_num_requests; ++i)
--
2.34.1
next reply other threads:[~2023-06-15 9:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-15 9:34 Daniel Scally [this message]
2023-06-15 17:15 ` [PATCH] usb: gadget: uvc: Move usb_ep_disable() to uvcg_video_enable() Laurent Pinchart
2023-08-30 20:38 ` Avichal Rakesh
2023-09-04 14:36 ` Michael Grzeschik
2023-09-08 15:54 ` Avichal Rakesh
2023-09-11 0:50 ` Michael Grzeschik
2023-09-12 4:26 ` Avichal Rakesh
2023-09-15 23:13 ` Michael Grzeschik
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=20230615093406.80195-1-dan.scally@ideasonboard.com \
--to=dan.scally@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-usb@vger.kernel.org \
/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