Re: [PATCH 2/2] media: rcar-isp: Fail buffer preparation if the ConfigDMA buffer is full

From: Niklas Söderlund

Date: Wed Dec 02 2026 - 11:31:13 EST


Hi Hyeonjun,

Thanks for your work.

On 2026-12-03 00:17:18 +0900, Hyeonjun Hong wrote:
> risp_conf_dma_prepare() returns -ENOMEM when the ConfigDMA buffer is
> full, but the rppx1 block handlers that call it do not check the result
> of the write callback. rppx1_params() then returns 0, the remaining
> register writes are dropped without notice and the truncated
> configuration is queued.
>
> Record the condition in the write descriptor and fail
> risp_io_params_buffer_prepare() if it was hit, instead of adding error
> handling to every write in the rppx1 block handlers.
>
> Signed-off-by: Hyeonjun Hong <hyeonjunhong330@xxxxxxxxx>
> ---
> drivers/media/platform/renesas/rcar-isp/core-io.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-isp/core-io.c b/drivers/media/platform/renesas/rcar-isp/core-io.c
> index 5c6018491160..a5f18aeb1f28 100644
> --- a/drivers/media/platform/renesas/rcar-isp/core-io.c
> +++ b/drivers/media/platform/renesas/rcar-isp/core-io.c
> @@ -501,6 +501,7 @@ struct risp_conf_dma_write_desc {
> u32 *buf;
> u32 base;
> unsigned int count;
> + bool overflow;

I don't like adding a flag for this, and it's not needed...

> };
>
> static int risp_conf_dma_prepare(void *priv, u32 offset, u32 value)
> @@ -508,8 +509,10 @@ static int risp_conf_dma_prepare(void *priv, u32 offset, u32 value)
> struct risp_conf_dma_write_desc *desc = priv;
>
> /* Bounds check, 8 bytes header + 8 bytes = address (4) + value (4). */
> - if (8 + (desc->count + 1) * 8 > RISP_IO_PARAMS_BUF_SIZE)
> + if (8 + (desc->count + 1) * 8 > RISP_IO_PARAMS_BUF_SIZE) {

... This check while also setting the new overflow flag will return
-ENOMEM ...


> + desc->overflow = true;
> return -ENOMEM;
> + }
>
> (*desc->buf++) = desc->base | offset;
> (*desc->buf++) = value;
> @@ -534,6 +537,7 @@ static int risp_io_params_buffer_prepare(struct vb2_buffer *vb)
> desc.buf = cpu_addr + 2;
> desc.base = io->core->rppaddr;
> desc.count = 0;
> + desc.overflow = false;
>
> /* Fill params body. */
> ret = rppx1_params(io->core->rpp, vb, io->format.fmt.meta.buffersize,
> @@ -541,6 +545,10 @@ static int risp_io_params_buffer_prepare(struct vb2_buffer *vb)
> if (ret)
> return ret;

... Which will be propagated and returned here ...


>
> + /* The block handlers do not check the result of the write callback. */
> + if (desc.overflow)
> + return -ENOMEM;


... So this check will never be reached.

> +
> /* Fill params header. */
> cpu_addr[0] = desc.count;
> cpu_addr[1] = 0x0;
> --
> 2.34.1
>

--
Kind Regards,
Niklas Söderlund