Re: [PATCH v4 1/2] dma-coherent: add support for multi coherent rmems per dev

From: Andy Shevchenko
Date: Fri Mar 08 2024 - 08:41:38 EST


On Fri, Mar 08, 2024 at 09:53:19AM +0000, Howard Yen wrote:
> Add support for multiple coherent rmems per device. This patch replaces
> original dma_mem with dma_mems list in device structure to store multiple
> rmems.
>
> These multiple rmems can be assigned to the device one by one by
> of_reserved_mem_device_init_by_idx() with the memory-region
> declaration in device tree as below and store the rmem to the dma_mems
> list.
>
> device1@0 {
> ...
> memory-region = <&reserved_mem0>, <&reserved_mem1>;
> ...
> };
>
> When driver tries to allocate memory from the rmems, looks for the first
> available rmem and allocates the memory from this rmem.
>
> Then if driver removed, of_reserved_mem_device_release() needs to be
> invoked to release all the rmems assigned to the device.

..

> +#endif
> +#ifdef CONFIG_DMA_DECLARE_COHERENT
> + INIT_LIST_HEAD(&dev->dma_mems);
> #endif

Side note: Have you used --histogram diff algo? If no, use it in the future.

--
With Best Regards,
Andy Shevchenko