All of lore.kernel.org
 help / color / mirror / Atom feed
* [3/4] usb: gadget: uvc: synchronize usb status phase delay for uvc_function_set_alt
@ 2018-04-18  3:18 Paul Elder
  0 siblings, 0 replies; only message in thread
From: Paul Elder @ 2018-04-18  3:18 UTC (permalink / raw)
  To: linux-usb; +Cc: Paul Elder, laurent.pinchart

This patch depends on the previous patch in this series:
[PATCH 2/4] usb: gadget: composite: add function to increment
delayed_status

The completion of the usb status phase from uvc_function_set_alt needs
to be delayed until uvc_v4l2_streamon/off. This is currently done by
uvc_function_set_alt returning USB_GADGET_DELAYED_STATUS and
composite_setup detecting this to increment cdev->delayed_status.
However, if uvc_v4l2_streamon/off is called in between this return and
increment, uvc_function_setup_continue within uvc_v4l2_streamon/off will
WARN that cdev->delayed_status is zero.

To fix this, use usb_composite_setup_delay to increment
cdev->delayed_status, and then return 0 so that composite_setup doesn't
increment cdev->delayed_status again.

Signed-off-by: Paul Elder <paul.elder@pitt.edu>
---
 drivers/usb/gadget/function/f_uvc.c    | 13 ++++++++++++-
 drivers/usb/gadget/function/uvc_v4l2.c |  2 ++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
index 9b63b28a1ee3..3324d36e809c 100644
--- a/drivers/usb/gadget/function/f_uvc.c
+++ b/drivers/usb/gadget/function/f_uvc.c
@@ -334,6 +334,8 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
 
 		uvc->state = UVC_STATE_STOPPING;
 
+		usb_composite_setup_delay(cdev);
+
 		memset(&v4l2_event, 0, sizeof(v4l2_event));
 		v4l2_event.type = UVC_EVENT_STREAMOFF;
 		v4l2_event_queue(&uvc->vdev, &v4l2_event);
@@ -358,10 +360,19 @@ uvc_function_set_alt(struct usb_function *f, unsigned interface, unsigned alt)
 
 		uvc->state = UVC_STATE_STARTING;
 
+		usb_composite_setup_delay(cdev);
+
 		memset(&v4l2_event, 0, sizeof(v4l2_event));
 		v4l2_event.type = UVC_EVENT_STREAMON;
 		v4l2_event_queue(&uvc->vdev, &v4l2_event);
-		return USB_GADGET_DELAYED_STATUS;
+
+		/*
+		 * Normally we would return USB_GADGET_DELAYED_STATUS
+		 * but status phase might try to continue in between
+		 * this function returning and the delayed status
+		 * actually being set
+		 */
+		return 0;
 
 	default:
 		return -EINVAL;
diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
index fdf02b6987c0..0592e13d861c 100644
--- a/drivers/usb/gadget/function/uvc_v4l2.c
+++ b/drivers/usb/gadget/function/uvc_v4l2.c
@@ -235,6 +235,8 @@ uvc_v4l2_streamoff(struct file *file, void *fh, enum v4l2_buf_type type)
 
 	uvc->state = UVC_STATE_CONNECTED;
 
+	uvc_function_setup_continue(uvc);
+
 	return 0;
 
 }

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-04-18  3:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18  3:18 [3/4] usb: gadget: uvc: synchronize usb status phase delay for uvc_function_set_alt Paul Elder

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.