linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v2,3/3] usb: gadget: uvc: disable stream when disconnected
@ 2018-04-24 20:59 Paul Elder
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Elder @ 2018-04-24 20:59 UTC (permalink / raw)
  To: linux-usb; +Cc: Paul Elder, laurent.pinchart, balbi, gregkh, rogerq

Down the call stack from the ioctl handler for VIDIOC_STREAMON,
uvc_video_alloc_requests contains a BUG_ON, which in the high level,
triggers when VIDIOC_STREAMON ioctl is issued without VIDIOC_STREAMOFF
being issued previously.

This can also be triggered by starting the stream and then physically
disconnecting usb. To fix this, do the streamoff procedures on usb
disconnect.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
Changes in v2: Nothing

 drivers/usb/gadget/function/f_uvc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index fa34dcbe1197..5bb79888e3f7 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -374,9 +374,12 @@ uvc_function_disable(struct usb_function *f)
 {
 	struct uvc_device *uvc = to_uvc(f);
 	struct v4l2_event v4l2_event;
+	struct uvc_video *video = &uvc->video;
 
 	INFO(f->config->cdev, "uvc_function_disable\n");
 
+	uvcg_video_enable(video, 0);
+
 	memset(&v4l2_event, 0, sizeof(v4l2_event));
 	v4l2_event.type = UVC_EVENT_DISCONNECT;
 	v4l2_event_queue(&uvc->vdev, &v4l2_event);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [v2,3/3] usb: gadget: uvc: disable stream when disconnected
@ 2018-05-21  8:10 Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2018-05-21  8:10 UTC (permalink / raw)
  To: Paul Elder; +Cc: linux-usb, balbi, gregkh, rogerq

Hi Paul,

Thank you for the patch.

On Tuesday, 24 April 2018 23:59:36 EEST Paul Elder wrote:
> Down the call stack from the ioctl handler for VIDIOC_STREAMON,
> uvc_video_alloc_requests contains a BUG_ON, which in the high level,
> triggers when VIDIOC_STREAMON ioctl is issued without VIDIOC_STREAMOFF
> being issued previously.
> 
> This can also be triggered by starting the stream and then physically
> disconnecting usb. To fix this, do the streamoff procedures on usb
> disconnect.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
> Changes in v2: Nothing
> 
>  drivers/usb/gadget/function/f_uvc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_uvc.c
> b/drivers/usb/gadget/function/f_uvc.c index fa34dcbe1197..5bb79888e3f7
> 100644
> --- a/drivers/usb/gadget/function/f_uvc.c
> +++ b/drivers/usb/gadget/function/f_uvc.c
> @@ -374,9 +374,12 @@ uvc_function_disable(struct usb_function *f)
>  {
>  	struct uvc_device *uvc = to_uvc(f);
>  	struct v4l2_event v4l2_event;
> +	struct uvc_video *video = &uvc->video;
> 
>  	INFO(f->config->cdev, "uvc_function_disable\n");
> 
> +	uvcg_video_enable(video, 0);
> +

As commented in my reply to patch 2/3, you will need to protect this with 
proper locking. You now have at least four events dealing with states and 
buffers allocation (VIDIOC_STREAMON, VIDIOC_STREAMOFF, uvc_function_set_alt 
and uvc_function_disable).

>  	memset(&v4l2_event, 0, sizeof(v4l2_event));
>  	v4l2_event.type = UVC_EVENT_DISCONNECT;
>  	v4l2_event_queue(&uvc->vdev, &v4l2_event);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-21  8:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-21  8:10 [v2,3/3] usb: gadget: uvc: disable stream when disconnected Laurent Pinchart
  -- strict thread matches above, loose matches on Subject: below --
2018-04-24 20:59 Paul Elder

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).