uvc_stop_streaming() is used for meta and video nodes. Split the function
in two to avoid confusion.
Use this opportunity to rename uvc_start_streaming() to
uvc_start_streaming_video(), as it is only called by the video nodes.
Reviewed-by: Hans de Goede <hansg@kernel.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c
index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644
--- a/drivers/media/usb/uvc/uvc_queue.c
+++ b/drivers/media/usb/uvc/uvc_queue.c
@@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb)
uvc_video_clock_update(stream, vbuf, buf);
}
-static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count)
+static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count)
{
struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
struct uvc_streaming *stream = uvc_queue_to_stream(queue);
@@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count)
return ret;
}
-static void uvc_stop_streaming(struct vb2_queue *vq)
+static void uvc_stop_streaming_video(struct vb2_queue *vq)
{
struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
lockdep_assert_irqs_enabled();
- if (vq->type != V4L2_BUF_TYPE_META_CAPTURE)
- uvc_video_stop_streaming(uvc_queue_to_stream(queue));
+ uvc_video_stop_streaming(uvc_queue_to_stream(queue));
+
+ uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
+}
+
+static void uvc_stop_streaming_meta(struct vb2_queue *vq)
+{
+ struct uvc_video_queue *queue = vb2_get_drv_priv(vq);
+
+ lockdep_assert_irqs_enabled();
uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR);
}
@@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = {
.buf_prepare = uvc_buffer_prepare,
.buf_queue = uvc_buffer_queue,
.buf_finish = uvc_buffer_finish,
- .start_streaming = uvc_start_streaming,
- .stop_streaming = uvc_stop_streaming,
+ .start_streaming = uvc_start_streaming_video,
+ .stop_streaming = uvc_stop_streaming_video,
};
static const struct vb2_ops uvc_meta_queue_qops = {
.queue_setup = uvc_queue_setup,
.buf_prepare = uvc_buffer_prepare,
.buf_queue = uvc_buffer_queue,
- .stop_streaming = uvc_stop_streaming,
+ .stop_streaming = uvc_stop_streaming_meta,
};
int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type)
--
2.50.0.rc1.591.g9c95f17f64-goog
On Mon, Jun 16, 2025 at 03:24:40PM +0000, Ricardo Ribalda wrote: > uvc_stop_streaming() is used for meta and video nodes. Split the function > in two to avoid confusion. > > Use this opportunity to rename uvc_start_streaming() to > uvc_start_streaming_video(), as it is only called by the video nodes. > > Reviewed-by: Hans de Goede <hansg@kernel.org> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- > 1 file changed, 15 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c > index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 > --- a/drivers/media/usb/uvc/uvc_queue.c > +++ b/drivers/media/usb/uvc/uvc_queue.c > @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) > uvc_video_clock_update(stream, vbuf, buf); > } > > -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) > { > struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > struct uvc_streaming *stream = uvc_queue_to_stream(queue); > @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > return ret; > } > > -static void uvc_stop_streaming(struct vb2_queue *vq) > +static void uvc_stop_streaming_video(struct vb2_queue *vq) > { > struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > > lockdep_assert_irqs_enabled(); > > - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) > - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > + > + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > +} > + > +static void uvc_stop_streaming_meta(struct vb2_queue *vq) > +{ > + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > + > + lockdep_assert_irqs_enabled(); > > uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); I haven't checked where it was introduced, but I think you have a race here. uvc_queue_return_buffers() will return all buffers currently sitting in the queue->irqqueue. This can race with a bunch of places in uvc_video.c that call uvc_queue_get_current_buffer() or uvc_queue_get_next_buffer(), as those functions return a buffer without removing it from the list. > } > @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { > .buf_prepare = uvc_buffer_prepare, > .buf_queue = uvc_buffer_queue, > .buf_finish = uvc_buffer_finish, > - .start_streaming = uvc_start_streaming, > - .stop_streaming = uvc_stop_streaming, > + .start_streaming = uvc_start_streaming_video, > + .stop_streaming = uvc_stop_streaming_video, > }; > > static const struct vb2_ops uvc_meta_queue_qops = { > .queue_setup = uvc_queue_setup, > .buf_prepare = uvc_buffer_prepare, > .buf_queue = uvc_buffer_queue, > - .stop_streaming = uvc_stop_streaming, > + .stop_streaming = uvc_stop_streaming_meta, > }; > > int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) -- Regards, Laurent Pinchart
Hi Laurent On 30-Jun-25 4:17 PM, Laurent Pinchart wrote: > On Mon, Jun 16, 2025 at 03:24:40PM +0000, Ricardo Ribalda wrote: >> uvc_stop_streaming() is used for meta and video nodes. Split the function >> in two to avoid confusion. >> >> Use this opportunity to rename uvc_start_streaming() to >> uvc_start_streaming_video(), as it is only called by the video nodes. >> >> Reviewed-by: Hans de Goede <hansg@kernel.org> >> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> >> --- >> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- >> 1 file changed, 15 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c >> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 >> --- a/drivers/media/usb/uvc/uvc_queue.c >> +++ b/drivers/media/usb/uvc/uvc_queue.c >> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) >> uvc_video_clock_update(stream, vbuf, buf); >> } >> >> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) >> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) >> { >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >> struct uvc_streaming *stream = uvc_queue_to_stream(queue); >> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) >> return ret; >> } >> >> -static void uvc_stop_streaming(struct vb2_queue *vq) >> +static void uvc_stop_streaming_video(struct vb2_queue *vq) >> { >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >> >> lockdep_assert_irqs_enabled(); >> >> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) >> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); >> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); >> + >> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); >> +} >> + >> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) >> +{ >> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >> + >> + lockdep_assert_irqs_enabled(); >> >> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > > I haven't checked where it was introduced, but I think you have a race > here. uvc_queue_return_buffers() will return all buffers currently > sitting in the queue->irqqueue. This can race with a bunch of places in > uvc_video.c that call uvc_queue_get_current_buffer() or > uvc_queue_get_next_buffer(), as those functions return a buffer without > removing it from the list. This change just splits uvc_stop_streaming() into 2 separate functions for uvc_queue_qops + uvc_meta_queue_qops to remove the weird looking "if (vq->type != V4L2_BUF_TYPE_META_CAPTURE)" check done in the shared uvc_stop_streaming(). This patch does not make any functional changes. So if such a race exists then that is a pre-existing problem and not caused by this patch. Regards, Hans > >> } >> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { >> .buf_prepare = uvc_buffer_prepare, >> .buf_queue = uvc_buffer_queue, >> .buf_finish = uvc_buffer_finish, >> - .start_streaming = uvc_start_streaming, >> - .stop_streaming = uvc_stop_streaming, >> + .start_streaming = uvc_start_streaming_video, >> + .stop_streaming = uvc_stop_streaming_video, >> }; >> >> static const struct vb2_ops uvc_meta_queue_qops = { >> .queue_setup = uvc_queue_setup, >> .buf_prepare = uvc_buffer_prepare, >> .buf_queue = uvc_buffer_queue, >> - .stop_streaming = uvc_stop_streaming, >> + .stop_streaming = uvc_stop_streaming_meta, >> }; >> >> int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) >
On Mon, Jun 30, 2025 at 05:12:29PM +0200, Hans de Goede wrote: > On 30-Jun-25 4:17 PM, Laurent Pinchart wrote: > > On Mon, Jun 16, 2025 at 03:24:40PM +0000, Ricardo Ribalda wrote: > >> uvc_stop_streaming() is used for meta and video nodes. Split the function > >> in two to avoid confusion. > >> > >> Use this opportunity to rename uvc_start_streaming() to > >> uvc_start_streaming_video(), as it is only called by the video nodes. > >> > >> Reviewed-by: Hans de Goede <hansg@kernel.org> > >> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > >> --- > >> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- > >> 1 file changed, 15 insertions(+), 7 deletions(-) > >> > >> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c > >> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 > >> --- a/drivers/media/usb/uvc/uvc_queue.c > >> +++ b/drivers/media/usb/uvc/uvc_queue.c > >> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) > >> uvc_video_clock_update(stream, vbuf, buf); > >> } > >> > >> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > >> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) > >> { > >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >> struct uvc_streaming *stream = uvc_queue_to_stream(queue); > >> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > >> return ret; > >> } > >> > >> -static void uvc_stop_streaming(struct vb2_queue *vq) > >> +static void uvc_stop_streaming_video(struct vb2_queue *vq) > >> { > >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >> > >> lockdep_assert_irqs_enabled(); > >> > >> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) > >> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > >> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > >> + > >> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > >> +} > >> + > >> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) > >> +{ > >> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >> + > >> + lockdep_assert_irqs_enabled(); > >> > >> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > > > > I haven't checked where it was introduced, but I think you have a race > > here. uvc_queue_return_buffers() will return all buffers currently > > sitting in the queue->irqqueue. This can race with a bunch of places in > > uvc_video.c that call uvc_queue_get_current_buffer() or > > uvc_queue_get_next_buffer(), as those functions return a buffer without > > removing it from the list. > > This change just splits uvc_stop_streaming() into 2 separate > functions for uvc_queue_qops + uvc_meta_queue_qops to remove > the weird looking "if (vq->type != V4L2_BUF_TYPE_META_CAPTURE)" > check done in the shared uvc_stop_streaming(). > > This patch does not make any functional changes. So if such > a race exists then that is a pre-existing problem and not > caused by this patch. Yes, that's why I said I'm not sure where it was introduced. I only noticed the issue here, it comes from before this patch. > >> } > >> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { > >> .buf_prepare = uvc_buffer_prepare, > >> .buf_queue = uvc_buffer_queue, > >> .buf_finish = uvc_buffer_finish, > >> - .start_streaming = uvc_start_streaming, > >> - .stop_streaming = uvc_stop_streaming, > >> + .start_streaming = uvc_start_streaming_video, > >> + .stop_streaming = uvc_stop_streaming_video, > >> }; > >> > >> static const struct vb2_ops uvc_meta_queue_qops = { > >> .queue_setup = uvc_queue_setup, > >> .buf_prepare = uvc_buffer_prepare, > >> .buf_queue = uvc_buffer_queue, > >> - .stop_streaming = uvc_stop_streaming, > >> + .stop_streaming = uvc_stop_streaming_meta, > >> }; > >> > >> int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) -- Regards, Laurent Pinchart
On 16/06/2025 17:24, Ricardo Ribalda wrote: > uvc_stop_streaming() is used for meta and video nodes. Split the function > in two to avoid confusion. > > Use this opportunity to rename uvc_start_streaming() to > uvc_start_streaming_video(), as it is only called by the video nodes. > > Reviewed-by: Hans de Goede <hansg@kernel.org> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > --- > drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- > 1 file changed, 15 insertions(+), 7 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c > index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 > --- a/drivers/media/usb/uvc/uvc_queue.c > +++ b/drivers/media/usb/uvc/uvc_queue.c > @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) > uvc_video_clock_update(stream, vbuf, buf); > } > > -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) > { > struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > struct uvc_streaming *stream = uvc_queue_to_stream(queue); > @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > return ret; > } > > -static void uvc_stop_streaming(struct vb2_queue *vq) > +static void uvc_stop_streaming_video(struct vb2_queue *vq) > { > struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > > lockdep_assert_irqs_enabled(); > > - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) > - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > + > + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > +} > + > +static void uvc_stop_streaming_meta(struct vb2_queue *vq) > +{ > + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > + > + lockdep_assert_irqs_enabled(); > > uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > } > @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { > .buf_prepare = uvc_buffer_prepare, > .buf_queue = uvc_buffer_queue, > .buf_finish = uvc_buffer_finish, > - .start_streaming = uvc_start_streaming, > - .stop_streaming = uvc_stop_streaming, > + .start_streaming = uvc_start_streaming_video, > + .stop_streaming = uvc_stop_streaming_video, > }; > > static const struct vb2_ops uvc_meta_queue_qops = { > .queue_setup = uvc_queue_setup, > .buf_prepare = uvc_buffer_prepare, > .buf_queue = uvc_buffer_queue, > - .stop_streaming = uvc_stop_streaming, > + .stop_streaming = uvc_stop_streaming_meta, > }; I think there should be a comment stating that the metadata stream expects that video is streaming, it does not start streaming by itself. Something like: /* * .start_streaming is not provided here. Metadata relies on * video streaming being active. If video isn't streaming, then * no metadata will arrive either. */ It's unexpected that there is no start_streaming for metadata, so a comment wouldn't hurt. Otherwise this looks fine, so: Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl> Regards, Hans > > int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type) >
Hi all, On 17-Jun-25 11:27 AM, Hans Verkuil wrote: > On 16/06/2025 17:24, Ricardo Ribalda wrote: >> uvc_stop_streaming() is used for meta and video nodes. Split the function >> in two to avoid confusion. >> >> Use this opportunity to rename uvc_start_streaming() to >> uvc_start_streaming_video(), as it is only called by the video nodes. >> >> Reviewed-by: Hans de Goede <hansg@kernel.org> >> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> >> --- >> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- >> 1 file changed, 15 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c >> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 >> --- a/drivers/media/usb/uvc/uvc_queue.c >> +++ b/drivers/media/usb/uvc/uvc_queue.c >> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) >> uvc_video_clock_update(stream, vbuf, buf); >> } >> >> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) >> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) >> { >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >> struct uvc_streaming *stream = uvc_queue_to_stream(queue); >> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) >> return ret; >> } >> >> -static void uvc_stop_streaming(struct vb2_queue *vq) >> +static void uvc_stop_streaming_video(struct vb2_queue *vq) >> { >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >> >> lockdep_assert_irqs_enabled(); >> >> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) >> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); >> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); >> + >> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); >> +} >> + >> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) >> +{ >> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >> + >> + lockdep_assert_irqs_enabled(); >> >> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); >> } >> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { >> .buf_prepare = uvc_buffer_prepare, >> .buf_queue = uvc_buffer_queue, >> .buf_finish = uvc_buffer_finish, >> - .start_streaming = uvc_start_streaming, >> - .stop_streaming = uvc_stop_streaming, >> + .start_streaming = uvc_start_streaming_video, >> + .stop_streaming = uvc_stop_streaming_video, >> }; >> >> static const struct vb2_ops uvc_meta_queue_qops = { >> .queue_setup = uvc_queue_setup, >> .buf_prepare = uvc_buffer_prepare, >> .buf_queue = uvc_buffer_queue, >> - .stop_streaming = uvc_stop_streaming, >> + .stop_streaming = uvc_stop_streaming_meta, >> }; > > I think there should be a comment stating that the metadata stream > expects that video is streaming, it does not start streaming by itself. > > Something like: > > /* > * .start_streaming is not provided here. Metadata relies on > * video streaming being active. If video isn't streaming, then > * no metadata will arrive either. > */ > > It's unexpected that there is no start_streaming for metadata, so a > comment wouldn't hurt. I've added this comment while merging this series and I've now pushed the entire series to uvc.git/for-next . BTW it seems that both uvc.git/next and uvc.git/for-next are in use now? With uvc.git/next seemingly following media-commiters/next ? I thought we had agreed to only use uvc.git/for-next ? Regards, Hans
On Mon, Jun 30, 2025 at 02:59:05PM +0200, Hans de Goede wrote: > On 17-Jun-25 11:27 AM, Hans Verkuil wrote: > > On 16/06/2025 17:24, Ricardo Ribalda wrote: > >> uvc_stop_streaming() is used for meta and video nodes. Split the function > >> in two to avoid confusion. > >> > >> Use this opportunity to rename uvc_start_streaming() to > >> uvc_start_streaming_video(), as it is only called by the video nodes. > >> > >> Reviewed-by: Hans de Goede <hansg@kernel.org> > >> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > >> --- > >> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- > >> 1 file changed, 15 insertions(+), 7 deletions(-) > >> > >> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c > >> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 > >> --- a/drivers/media/usb/uvc/uvc_queue.c > >> +++ b/drivers/media/usb/uvc/uvc_queue.c > >> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) > >> uvc_video_clock_update(stream, vbuf, buf); > >> } > >> > >> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > >> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) > >> { > >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >> struct uvc_streaming *stream = uvc_queue_to_stream(queue); > >> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > >> return ret; > >> } > >> > >> -static void uvc_stop_streaming(struct vb2_queue *vq) > >> +static void uvc_stop_streaming_video(struct vb2_queue *vq) > >> { > >> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >> > >> lockdep_assert_irqs_enabled(); > >> > >> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) > >> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > >> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > >> + > >> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > >> +} > >> + > >> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) > >> +{ > >> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >> + > >> + lockdep_assert_irqs_enabled(); > >> > >> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > >> } > >> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { > >> .buf_prepare = uvc_buffer_prepare, > >> .buf_queue = uvc_buffer_queue, > >> .buf_finish = uvc_buffer_finish, > >> - .start_streaming = uvc_start_streaming, > >> - .stop_streaming = uvc_stop_streaming, > >> + .start_streaming = uvc_start_streaming_video, > >> + .stop_streaming = uvc_stop_streaming_video, > >> }; > >> > >> static const struct vb2_ops uvc_meta_queue_qops = { > >> .queue_setup = uvc_queue_setup, > >> .buf_prepare = uvc_buffer_prepare, > >> .buf_queue = uvc_buffer_queue, > >> - .stop_streaming = uvc_stop_streaming, > >> + .stop_streaming = uvc_stop_streaming_meta, > >> }; > > > > I think there should be a comment stating that the metadata stream > > expects that video is streaming, it does not start streaming by itself. > > > > Something like: > > > > /* > > * .start_streaming is not provided here. Metadata relies on > > * video streaming being active. If video isn't streaming, then > > * no metadata will arrive either. > > */ > > > > It's unexpected that there is no start_streaming for metadata, so a > > comment wouldn't hurt. > > I've added this comment while merging this series and I've now pushed > the entire series to uvc.git/for-next . > > BTW it seems that both uvc.git/next and uvc.git/for-next are in > use now? With uvc.git/next seemingly following media-commiters/next ? As far as I understand, some jobs in the media CI use the next branch, for instance the bisect job that tries to compile every commit uses the next branch as a base. We therefore need to keep the next branch up-to-date, mirroring upstream. > I thought we had agreed to only use uvc.git/for-next ? -- Regards, Laurent Pinchart
Hi, On 30-Jun-25 3:10 PM, Laurent Pinchart wrote: > On Mon, Jun 30, 2025 at 02:59:05PM +0200, Hans de Goede wrote: >> On 17-Jun-25 11:27 AM, Hans Verkuil wrote: >>> On 16/06/2025 17:24, Ricardo Ribalda wrote: >>>> uvc_stop_streaming() is used for meta and video nodes. Split the function >>>> in two to avoid confusion. >>>> >>>> Use this opportunity to rename uvc_start_streaming() to >>>> uvc_start_streaming_video(), as it is only called by the video nodes. >>>> >>>> Reviewed-by: Hans de Goede <hansg@kernel.org> >>>> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> >>>> --- >>>> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- >>>> 1 file changed, 15 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c >>>> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 >>>> --- a/drivers/media/usb/uvc/uvc_queue.c >>>> +++ b/drivers/media/usb/uvc/uvc_queue.c >>>> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) >>>> uvc_video_clock_update(stream, vbuf, buf); >>>> } >>>> >>>> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) >>>> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) >>>> { >>>> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >>>> struct uvc_streaming *stream = uvc_queue_to_stream(queue); >>>> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) >>>> return ret; >>>> } >>>> >>>> -static void uvc_stop_streaming(struct vb2_queue *vq) >>>> +static void uvc_stop_streaming_video(struct vb2_queue *vq) >>>> { >>>> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >>>> >>>> lockdep_assert_irqs_enabled(); >>>> >>>> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) >>>> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); >>>> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); >>>> + >>>> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); >>>> +} >>>> + >>>> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) >>>> +{ >>>> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); >>>> + >>>> + lockdep_assert_irqs_enabled(); >>>> >>>> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); >>>> } >>>> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { >>>> .buf_prepare = uvc_buffer_prepare, >>>> .buf_queue = uvc_buffer_queue, >>>> .buf_finish = uvc_buffer_finish, >>>> - .start_streaming = uvc_start_streaming, >>>> - .stop_streaming = uvc_stop_streaming, >>>> + .start_streaming = uvc_start_streaming_video, >>>> + .stop_streaming = uvc_stop_streaming_video, >>>> }; >>>> >>>> static const struct vb2_ops uvc_meta_queue_qops = { >>>> .queue_setup = uvc_queue_setup, >>>> .buf_prepare = uvc_buffer_prepare, >>>> .buf_queue = uvc_buffer_queue, >>>> - .stop_streaming = uvc_stop_streaming, >>>> + .stop_streaming = uvc_stop_streaming_meta, >>>> }; >>> >>> I think there should be a comment stating that the metadata stream >>> expects that video is streaming, it does not start streaming by itself. >>> >>> Something like: >>> >>> /* >>> * .start_streaming is not provided here. Metadata relies on >>> * video streaming being active. If video isn't streaming, then >>> * no metadata will arrive either. >>> */ >>> >>> It's unexpected that there is no start_streaming for metadata, so a >>> comment wouldn't hurt. >> >> I've added this comment while merging this series and I've now pushed >> the entire series to uvc.git/for-next . >> >> BTW it seems that both uvc.git/next and uvc.git/for-next are in >> use now? With uvc.git/next seemingly following media-commiters/next ? > > As far as I understand, some jobs in the media CI use the next branch, > for instance the bisect job that tries to compile every commit uses the > next branch as a base. We therefore need to keep the next branch > up-to-date, mirroring upstream. Ok, so we have the next branch mirroring upstream and then we use for-next to merge new patches as I've just done ? Regards, Hans
On Mon, Jun 30, 2025 at 03:12:38PM +0200, Hans de Goede wrote: > On 30-Jun-25 3:10 PM, Laurent Pinchart wrote: > > On Mon, Jun 30, 2025 at 02:59:05PM +0200, Hans de Goede wrote: > >> On 17-Jun-25 11:27 AM, Hans Verkuil wrote: > >>> On 16/06/2025 17:24, Ricardo Ribalda wrote: > >>>> uvc_stop_streaming() is used for meta and video nodes. Split the function > >>>> in two to avoid confusion. > >>>> > >>>> Use this opportunity to rename uvc_start_streaming() to > >>>> uvc_start_streaming_video(), as it is only called by the video nodes. > >>>> > >>>> Reviewed-by: Hans de Goede <hansg@kernel.org> > >>>> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > >>>> --- > >>>> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- > >>>> 1 file changed, 15 insertions(+), 7 deletions(-) > >>>> > >>>> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c > >>>> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 > >>>> --- a/drivers/media/usb/uvc/uvc_queue.c > >>>> +++ b/drivers/media/usb/uvc/uvc_queue.c > >>>> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) > >>>> uvc_video_clock_update(stream, vbuf, buf); > >>>> } > >>>> > >>>> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > >>>> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) > >>>> { > >>>> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >>>> struct uvc_streaming *stream = uvc_queue_to_stream(queue); > >>>> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > >>>> return ret; > >>>> } > >>>> > >>>> -static void uvc_stop_streaming(struct vb2_queue *vq) > >>>> +static void uvc_stop_streaming_video(struct vb2_queue *vq) > >>>> { > >>>> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >>>> > >>>> lockdep_assert_irqs_enabled(); > >>>> > >>>> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) > >>>> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > >>>> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > >>>> + > >>>> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > >>>> +} > >>>> + > >>>> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) > >>>> +{ > >>>> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > >>>> + > >>>> + lockdep_assert_irqs_enabled(); > >>>> > >>>> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > >>>> } > >>>> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { > >>>> .buf_prepare = uvc_buffer_prepare, > >>>> .buf_queue = uvc_buffer_queue, > >>>> .buf_finish = uvc_buffer_finish, > >>>> - .start_streaming = uvc_start_streaming, > >>>> - .stop_streaming = uvc_stop_streaming, > >>>> + .start_streaming = uvc_start_streaming_video, > >>>> + .stop_streaming = uvc_stop_streaming_video, > >>>> }; > >>>> > >>>> static const struct vb2_ops uvc_meta_queue_qops = { > >>>> .queue_setup = uvc_queue_setup, > >>>> .buf_prepare = uvc_buffer_prepare, > >>>> .buf_queue = uvc_buffer_queue, > >>>> - .stop_streaming = uvc_stop_streaming, > >>>> + .stop_streaming = uvc_stop_streaming_meta, > >>>> }; > >>> > >>> I think there should be a comment stating that the metadata stream > >>> expects that video is streaming, it does not start streaming by itself. > >>> > >>> Something like: > >>> > >>> /* > >>> * .start_streaming is not provided here. Metadata relies on > >>> * video streaming being active. If video isn't streaming, then > >>> * no metadata will arrive either. > >>> */ > >>> > >>> It's unexpected that there is no start_streaming for metadata, so a > >>> comment wouldn't hurt. > >> > >> I've added this comment while merging this series and I've now pushed > >> the entire series to uvc.git/for-next . > >> > >> BTW it seems that both uvc.git/next and uvc.git/for-next are in > >> use now? With uvc.git/next seemingly following media-commiters/next ? > > > > As far as I understand, some jobs in the media CI use the next branch, > > for instance the bisect job that tries to compile every commit uses the > > next branch as a base. We therefore need to keep the next branch > > up-to-date, mirroring upstream. > > Ok, so we have the next branch mirroring upstream and then we > use for-next to merge new patches as I've just done ? Sounds good. -- Regards, Laurent Pinchart
On Mon, 30 Jun 2025 at 15:25, Laurent Pinchart <laurent.pinchart@ideasonboard.com> wrote: > > On Mon, Jun 30, 2025 at 03:12:38PM +0200, Hans de Goede wrote: > > On 30-Jun-25 3:10 PM, Laurent Pinchart wrote: > > > On Mon, Jun 30, 2025 at 02:59:05PM +0200, Hans de Goede wrote: > > >> On 17-Jun-25 11:27 AM, Hans Verkuil wrote: > > >>> On 16/06/2025 17:24, Ricardo Ribalda wrote: > > >>>> uvc_stop_streaming() is used for meta and video nodes. Split the function > > >>>> in two to avoid confusion. > > >>>> > > >>>> Use this opportunity to rename uvc_start_streaming() to > > >>>> uvc_start_streaming_video(), as it is only called by the video nodes. > > >>>> > > >>>> Reviewed-by: Hans de Goede <hansg@kernel.org> > > >>>> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> > > >>>> --- > > >>>> drivers/media/usb/uvc/uvc_queue.c | 22 +++++++++++++++------- > > >>>> 1 file changed, 15 insertions(+), 7 deletions(-) > > >>>> > > >>>> diff --git a/drivers/media/usb/uvc/uvc_queue.c b/drivers/media/usb/uvc/uvc_queue.c > > >>>> index 8f9737ac729546683ca48f5e71ce3dfacbae2926..3f357c2d48cfd258c26f0342007d1d12f1e01007 100644 > > >>>> --- a/drivers/media/usb/uvc/uvc_queue.c > > >>>> +++ b/drivers/media/usb/uvc/uvc_queue.c > > >>>> @@ -167,7 +167,7 @@ static void uvc_buffer_finish(struct vb2_buffer *vb) > > >>>> uvc_video_clock_update(stream, vbuf, buf); > > >>>> } > > >>>> > > >>>> -static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > > >>>> +static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) > > >>>> { > > >>>> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > > >>>> struct uvc_streaming *stream = uvc_queue_to_stream(queue); > > >>>> @@ -186,14 +186,22 @@ static int uvc_start_streaming(struct vb2_queue *vq, unsigned int count) > > >>>> return ret; > > >>>> } > > >>>> > > >>>> -static void uvc_stop_streaming(struct vb2_queue *vq) > > >>>> +static void uvc_stop_streaming_video(struct vb2_queue *vq) > > >>>> { > > >>>> struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > > >>>> > > >>>> lockdep_assert_irqs_enabled(); > > >>>> > > >>>> - if (vq->type != V4L2_BUF_TYPE_META_CAPTURE) > > >>>> - uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > > >>>> + uvc_video_stop_streaming(uvc_queue_to_stream(queue)); > > >>>> + > > >>>> + uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > > >>>> +} > > >>>> + > > >>>> +static void uvc_stop_streaming_meta(struct vb2_queue *vq) > > >>>> +{ > > >>>> + struct uvc_video_queue *queue = vb2_get_drv_priv(vq); > > >>>> + > > >>>> + lockdep_assert_irqs_enabled(); > > >>>> > > >>>> uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); > > >>>> } > > >>>> @@ -203,15 +211,15 @@ static const struct vb2_ops uvc_queue_qops = { > > >>>> .buf_prepare = uvc_buffer_prepare, > > >>>> .buf_queue = uvc_buffer_queue, > > >>>> .buf_finish = uvc_buffer_finish, > > >>>> - .start_streaming = uvc_start_streaming, > > >>>> - .stop_streaming = uvc_stop_streaming, > > >>>> + .start_streaming = uvc_start_streaming_video, > > >>>> + .stop_streaming = uvc_stop_streaming_video, > > >>>> }; > > >>>> > > >>>> static const struct vb2_ops uvc_meta_queue_qops = { > > >>>> .queue_setup = uvc_queue_setup, > > >>>> .buf_prepare = uvc_buffer_prepare, > > >>>> .buf_queue = uvc_buffer_queue, > > >>>> - .stop_streaming = uvc_stop_streaming, > > >>>> + .stop_streaming = uvc_stop_streaming_meta, > > >>>> }; > > >>> > > >>> I think there should be a comment stating that the metadata stream > > >>> expects that video is streaming, it does not start streaming by itself. > > >>> > > >>> Something like: > > >>> > > >>> /* > > >>> * .start_streaming is not provided here. Metadata relies on > > >>> * video streaming being active. If video isn't streaming, then > > >>> * no metadata will arrive either. > > >>> */ > > >>> > > >>> It's unexpected that there is no start_streaming for metadata, so a > > >>> comment wouldn't hurt. > > >> > > >> I've added this comment while merging this series and I've now pushed > > >> the entire series to uvc.git/for-next . > > >> > > >> BTW it seems that both uvc.git/next and uvc.git/for-next are in > > >> use now? With uvc.git/next seemingly following media-commiters/next ? > > > > > > As far as I understand, some jobs in the media CI use the next branch, > > > for instance the bisect job that tries to compile every commit uses the > > > next branch as a base. We therefore need to keep the next branch > > > up-to-date, mirroring upstream. > > > > Ok, so we have the next branch mirroring upstream and then we > > use for-next to merge new patches as I've just done ? > > Sounds good. BTW the auto-mirroring from media-committers has not been enabled. Do you want it? > > -- > Regards, > > Laurent Pinchart -- Ricardo Ribalda
© 2016 - 2025 Red Hat, Inc.