* [PATCH v2] media: rcar-vin: Return unused buffers correctly
@ 2026-11-21 11:54 Niklas Söderlund
2026-11-22 18:25 ` Jacopo Mondi
2026-11-27 14:17 ` Hans Verkuil
0 siblings, 2 replies; 6+ messages in thread
From: Niklas Söderlund @ 2026-11-21 11:54 UTC (permalink / raw)
To: Niklas Söderlund, Mauro Carvalho Chehab, Geert Uytterhoeven,
Magnus Damm, Jacopo Mondi
Cc: linux-media, linux-renesas-soc, linux-kernel,
Niklas Söderlund
Unused VB2 buffers should be returned with state DONE not ERROR when
stopping.
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
Changes in v2:
- Link to v1: https://patch.msgid.link/20260828-vin-fix-vb2-v1-1-97eb1f4f75c9@ragnatech.se
---
* Changes since v1
- Fix unused buffers returned in rvin_stop_streaming() too.
---
drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
index 5e515d16c164..d3d1af47f8b1 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
@@ -1434,7 +1434,7 @@ void rvin_stop_streaming(struct rvin_dev *vin)
for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) {
if (vin->buf_hw[i].buffer)
vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf,
- VB2_BUF_STATE_ERROR);
+ VB2_BUF_STATE_DONE);
}
}
@@ -1449,7 +1449,7 @@ static void rvin_stop_streaming_vq(struct vb2_queue *vq)
dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
vin->scratch_phys);
- return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
+ return_unused_buffers(vin, VB2_BUF_STATE_DONE);
}
static const struct vb2_ops rvin_qops = {
---
base-commit: aa0f4c41d4870a18e65772a1817af16427200371
change-id: 20260828-vin-fix-vb2-28e1bb24a618
Best regards,
--
Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] media: rcar-vin: Return unused buffers correctly
2026-11-21 11:54 [PATCH v2] media: rcar-vin: Return unused buffers correctly Niklas Söderlund
@ 2026-11-22 18:25 ` Jacopo Mondi
2026-11-23 7:58 ` Niklas Söderlund
2026-11-27 14:17 ` Hans Verkuil
1 sibling, 1 reply; 6+ messages in thread
From: Jacopo Mondi @ 2026-11-22 18:25 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Niklas Söderlund, Mauro Carvalho Chehab, Geert Uytterhoeven,
Magnus Damm, Jacopo Mondi, linux-media, linux-renesas-soc,
linux-kernel
Hi Niklas
On Sat, Nov 21, 2026 at 12:54:59PM +0100, Niklas Söderlund wrote:
> Unused VB2 buffers should be returned with state DONE not ERROR when
> stopping.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
I'll take it as you don't consider a Fixes required. This however
count as a bug to me as it doesn't respect the expected API behaviour.
Am I too concerned ?
> ---
> Changes in v2:
> - Link to v1: https://patch.msgid.link/20260828-vin-fix-vb2-v1-1-97eb1f4f75c9@ragnatech.se
> ---
> * Changes since v1
> - Fix unused buffers returned in rvin_stop_streaming() too.
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index 5e515d16c164..d3d1af47f8b1 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -1434,7 +1434,7 @@ void rvin_stop_streaming(struct rvin_dev *vin)
> for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) {
> if (vin->buf_hw[i].buffer)
> vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf,
> - VB2_BUF_STATE_ERROR);
> + VB2_BUF_STATE_DONE);
> }
>
> }
> @@ -1449,7 +1449,7 @@ static void rvin_stop_streaming_vq(struct vb2_queue *vq)
> dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> vin->scratch_phys);
>
> - return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
> + return_unused_buffers(vin, VB2_BUF_STATE_DONE);
> }
>
> static const struct vb2_ops rvin_qops = {
>
> ---
> base-commit: aa0f4c41d4870a18e65772a1817af16427200371
> change-id: 20260828-vin-fix-vb2-28e1bb24a618
>
> Best regards,
> --
> Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] media: rcar-vin: Return unused buffers correctly
2026-11-22 18:25 ` Jacopo Mondi
@ 2026-11-23 7:58 ` Niklas Söderlund
2026-11-24 7:55 ` Jacopo Mondi
0 siblings, 1 reply; 6+ messages in thread
From: Niklas Söderlund @ 2026-11-23 7:58 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Mauro Carvalho Chehab, Geert Uytterhoeven, Magnus Damm,
linux-media, linux-renesas-soc, linux-kernel
Hi Jacopo,
On 2026-11-22 19:25:56 +0100, Jacopo Mondi wrote:
> Hi Niklas
>
> On Sat, Nov 21, 2026 at 12:54:59PM +0100, Niklas Söderlund wrote:
> > Unused VB2 buffers should be returned with state DONE not ERROR when
> > stopping.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
>
> I'll take it as you don't consider a Fixes required.
Thanks.
> This however
> count as a bug to me as it doesn't respect the expected API behaviour.
> Am I too concerned ?
I think so, but I'm not against adding a fixes tag if you feel strongly
about it. If we do want it I think it needs to be to the commit which
first added the driver.
Fixes: f00add9655e1 ("[media] rcar-vin: add Renesas R-Car VIN driver")
Please let me know if you want me to spin a v3 with this tag added.
>
> > ---
> > Changes in v2:
> > - Link to v1: https://patch.msgid.link/20260828-vin-fix-vb2-v1-1-97eb1f4f75c9@ragnatech.se
> > ---
> > * Changes since v1
> > - Fix unused buffers returned in rvin_stop_streaming() too.
> > ---
> > drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > index 5e515d16c164..d3d1af47f8b1 100644
> > --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > @@ -1434,7 +1434,7 @@ void rvin_stop_streaming(struct rvin_dev *vin)
> > for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) {
> > if (vin->buf_hw[i].buffer)
> > vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf,
> > - VB2_BUF_STATE_ERROR);
> > + VB2_BUF_STATE_DONE);
> > }
> >
> > }
> > @@ -1449,7 +1449,7 @@ static void rvin_stop_streaming_vq(struct vb2_queue *vq)
> > dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> > vin->scratch_phys);
> >
> > - return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
> > + return_unused_buffers(vin, VB2_BUF_STATE_DONE);
> > }
> >
> > static const struct vb2_ops rvin_qops = {
> >
> > ---
> > base-commit: aa0f4c41d4870a18e65772a1817af16427200371
> > change-id: 20260828-vin-fix-vb2-28e1bb24a618
> >
> > Best regards,
> > --
> > Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> >
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] media: rcar-vin: Return unused buffers correctly
2026-11-23 7:58 ` Niklas Söderlund
@ 2026-11-24 7:55 ` Jacopo Mondi
0 siblings, 0 replies; 6+ messages in thread
From: Jacopo Mondi @ 2026-11-24 7:55 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Jacopo Mondi, Mauro Carvalho Chehab, Geert Uytterhoeven,
Magnus Damm, linux-media, linux-renesas-soc, linux-kernel
Hi Niklas,
On Mon, Nov 23, 2026 at 08:58:58AM +0100, Niklas Söderlund wrote:
> Hi Jacopo,
>
> On 2026-11-22 19:25:56 +0100, Jacopo Mondi wrote:
> > Hi Niklas
> >
> > On Sat, Nov 21, 2026 at 12:54:59PM +0100, Niklas Söderlund wrote:
> > > Unused VB2 buffers should be returned with state DONE not ERROR when
> > > stopping.
> > >
> > > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> >
> > Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
> >
> > I'll take it as you don't consider a Fixes required.
>
> Thanks.
>
> > This however
> > count as a bug to me as it doesn't respect the expected API behaviour.
> > Am I too concerned ?
>
> I think so, but I'm not against adding a fixes tag if you feel strongly
> about it. If we do want it I think it needs to be to the commit which
> first added the driver.
Ok, after all existing applications already work with the current
implementation, backporting the fix might cause more harm than good
>
> Fixes: f00add9655e1 ("[media] rcar-vin: add Renesas R-Car VIN driver")
>
> Please let me know if you want me to spin a v3 with this tag added.
No need to, I'll pile this one on the PR for rppx1
Thanks
>
> >
> > > ---
> > > Changes in v2:
> > > - Link to v1: https://patch.msgid.link/20260828-vin-fix-vb2-v1-1-97eb1f4f75c9@ragnatech.se
> > > ---
> > > * Changes since v1
> > > - Fix unused buffers returned in rvin_stop_streaming() too.
> > > ---
> > > drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > index 5e515d16c164..d3d1af47f8b1 100644
> > > --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > > @@ -1434,7 +1434,7 @@ void rvin_stop_streaming(struct rvin_dev *vin)
> > > for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) {
> > > if (vin->buf_hw[i].buffer)
> > > vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf,
> > > - VB2_BUF_STATE_ERROR);
> > > + VB2_BUF_STATE_DONE);
> > > }
> > >
> > > }
> > > @@ -1449,7 +1449,7 @@ static void rvin_stop_streaming_vq(struct vb2_queue *vq)
> > > dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> > > vin->scratch_phys);
> > >
> > > - return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
> > > + return_unused_buffers(vin, VB2_BUF_STATE_DONE);
> > > }
> > >
> > > static const struct vb2_ops rvin_qops = {
> > >
> > > ---
> > > base-commit: aa0f4c41d4870a18e65772a1817af16427200371
> > > change-id: 20260828-vin-fix-vb2-28e1bb24a618
> > >
> > > Best regards,
> > > --
> > > Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > >
>
> --
> Kind Regards,
> Niklas Söderlund
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] media: rcar-vin: Return unused buffers correctly
2026-11-21 11:54 [PATCH v2] media: rcar-vin: Return unused buffers correctly Niklas Söderlund
2026-11-22 18:25 ` Jacopo Mondi
@ 2026-11-27 14:17 ` Hans Verkuil
2026-11-27 14:47 ` Jacopo Mondi
1 sibling, 1 reply; 6+ messages in thread
From: Hans Verkuil @ 2026-11-27 14:17 UTC (permalink / raw)
To: Niklas Söderlund, Niklas Söderlund,
Mauro Carvalho Chehab, Geert Uytterhoeven, Magnus Damm,
Jacopo Mondi
Cc: linux-media, linux-renesas-soc, linux-kernel
On 21/11/2026 12:54, Niklas Söderlund wrote:
> Unused VB2 buffers should be returned with state DONE not ERROR when
> stopping.
Why? With 'unused' I assume you mean buffers that have no data in them, i.e. they
have never been used to capture video.
So ERROR is correct for that. The state DONE is reserved for buffers that return
a valid payload.
It's standard behavior to return any unused queued buffers as ERROR when we stop
streaming. That prevents userspace from trying to use their contents.
Jacopo, I'm dropping this one from your PR.
Regards,
Hans
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> Changes in v2:
> - Link to v1: https://patch.msgid.link/20260828-vin-fix-vb2-v1-1-97eb1f4f75c9@ragnatech.se
> ---
> * Changes since v1
> - Fix unused buffers returned in rvin_stop_streaming() too.
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> index 5e515d16c164..d3d1af47f8b1 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> @@ -1434,7 +1434,7 @@ void rvin_stop_streaming(struct rvin_dev *vin)
> for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) {
> if (vin->buf_hw[i].buffer)
> vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf,
> - VB2_BUF_STATE_ERROR);
> + VB2_BUF_STATE_DONE);
> }
>
> }
> @@ -1449,7 +1449,7 @@ static void rvin_stop_streaming_vq(struct vb2_queue *vq)
> dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> vin->scratch_phys);
>
> - return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
> + return_unused_buffers(vin, VB2_BUF_STATE_DONE);
> }
>
> static const struct vb2_ops rvin_qops = {
>
> ---
> base-commit: aa0f4c41d4870a18e65772a1817af16427200371
> change-id: 20260828-vin-fix-vb2-28e1bb24a618
>
> Best regards,
> --
> Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] media: rcar-vin: Return unused buffers correctly
2026-11-27 14:17 ` Hans Verkuil
@ 2026-11-27 14:47 ` Jacopo Mondi
0 siblings, 0 replies; 6+ messages in thread
From: Jacopo Mondi @ 2026-11-27 14:47 UTC (permalink / raw)
To: Hans Verkuil
Cc: Niklas Söderlund, Niklas Söderlund,
Mauro Carvalho Chehab, Geert Uytterhoeven, Magnus Damm,
Jacopo Mondi, linux-media, linux-renesas-soc, linux-kernel
Hi Hans
thanks for checking
On Fri, Nov 27, 2026 at 03:17:44PM +0100, Hans Verkuil wrote:
> On 21/11/2026 12:54, Niklas Söderlund wrote:
> > Unused VB2 buffers should be returned with state DONE not ERROR when
> > stopping.
>
> Why? With 'unused' I assume you mean buffers that have no data in them, i.e. they
> have never been used to capture video.
>
> So ERROR is correct for that. The state DONE is reserved for buffers that return
> a valid payload.
>
> It's standard behavior to return any unused queued buffers as ERROR when we stop
> streaming. That prevents userspace from trying to use their contents.
I probably mis-interpreting the:
"I/O returns to the same state as after calling ioctl VIDIOC_REQBUFS
and can be restarted accordingly."
part from
https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-streamon.html
(also because I now understand a buffer with FLAGS_ERROR is safe to
requeue according to
https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-qbuf.html#vidioc-qbuf
"It is recommended that drivers indicate recoverable errors by setting
the V4L2_BUF_FLAG_ERROR and returning 0 instead. In that case the
application should be able to safely reuse the buffer and continue
streaming."
>
> Jacopo, I'm dropping this one from your PR.
Fine, thanks for checking the PR!
>
> Regards,
>
> Hans
>
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > Changes in v2:
> > - Link to v1: https://patch.msgid.link/20260828-vin-fix-vb2-v1-1-97eb1f4f75c9@ragnatech.se
> > ---
> > * Changes since v1
> > - Fix unused buffers returned in rvin_stop_streaming() too.
> > ---
> > drivers/media/platform/renesas/rcar-vin/rcar-dma.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > index 5e515d16c164..d3d1af47f8b1 100644
> > --- a/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-dma.c
> > @@ -1434,7 +1434,7 @@ void rvin_stop_streaming(struct rvin_dev *vin)
> > for (unsigned int i = 0; i < HW_BUFFER_NUM; i++) {
> > if (vin->buf_hw[i].buffer)
> > vb2_buffer_done(&vin->buf_hw[i].buffer->vb2_buf,
> > - VB2_BUF_STATE_ERROR);
> > + VB2_BUF_STATE_DONE);
> > }
> >
> > }
> > @@ -1449,7 +1449,7 @@ static void rvin_stop_streaming_vq(struct vb2_queue *vq)
> > dma_free_coherent(vin->dev, vin->format.sizeimage, vin->scratch,
> > vin->scratch_phys);
> >
> > - return_unused_buffers(vin, VB2_BUF_STATE_ERROR);
> > + return_unused_buffers(vin, VB2_BUF_STATE_DONE);
> > }
> >
> > static const struct vb2_ops rvin_qops = {
> >
> > ---
> > base-commit: aa0f4c41d4870a18e65772a1817af16427200371
> > change-id: 20260828-vin-fix-vb2-28e1bb24a618
> >
> > Best regards,
> > --
> > Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> >
> >
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-27 14:48 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 11:54 [PATCH v2] media: rcar-vin: Return unused buffers correctly Niklas Söderlund
2026-11-22 18:25 ` Jacopo Mondi
2026-11-23 7:58 ` Niklas Söderlund
2026-11-24 7:55 ` Jacopo Mondi
2026-11-27 14:17 ` Hans Verkuil
2026-11-27 14:47 ` Jacopo Mondi
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).