Skip to contentSkip to conversation

usb: gadget: uvc_video: add worker to handle the frame pumping

PATCH New Michael Grzeschik 1 participant 1 message Apr 27, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH v2 1/1 usb: gadget: uvc_video: add worker to handle the frame pumping

In reply to a message not in the archive

This patch moves the function uvc_video_pump to be a separate schedule worker. This way the completion handler of each usb request and every direct caller of the pump has only to schedule the worker instead of doing the request handling by itself.

Moving the request handling to only one thread solves the locking problems between the three queueing cases.

Many drivers handle the completion handlers directly in their interrupt handlers. This patch also reduces the workload on each interrupt.

---
v1 -> v2: - only trigger the worker when in streaming state

 drivers/usb/gadget/function/uvc.h       |  2 +
 drivers/usb/gadget/function/uvc_v4l2.c  |  5 +-
 drivers/usb/gadget/function/uvc_video.c | 78 +++++--------------------
 drivers/usb/gadget/function/uvc_video.h |  2 -
 4 files changed, 22 insertions(+), 65 deletions(-)
drivers/usb/gadget/function/uvc.h +2 -0
index 1473d25ff17ad1..88e820db9234ec 100644
@@ -77,6 +77,8 @@ struct uvc_video {
 	struct uvc_device *uvc;
 	struct usb_ep *ep;
 
+	struct work_struct pump;
+
 	/* Frame parameters */
 	u8 bpp;
 	u32 fcc;
drivers/usb/gadget/function/uvc_v4l2.c +4 -1
index 495f0ec663ead9..67922b1355e69b 100644
@@ -169,7 +169,10 @@ uvc_v4l2_qbuf(struct file *file, void *fh, struct v4l2_buffer *b)
 	if (ret < 0)
 		return ret;
 
-	return uvcg_video_pump(video);
+	if (uvc->state == UVC_STATE_STREAMING)
+		schedule_work(&video->pump);
+
+	return ret;
 }
 
 static int
drivers/usb/gadget/function/uvc_video.c +16 -62

150 lines not on this page · raw message

drivers/usb/gadget/function/uvc_video.h +0 -2
index dff12103f69699..c618c7bee4756a 100644
@@ -14,8 +14,6 @@
 
 struct uvc_video;
 
-int uvcg_video_pump(struct uvc_video *video);
-
 int uvcg_video_enable(struct uvc_video *video, int enable);
 
 int uvcg_video_init(struct uvc_video *video, struct uvc_device *uvc);
Signature · 1 line
2.26.2