* [PATCH v2 0/2] media: rockchip: rkcif: various fixes
@ 2026-02-20 8:15 Michael Riesch via B4 Relay
2026-02-20 8:15 ` [PATCH v2 1/2] media: rockchip: rkcif: fix off by one bugs Michael Riesch via B4 Relay
2026-02-20 8:15 ` [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement Michael Riesch via B4 Relay
0 siblings, 2 replies; 5+ messages in thread
From: Michael Riesch via B4 Relay @ 2026-02-20 8:15 UTC (permalink / raw)
To: Dan Carpenter, Paul Elder, Laurent Pinchart, Mehdi Djait,
Mauro Carvalho Chehab, Heiko Stuebner, Sakari Ailus,
Hans Verkuil, Bryan O'Donoghue
Cc: Collabora Kernel Team, stable, linux-media, linux-arm-kernel,
linux-rockchip, linux-kernel, Michael Riesch, Chen-Yu Tsai
Habidere,
This series contains
1) a re-spin of Dan's patch that fixes some more stupid off-by-one issues.
This patch has been around on the list for some time, but apparently
has not been applied yet.
2) a fix that makes the DMA abstraction respect the minimum number of
buffers requirement
Best regards,
Michael
Signed-off-by: Michael Riesch <michael.riesch@collabora.com>
---
Changes in v2:
- fixed index of second buffer (Paul)
- fixed cosmetic issues (Laurent)
- Link to v1: https://lore.kernel.org/r/20260216-rkcif-fixes-v1-0-b16db20b6d68@collabora.com
---
Dan Carpenter (1):
media: rockchip: rkcif: fix off by one bugs
Michael Riesch (1):
media: rockchip: rkcif: comply with minimum number of buffers requirement
.../platform/rockchip/rkcif/rkcif-capture-mipi.c | 10 ++---
.../media/platform/rockchip/rkcif/rkcif-stream.c | 44 +++++++++++-----------
2 files changed, 27 insertions(+), 27 deletions(-)
---
base-commit: c824345288d11e269ce41b36c105715bc2286050
change-id: 20260216-rkcif-fixes-bdd9d3c7e4b0
Best regards,
--
Michael Riesch <michael.riesch@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH v2 1/2] media: rockchip: rkcif: fix off by one bugs 2026-02-20 8:15 [PATCH v2 0/2] media: rockchip: rkcif: various fixes Michael Riesch via B4 Relay @ 2026-02-20 8:15 ` Michael Riesch via B4 Relay 2026-02-20 8:15 ` [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement Michael Riesch via B4 Relay 1 sibling, 0 replies; 5+ messages in thread From: Michael Riesch via B4 Relay @ 2026-02-20 8:15 UTC (permalink / raw) To: Dan Carpenter, Paul Elder, Laurent Pinchart, Mehdi Djait, Mauro Carvalho Chehab, Heiko Stuebner, Sakari Ailus, Hans Verkuil, Bryan O'Donoghue Cc: Collabora Kernel Team, stable, linux-media, linux-arm-kernel, linux-rockchip, linux-kernel, Michael Riesch, Chen-Yu Tsai From: Dan Carpenter <dan.carpenter@linaro.org> Change these comparisons from > vs >= to avoid accessing one element beyond the end of the arrays. While at it, use ARRAY_SIZE instead of the _MAX enum values. Fixes: 1f2353f5a1af ("media: rockchip: rkcif: add support for rk3568 vicap mipi capture") Cc: stable@kernel.org Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Michael Riesch <michael.riesch@collabora.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Tested-by: Chen-Yu Tsai <wens@kernel.org> [fix cosmetic issues] Signed-off-by: Michael Riesch <michael.riesch@collabora.com> --- drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c b/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c index 1b81bcc067ef..9e67160a16e4 100644 --- a/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c +++ b/drivers/media/platform/rockchip/rkcif/rkcif-capture-mipi.c @@ -489,8 +489,8 @@ static inline unsigned int rkcif_mipi_get_reg(struct rkcif_interface *interface, block = interface->index - RKCIF_MIPI_BASE; - if (WARN_ON_ONCE(block > RKCIF_MIPI_MAX - RKCIF_MIPI_BASE) || - WARN_ON_ONCE(index > RKCIF_MIPI_REGISTER_MAX)) + if (WARN_ON_ONCE(block >= ARRAY_SIZE(rkcif->match_data->mipi->blocks)) || + WARN_ON_ONCE(index >= ARRAY_SIZE(rkcif->match_data->mipi->regs))) return RKCIF_REGISTER_NOTSUPPORTED; offset = rkcif->match_data->mipi->blocks[block].offset; @@ -510,9 +510,9 @@ static inline unsigned int rkcif_mipi_id_get_reg(struct rkcif_stream *stream, block = stream->interface->index - RKCIF_MIPI_BASE; id = stream->id; - if (WARN_ON_ONCE(block > RKCIF_MIPI_MAX - RKCIF_MIPI_BASE) || - WARN_ON_ONCE(id > RKCIF_ID_MAX) || - WARN_ON_ONCE(index > RKCIF_MIPI_ID_REGISTER_MAX)) + if (WARN_ON_ONCE(block >= ARRAY_SIZE(rkcif->match_data->mipi->blocks)) || + WARN_ON_ONCE(id >= ARRAY_SIZE(rkcif->match_data->mipi->regs_id)) || + WARN_ON_ONCE(index >= ARRAY_SIZE(rkcif->match_data->mipi->regs_id[id]))) return RKCIF_REGISTER_NOTSUPPORTED; offset = rkcif->match_data->mipi->blocks[block].offset; -- 2.39.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement 2026-02-20 8:15 [PATCH v2 0/2] media: rockchip: rkcif: various fixes Michael Riesch via B4 Relay 2026-02-20 8:15 ` [PATCH v2 1/2] media: rockchip: rkcif: fix off by one bugs Michael Riesch via B4 Relay @ 2026-02-20 8:15 ` Michael Riesch via B4 Relay 2026-02-25 3:18 ` Paul Elder 2026-02-25 10:35 ` Isaac Scott 1 sibling, 2 replies; 5+ messages in thread From: Michael Riesch via B4 Relay @ 2026-02-20 8:15 UTC (permalink / raw) To: Dan Carpenter, Paul Elder, Laurent Pinchart, Mehdi Djait, Mauro Carvalho Chehab, Heiko Stuebner, Sakari Ailus, Hans Verkuil, Bryan O'Donoghue Cc: Collabora Kernel Team, stable, linux-media, linux-arm-kernel, linux-rockchip, linux-kernel, Michael Riesch, Chen-Yu Tsai From: Michael Riesch <michael.riesch@collabora.com> Each stream requires CIF_REQ_BUFS_MIN=1 buffers to enable streaming. However, it failed with only one buffer provided. Comply with the minimum number of buffers requirement and accept exactly one buffer. Fixes: 501802e2ad51 ("media: rockchip: rkcif: add abstraction for dma blocks") Cc: stable@kernel.org Tested-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Chen-Yu Tsai <wens@kernel.org> Signed-off-by: Michael Riesch <michael.riesch@collabora.com> --- .../media/platform/rockchip/rkcif/rkcif-stream.c | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c index e00010a91e8b..f15bee4f7cd7 100644 --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c @@ -106,42 +106,42 @@ static int rkcif_stream_init_buffers(struct rkcif_stream *stream) { struct v4l2_pix_format_mplane *pix = &stream->pix; - stream->buffers[0] = rkcif_stream_pop_buffer(stream); - if (!stream->buffers[0]) - goto err_buff_0; - - stream->buffers[1] = rkcif_stream_pop_buffer(stream); - if (!stream->buffers[1]) - goto err_buff_1; - - if (stream->queue_buffer) { - stream->queue_buffer(stream, 0); - stream->queue_buffer(stream, 1); - } - stream->dummy.size = pix->num_planes * pix->plane_fmt[0].sizeimage; stream->dummy.vaddr = dma_alloc_attrs(stream->rkcif->dev, stream->dummy.size, &stream->dummy.buffer.buff_addr[0], GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING); if (!stream->dummy.vaddr) - goto err_dummy; + return -ENOMEM; for (unsigned int i = 1; i < pix->num_planes; i++) stream->dummy.buffer.buff_addr[i] = stream->dummy.buffer.buff_addr[i - 1] + pix->plane_fmt[i - 1].bytesperline * pix->height; - return 0; + stream->buffers[0] = rkcif_stream_pop_buffer(stream); + if (!stream->buffers[0]) + goto err_dummy_free; + + stream->buffers[1] = rkcif_stream_pop_buffer(stream); + if (!stream->buffers[1]) { + stream->buffers[1] = &stream->dummy.buffer; + stream->buffers[1]->is_dummy = true; + } -err_dummy: - rkcif_stream_return_buffer(stream->buffers[1], VB2_BUF_STATE_QUEUED); - stream->buffers[1] = NULL; + if (stream->queue_buffer) { + stream->queue_buffer(stream, 0); + stream->queue_buffer(stream, 1); + } + + return 0; -err_buff_1: - rkcif_stream_return_buffer(stream->buffers[0], VB2_BUF_STATE_QUEUED); - stream->buffers[0] = NULL; -err_buff_0: +err_dummy_free: + dma_free_attrs(stream->rkcif->dev, stream->dummy.size, + stream->dummy.vaddr, + stream->dummy.buffer.buff_addr[0], + DMA_ATTR_NO_KERNEL_MAPPING); + stream->dummy.vaddr = NULL; return -EINVAL; } -- 2.39.5 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement 2026-02-20 8:15 ` [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement Michael Riesch via B4 Relay @ 2026-02-25 3:18 ` Paul Elder 2026-02-25 10:35 ` Isaac Scott 1 sibling, 0 replies; 5+ messages in thread From: Paul Elder @ 2026-02-25 3:18 UTC (permalink / raw) To: Bryan O'Donoghue, Dan Carpenter, Hans Verkuil, Heiko Stuebner, Laurent Pinchart, Mauro Carvalho Chehab, Mehdi Djait, Michael Riesch via B4 Relay, Sakari Ailus, michael.riesch Cc: Collabora Kernel Team, stable, linux-media, linux-arm-kernel, linux-rockchip, linux-kernel, Michael Riesch, Chen-Yu Tsai Hi Michael, Thanks for the patch. Quoting Michael Riesch via B4 Relay (2026-02-20 17:15:08) > From: Michael Riesch <michael.riesch@collabora.com> > > Each stream requires CIF_REQ_BUFS_MIN=1 buffers to enable streaming. > However, it failed with only one buffer provided. > > Comply with the minimum number of buffers requirement and accept > exactly one buffer. > > Fixes: 501802e2ad51 ("media: rockchip: rkcif: add abstraction for dma blocks") > Cc: stable@kernel.org > Tested-by: Paul Elder <paul.elder@ideasonboard.com> > Tested-by: Chen-Yu Tsai <wens@kernel.org> > Signed-off-by: Michael Riesch <michael.riesch@collabora.com> Looks good to me. Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > --- > .../media/platform/rockchip/rkcif/rkcif-stream.c | 44 +++++++++++----------- > 1 file changed, 22 insertions(+), 22 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > index e00010a91e8b..f15bee4f7cd7 100644 > --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > @@ -106,42 +106,42 @@ static int rkcif_stream_init_buffers(struct rkcif_stream *stream) > { > struct v4l2_pix_format_mplane *pix = &stream->pix; > > - stream->buffers[0] = rkcif_stream_pop_buffer(stream); > - if (!stream->buffers[0]) > - goto err_buff_0; > - > - stream->buffers[1] = rkcif_stream_pop_buffer(stream); > - if (!stream->buffers[1]) > - goto err_buff_1; > - > - if (stream->queue_buffer) { > - stream->queue_buffer(stream, 0); > - stream->queue_buffer(stream, 1); > - } > - > stream->dummy.size = pix->num_planes * pix->plane_fmt[0].sizeimage; > stream->dummy.vaddr = > dma_alloc_attrs(stream->rkcif->dev, stream->dummy.size, > &stream->dummy.buffer.buff_addr[0], GFP_KERNEL, > DMA_ATTR_NO_KERNEL_MAPPING); > if (!stream->dummy.vaddr) > - goto err_dummy; > + return -ENOMEM; > > for (unsigned int i = 1; i < pix->num_planes; i++) > stream->dummy.buffer.buff_addr[i] = > stream->dummy.buffer.buff_addr[i - 1] + > pix->plane_fmt[i - 1].bytesperline * pix->height; > > - return 0; > + stream->buffers[0] = rkcif_stream_pop_buffer(stream); > + if (!stream->buffers[0]) > + goto err_dummy_free; > + > + stream->buffers[1] = rkcif_stream_pop_buffer(stream); > + if (!stream->buffers[1]) { > + stream->buffers[1] = &stream->dummy.buffer; > + stream->buffers[1]->is_dummy = true; > + } > > -err_dummy: > - rkcif_stream_return_buffer(stream->buffers[1], VB2_BUF_STATE_QUEUED); > - stream->buffers[1] = NULL; > + if (stream->queue_buffer) { > + stream->queue_buffer(stream, 0); > + stream->queue_buffer(stream, 1); > + } > + > + return 0; > > -err_buff_1: > - rkcif_stream_return_buffer(stream->buffers[0], VB2_BUF_STATE_QUEUED); > - stream->buffers[0] = NULL; > -err_buff_0: > +err_dummy_free: > + dma_free_attrs(stream->rkcif->dev, stream->dummy.size, > + stream->dummy.vaddr, > + stream->dummy.buffer.buff_addr[0], > + DMA_ATTR_NO_KERNEL_MAPPING); > + stream->dummy.vaddr = NULL; > return -EINVAL; > } > > > -- > 2.39.5 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement 2026-02-20 8:15 ` [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement Michael Riesch via B4 Relay 2026-02-25 3:18 ` Paul Elder @ 2026-02-25 10:35 ` Isaac Scott 1 sibling, 0 replies; 5+ messages in thread From: Isaac Scott @ 2026-02-25 10:35 UTC (permalink / raw) To: Bryan O'Donoghue, Dan Carpenter, Hans Verkuil, Heiko Stuebner, Laurent Pinchart, Mauro Carvalho Chehab, Mehdi Djait, Michael Riesch via B4 Relay, Paul Elder, Sakari Ailus, michael.riesch Cc: Collabora Kernel Team, stable, linux-media, linux-arm-kernel, linux-rockchip, linux-kernel, Michael Riesch, Chen-Yu Tsai Hi Michael, Thank you for the patch! Quoting Michael Riesch via B4 Relay (2026-02-20 08:15:08) > From: Michael Riesch <michael.riesch@collabora.com> > > Each stream requires CIF_REQ_BUFS_MIN=1 buffers to enable streaming. > However, it failed with only one buffer provided. > > Comply with the minimum number of buffers requirement and accept > exactly one buffer. > > Fixes: 501802e2ad51 ("media: rockchip: rkcif: add abstraction for dma blocks") > Cc: stable@kernel.org > Tested-by: Paul Elder <paul.elder@ideasonboard.com> > Tested-by: Chen-Yu Tsai <wens@kernel.org> > Signed-off-by: Michael Riesch <michael.riesch@collabora.com> > --- > .../media/platform/rockchip/rkcif/rkcif-stream.c | 44 +++++++++++----------- > 1 file changed, 22 insertions(+), 22 deletions(-) > > diff --git a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > index e00010a91e8b..f15bee4f7cd7 100644 > --- a/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > +++ b/drivers/media/platform/rockchip/rkcif/rkcif-stream.c > @@ -106,42 +106,42 @@ static int rkcif_stream_init_buffers(struct rkcif_stream *stream) > { > struct v4l2_pix_format_mplane *pix = &stream->pix; > > - stream->buffers[0] = rkcif_stream_pop_buffer(stream); > - if (!stream->buffers[0]) > - goto err_buff_0; > - > - stream->buffers[1] = rkcif_stream_pop_buffer(stream); > - if (!stream->buffers[1]) > - goto err_buff_1; > - > - if (stream->queue_buffer) { > - stream->queue_buffer(stream, 0); > - stream->queue_buffer(stream, 1); > - } > - > stream->dummy.size = pix->num_planes * pix->plane_fmt[0].sizeimage; > stream->dummy.vaddr = > dma_alloc_attrs(stream->rkcif->dev, stream->dummy.size, > &stream->dummy.buffer.buff_addr[0], GFP_KERNEL, > DMA_ATTR_NO_KERNEL_MAPPING); > if (!stream->dummy.vaddr) > - goto err_dummy; > + return -ENOMEM; > > for (unsigned int i = 1; i < pix->num_planes; i++) > stream->dummy.buffer.buff_addr[i] = > stream->dummy.buffer.buff_addr[i - 1] + > pix->plane_fmt[i - 1].bytesperline * pix->height; > > - return 0; > + stream->buffers[0] = rkcif_stream_pop_buffer(stream); > + if (!stream->buffers[0]) > + goto err_dummy_free; > + > + stream->buffers[1] = rkcif_stream_pop_buffer(stream); > + if (!stream->buffers[1]) { > + stream->buffers[1] = &stream->dummy.buffer; > + stream->buffers[1]->is_dummy = true; > + } Looks good to me! Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com> > > -err_dummy: > - rkcif_stream_return_buffer(stream->buffers[1], VB2_BUF_STATE_QUEUED); > - stream->buffers[1] = NULL; > + if (stream->queue_buffer) { > + stream->queue_buffer(stream, 0); > + stream->queue_buffer(stream, 1); > + } > + > + return 0; > > -err_buff_1: > - rkcif_stream_return_buffer(stream->buffers[0], VB2_BUF_STATE_QUEUED); > - stream->buffers[0] = NULL; > -err_buff_0: > +err_dummy_free: > + dma_free_attrs(stream->rkcif->dev, stream->dummy.size, > + stream->dummy.vaddr, > + stream->dummy.buffer.buff_addr[0], > + DMA_ATTR_NO_KERNEL_MAPPING); > + stream->dummy.vaddr = NULL; > return -EINVAL; > } > > > -- > 2.39.5 > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-25 10:35 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-02-20 8:15 [PATCH v2 0/2] media: rockchip: rkcif: various fixes Michael Riesch via B4 Relay 2026-02-20 8:15 ` [PATCH v2 1/2] media: rockchip: rkcif: fix off by one bugs Michael Riesch via B4 Relay 2026-02-20 8:15 ` [PATCH v2 2/2] media: rockchip: rkcif: comply with minimum number of buffers requirement Michael Riesch via B4 Relay 2026-02-25 3:18 ` Paul Elder 2026-02-25 10:35 ` Isaac Scott
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®