Re: [PATCH v7 3/9] iommu: register the DMA channel bus for IOMMU notifications
From: Frank Li
Date: Mon Nov 16 2026 - 11:56:07 EST
On Mon, Nov 16, 2026 at 11:05:24AM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@xxxxxxx>
>
> DMA channel devices are about to be registered on a dedicated DMA channel
> bus so that they get a properly balanced bus association before
> device_register().
>
> Add that bus to iommu_buses[] so the IOMMU core installs its bus notifier
> for it. This allows of_dma_configure() to probe a per-channel IOMMU and,
> more importantly, lets BUS_NOTIFY_REMOVED_DEVICE release the IOMMU group
> and domain when the channel device is unregistered.
>
> The dmaengine bus is registered from a core_initcall, before any IOMMU
> driver can call iommu_device_register(), which iterates iommu_buses[] and
> fails if a bus has not been registered yet. Guard the entry with
> CONFIG_DMA_ENGINE because the bus does not exist when the DMA engine core
> is not built.
>
> Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> ---
Reviewed-by: Frank Li <Frank.Li@xxxxxxx>
> drivers/iommu/iommu.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index b486b8bbd1fc..ab31cd15d1d5 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -8,6 +8,7 @@
>
> #include <linux/amba/bus.h>
> #include <linux/device.h>
> +#include <linux/dmaengine.h>
> #include <linux/kernel.h>
> #include <linux/bits.h>
> #include <linux/bug.h>
> @@ -191,6 +192,9 @@ static const struct bus_type * const iommu_buses[] = {
> #ifdef CONFIG_ARM_AMBA
> &amba_bustype,
> #endif
> +#ifdef CONFIG_DMA_ENGINE
> + &dmaengine_chan_bus_type,
> +#endif
> #ifdef CONFIG_FSL_MC_BUS
> &fsl_mc_bus_type,
> #endif
>
> --
> 2.34.1
>