Message ID | 20201221164819.792019-2-ribalda@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Show privacy_gpio as a v4l2_ctrl | expand |
Hi Ricardo, Thank you for the patch. On Mon, Dec 21, 2020 at 05:48:08PM +0100, Ricardo Ribalda wrote: > The control and its data needs to be copied to the workqueue at the same > time to avoid half-updates of the events. > This is, events reported to userspace were the control id does not match > its value. Actually, after discussing this with you on IRC, I'm not sure there's a problem. The URB is resubmitted by uvc_ctrl_status_event_work(), so the data shouldn't be overwritten before it is processed. > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_ctrl.c | 2 +- > drivers/media/usb/uvc/uvcvideo.h | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c > index 011e69427b7c..aa18dcdf8165 100644 > --- a/drivers/media/usb/uvc/uvc_ctrl.c > +++ b/drivers/media/usb/uvc/uvc_ctrl.c > @@ -1332,7 +1332,7 @@ bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain, > return false; > } > > - w->data = data; > + memcpy(w->data, data, ctrl->info.size); > w->urb = urb; > w->chain = chain; > w->ctrl = ctrl; > diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h > index a3dfacf069c4..0db6c2e0bd98 100644 > --- a/drivers/media/usb/uvc/uvcvideo.h > +++ b/drivers/media/usb/uvc/uvcvideo.h > @@ -678,7 +678,7 @@ struct uvc_device { > struct urb *urb; > struct uvc_video_chain *chain; > struct uvc_control *ctrl; > - const void *data; > + u8 data[UVC_MAX_STATUS_SIZE]; > } async_ctrl; > }; >
diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index 011e69427b7c..aa18dcdf8165 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -1332,7 +1332,7 @@ bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain, return false; } - w->data = data; + memcpy(w->data, data, ctrl->info.size); w->urb = urb; w->chain = chain; w->ctrl = ctrl; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index a3dfacf069c4..0db6c2e0bd98 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -678,7 +678,7 @@ struct uvc_device { struct urb *urb; struct uvc_video_chain *chain; struct uvc_control *ctrl; - const void *data; + u8 data[UVC_MAX_STATUS_SIZE]; } async_ctrl; };
The control and its data needs to be copied to the workqueue at the same time to avoid half-updates of the events. This is, events reported to userspace were the control id does not match its value. Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> --- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- drivers/media/usb/uvc/uvcvideo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)