Re: [PATCH v5 2/7] dmaengine: add a bus for DMA channel devices
From: Frank Li
Date: Wed Nov 11 2026 - 12:38:58 EST
On Wed, Nov 11, 2026 at 09:47:30PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@xxxxxxx>
>
> DMA channel devices are currently created as class devices without a bus.
> This works for sysfs, but it prevents per-channel DMA/IOMMU configuration:
> of_dma_configure() only probes the IOMMU when dev->bus is set, and the
> IOMMU core only installs probe/release notifiers for buses listed in
> iommu_buses[].
>
> Drivers that need per-channel IOMMU support currently work around this by
> assigning dev->bus after device_register(). That leaves the bus subsystem
> reference count unbalanced because bus_add_device() already ran with a NULL
> bus, and bus_remove_device() will later drop a reference that was never
> taken.
>
> Add a dedicated bus for DMA channel devices and register it during
> dmaengine initialisation. Use core_initcall so the bus exists before any
> IOMMU driver can call iommu_device_register(), which iterates iommu_buses[]
> and fails on an unregistered bus. The match callback always reports no
> match, so no driver can bind to these devices. A follow-up patch will
> register the channel devices on this bus.
>
> Clean up the unmap pools if dmaengine initialisation fails after they have
> been allocated.
>
> Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> ---
> drivers/dma/dmaengine.c | 28 +++++++++++++++++++++++++---
> include/linux/dmaengine.h | 4 ++++
> 2 files changed, 29 insertions(+), 3 deletions(-)
>
...
> diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> index 805668fbe437..14d8f182c7cb 100644
> --- a/include/linux/dmaengine.h
> +++ b/include/linux/dmaengine.h
> @@ -412,6 +412,10 @@ struct dma_chan_dev {
> bool chan_dma_dev;
> };
>
> +#ifdef CONFIG_DMA_ENGINE
> +extern const struct bus_type dma_chan_bus_type;
New API, need use dmaengine prefix, dmaengine_chan_bus_type
Not sure how other dmaengine support it before? Maybe already block for
long time.
Frank
> +#endif
> +
> /**
> * enum dma_slave_buswidth - defines bus width of the DMA slave
> * device, source or target buses
>
> --
> 2.34.1
>