Re: [PATCH v3 4/5] media: iris: select appropriate DMA device for internal buffers

Bryan O'Donoghue
2025-06-27T17:07:38Z

On 27/06/2025 16:48, Vikash Garodia wrote:
> When a non-pixel device (np_dev) exists, it is preferred for DMA
> operations for internal buffers which are specific to bitstream data
> processing. DPB(decoded picture buffer) buffers are internal buffers
> associated with pixel buffers, hence they are not part of "non_pixel"
> device.
>
> Signed-off-by: Vikash Garodia <quic_vgarodia@quicinc.com>
> ---
> drivers/media/platform/qcom/iris/iris_buffer.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_buffer.c b/drivers/media/platform/qcom/iris/iris_buffer.c
> index e5c5a564fcb81e77746df8c4797a10a07f2ae946..0bf6041936175d03a51985be148e78894fc3e990 100644
> --- a/drivers/media/platform/qcom/iris/iris_buffer.c
> +++ b/drivers/media/platform/qcom/iris/iris_buffer.c
> @@ -265,6 +265,7 @@ static int iris_create_internal_buffer(struct iris_inst *inst,
> struct iris_buffers *buffers = &inst->buffers[buffer_type];
> struct iris_core *core = inst->core;
> struct iris_buffer *buffer;
> + struct device *dev;
>
> if (!buffers->size)
> return 0;
> @@ -280,7 +281,11 @@ static int iris_create_internal_buffer(struct iris_inst *inst,
> buffer->dma_attrs = DMA_ATTR_WRITE_COMBINE | DMA_ATTR_NO_KERNEL_MAPPING;
> list_add_tail(&buffer->list, &buffers->list);
>
> - buffer->kvaddr = dma_alloc_attrs(core->dev, buffer->buffer_size,
> + dev = core->np_dev ? core->np_dev : core->dev;
> + if (buffer->type == BUF_DPB)
> + dev = core->dev;
> +
> + buffer->kvaddr = dma_alloc_attrs(dev, buffer->buffer_size,
> &buffer->device_addr, GFP_KERNEL, buffer->dma_attrs);
> if (!buffer->kvaddr)
> return -ENOMEM;
> @@ -367,9 +372,15 @@ int iris_queue_internal_buffers(struct iris_inst *inst, u32 plane)
> int iris_destroy_internal_buffer(struct iris_inst *inst, struct iris_buffer *buffer)
> {
> struct iris_core *core = inst->core;
> + struct device *dev;
> +
> + dev = core->np_dev ? core->np_dev : core->dev;
> +
> + if (buffer->type == BUF_DPB)
> + dev = core->dev;

Again I think the hooking of dev is clearer with if/else instead of
ternary operators.

Its not against the coding standard to my knowledge ..

>
> list_del(&buffer->list);
> - dma_free_attrs(core->dev, buffer->buffer_size, buffer->kvaddr,
> + dma_free_attrs(dev, buffer->buffer_size, buffer->kvaddr,
> buffer->device_addr, buffer->dma_attrs);
> kfree(buffer);
>
>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>