DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: imx@lists.linux.dev, dmaengine@vger.kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v3 3/7] iommu: register the DMA channel bus for IOMMU notifications
Date: Mon, 02 Nov 2026 07:03:42 +0000	[thread overview]
Message-ID: <sashiko-outbox-192996@kernel.org> (raw)
In-Reply-To: <20261102-edma-iommu-v3-v3-3-9d0e62a954eb@Example.Com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] iommu: iommu_device_register() fails before arch_initcall(dma_bus_init)
--

commit 9240bcc4b7e8d99a1e2af1ff943ce2458c2e21eb
Author: Peng Fan <peng.fan@nxp.com>

iommu: register the DMA channel bus for IOMMU notifications

This commit adds dma_chan_bus_type (guarded by CONFIG_DMA_ENGINE) to
iommu_buses[] so the IOMMU core installs its bus notifier for DMA channel
devices.

> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index b486b8bbd1fcd..6fa871bbd63ad 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c

[ ... ]

> @@ -191,6 +192,9 @@ static const struct bus_type * const iommu_buses[] = {
>  #ifdef CONFIG_ARM_AMBA
>  	&amba_bustype,
>  #endif
> +#ifdef CONFIG_DMA_ENGINE
> +	&dma_chan_bus_type,
> +#endif

[Severity: High]
Could this cause iommu_device_register() to fail when called before
arch_initcall(dma_bus_init)?

The commit message notes that dma_chan_bus_type is registered at
arch_initcall before iommu_subsys_init() runs at subsys_initcall, but
iommu_buses[] is also iterated by iommu_device_register():

drivers/iommu/iommu.c:iommu_device_register() {
	...
	for (int i = 0; i < ARRAY_SIZE(iommu_buses) && !err; i++)
		err = bus_iommu_probe(iommu_buses[i]);
	if (err)
		iommu_device_unregister(iommu);
	...
}

And bus_iommu_probe() calls bus_for_each_dev(), which returns -EINVAL if
the bus has not been registered via bus_register() yet:

drivers/base/bus.c:bus_for_each_dev() {
	struct subsys_private *sp = bus_to_subsys(bus);
	...
	if (!sp)
		return -EINVAL;
}

Every other bus in iommu_buses[] is registered at postcore_initcall or
earlier. On PowerPC, spapr_tce_setup_phb_iommus_initcall() registers PHB
IOMMU devices at postcore_initcall_sync, before arch_initcall(dma_bus_init):

arch/powerpc/kernel/iommu.c:spapr_tce_setup_phb_iommus_initcall() {
	struct pci_controller *hose;

	list_for_each_entry(hose, &hose_list, list_node) {
		ppc_iommu_register_device(hose);
	}
	return 0;
}
postcore_initcall_sync(spapr_tce_setup_phb_iommus_initcall);

When CONFIG_DMA_ENGINE=y, wouldn't bus_iommu_probe(&dma_chan_bus_type)
return -EINVAL during spapr_tce_setup_phb_iommus_initcall(), causing
iommu_device_register() to unregister all PHB IOMMU devices?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261102-edma-iommu-v3-v3-0-9d0e62a954eb@Example.Com?part=3

  reply	other threads:[~2026-11-02  7:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  6:49 [PATCH v3 0/7] dmaengine: add DMA channel bus and fsl-edma per-channel IOMMU support Peng Fan (OSS)
2026-11-02  6:49 ` [PATCH v3 1/7] dmaengine: fsl-edma: unregister channels before vchan cleanup Peng Fan (OSS)
2026-11-02  6:49 ` [PATCH v3 2/7] dmaengine: add a bus for DMA channel devices Peng Fan (OSS)
2026-11-02  7:02   ` sashiko-bot
2026-11-02  6:49 ` [PATCH v3 3/7] iommu: register the DMA channel bus for IOMMU notifications Peng Fan (OSS)
2026-11-02  7:03   ` sashiko-bot [this message]
2026-11-02  6:49 ` [PATCH v3 4/7] dmaengine: move channel devices to the DMA channel bus Peng Fan (OSS)
2026-11-02  6:49 ` [PATCH v3 5/7] dt-bindings: dma: fsl,edma: add per-channel child node support Peng Fan (OSS)
2026-11-02  6:50 ` [PATCH v3 6/7] dmaengine: fsl-edma: support per-channel DT child nodes Peng Fan (OSS)
2026-11-02  7:10   ` sashiko-bot
2026-11-02  6:50 ` [PATCH v3 7/7] arm64: dts: imx95: convert eDMA to per-channel " Peng Fan (OSS)
2026-11-02  7:00   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-192996@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=peng.fan@oss.nxp.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox