From: Robin Murphy <robin.murphy@arm.com>
To: Mikko Perttunen <mperttunen@nvidia.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
"Joerg Roedel (AMD)" <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Heiko Stuebner <heiko@sntech.de>,
Thierry Reding <thierry.reding@kernel.org>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Jonathan Hunter <jonathanh@nvidia.com>,
Krishna Reddy <vdumpa@nvidia.com>,
Krzysztof Kozlowski <krzk@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>
Cc: Peter Griffin <peter.griffin@linaro.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Yong Wu <yong.wu@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Rob Clark <robin.clark@oss.qualcomm.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v2 07/11] iommu: Let 32-bit ARM drivers opt into a DMA API default domain
Date: Tue, 20 Oct 2026 12:28:54 +0100 [thread overview]
Message-ID: <be6cd787-8502-4499-ad62-597c1b9b7702@arm.com> (raw)
In-Reply-To: <20261016-b4-arm32-iommu-dma-cookie-v2-7-b06842a01938@nvidia.com>
On 16/10/2026 7:46 am, Mikko Perttunen wrote:
> iommu_get_default_domain_type() unconditionally forces IDENTITY on
> 32-bit ARM as ARM_DMA_USE_IOMMU installs its own UNMANAGED domain on top
> of whatever the group already had. Now that the ARM DMA API state is an
> ordinary domain cookie, IOMMU drivers can ask for a real
> IOMMU_DOMAIN_DMA default domain instead. Drop the override so that
> ->def_domain_type is honoured, and let a driver-requested DMA domain
> through the !CONFIG_IOMMU_DMA guard when ARM_DMA_USE_IOMMU can back it.
>
> IOMMU_DOMAIN_DMA stays strictly opt-in on 32-bit ARM and is never the
> fallback to avoid unexpected changes, as drivers today return 0 from
> ->def_domain_type while expecting the legacy behaviour.
>
> Behaviour is therefore unchanged for every existing 32-bit ARM IOMMU
> driver:
>
> - exynos-iommu, omap-iommu, rockchip-iommu, msm_iommu, ipmmu-vmsa,
> mtk_iommu*, sun50i-iommu and qcom_iommu have no ->def_domain_type,
> so iommu_get_def_domain_type() returns the unchanged cur_type of 0,
> which is forced to IDENTITY as before.
> - arm-smmu returns IDENTITY for legacy bindings and 0 otherwise, which
> ends up in the same place.
> - tegra-smmu returns IDENTITY explicitly, and keeps doing so until a
> later patch.
>
> Also move the static_assert on the two DMA API implementations being
> mutually exclusive to drivers/iommu/dma-iommu.h, next to the
> declarations that depend on it.
>
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
> drivers/iommu/dma-iommu.h | 3 +++
> drivers/iommu/iommu.c | 20 +++++---------------
> 2 files changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iommu/dma-iommu.h b/drivers/iommu/dma-iommu.h
> index 71b23cb698c0..24fa4165450f 100644
> --- a/drivers/iommu/dma-iommu.h
> +++ b/drivers/iommu/dma-iommu.h
> @@ -12,6 +12,9 @@
> * IOMMU_DOMAIN_DMA default domains. Only one provider can be compiled in at a
> * time.
> */
> +static_assert(!(IS_ENABLED(CONFIG_IOMMU_DMA) &&
> + IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)));
> +
Don't the first couple of patches already make this redundant, since
such a build would now fail anyway due to multiple definitions of
iommu_setup_dma_ops() etc.?
> #if defined(CONFIG_ARM_DMA_USE_IOMMU)
>
> #include <asm/dma-iommu.h>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 5fbb76d44a1e..0d812c4b9f08 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1884,18 +1884,6 @@ static int iommu_get_default_domain_type(struct iommu_group *group,
>
> lockdep_assert_held(&group->mutex);
>
> - /*
> - * ARM32 drivers supporting CONFIG_ARM_DMA_USE_IOMMU can declare an
> - * identity_domain and it will automatically become their default
> - * domain. Later on ARM_DMA_USE_IOMMU will install its UNMANAGED domain.
> - * Override the selection to IDENTITY.
> - */
> - if (IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)) {
> - static_assert(!(IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU) &&
> - IS_ENABLED(CONFIG_IOMMU_DMA)));
> - driver_type = IOMMU_DOMAIN_IDENTITY;
> - }
> -
> for_each_group_device(group, gdev) {
> driver_type = iommu_get_def_domain_type(group, gdev->dev,
> driver_type);
> @@ -1913,11 +1901,13 @@ static int iommu_get_default_domain_type(struct iommu_group *group,
>
> /*
> * If the common dma ops are not selected in kconfig then we cannot use
> - * IOMMU_DOMAIN_DMA at all. Force IDENTITY if nothing else has been
> - * selected.
> + * IOMMU_DOMAIN_DMA at all, unless this is ARM32 and the driver asked
> + * for it explicitly, where CONFIG_ARM_DMA_USE_IOMMU provides the
> + * implementation. Force IDENTITY if nothing else has been selected.
> */
> if (!IS_ENABLED(CONFIG_IOMMU_DMA)) {
> - if (WARN_ON(driver_type == IOMMU_DOMAIN_DMA))
> + if (WARN_ON(driver_type == IOMMU_DOMAIN_DMA &&
> + !IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)))
This ends up looking a bit odd, and not clear that it's still more or
less the same special-case workaround seemingly being removed in the
hunk above.
At this point I'd rather push any remaining identity special cases into
the relevant drivers, however I'm somewhat more confident that there may
not actually need to be any:
- exynos-iommu, omap-iommu, rockchip-iommu, msm_iommu: AFAICS these all
only ever have a single client device, so the per-group implicit domain
should be equivalent to the per-device explicit one, so they should not
be impacted by switching (provided the "throw away the ARM domain" idiom
in some of their client drivers becomes non-destructive as mentioned)
- mtk_iommu, sun50i-iommu, qcom_iommu, arm_smmu: While Kconfig might
allow building them, I'm not sure we really support the first 3 on
32-bit at all, but again since these all have no special CONFIG_ARM
group handling anyway then either they must work out as above or they're
already broken, and thus at most the change might un-break them.
- mtk_iommu_v1 and ipmmu-vmsa probably wouldn't care given that they end
up attaching to their own shared domain anyway - they just can't wait to
be able to use a proper singleton group to rip all that out :D
The main reason for forcing identity was to meet the expectations of the
existing ARM DMA ops setup, but if we're now touching the ARM code to
properly tie that in to the IOMMU flow, then I think we can just do the
right thing.
Thanks,
Robin.
> return -1;
> if (!driver_type)
> driver_type = IOMMU_DOMAIN_IDENTITY;
>
next prev parent reply other threads:[~2026-10-20 11:29 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 6:46 [PATCH v2 00/11] Make the 32-bit ARM DMA API work with normal IOMMU DMA default domains (+ Tegra PoC) Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 01/11] iommu: Add iommu_teardown_dma_ops Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 02/11] iommu: Add cookie type for ARM_DMA_USE_IOMMU Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 03/11] ARM: dma-mapping: Split mapping allocation from domain allocation Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 04/11] ARM: dma-mapping: Implement and expose DMA setup functions Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 05/11] ARM: dma-mapping: Bypass the legacy path for core-owned DMA API domains Mikko Perttunen
2026-10-19 16:55 ` Robin Murphy
2026-10-20 4:01 ` Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 06/11] ARM: dma-mapping: Handle foreign buffers in arm_iommu_get_sgtable Mikko Perttunen
2026-10-19 15:47 ` Robin Murphy
2026-10-20 3:55 ` Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 07/11] iommu: Let 32-bit ARM drivers opt into a DMA API default domain Mikko Perttunen
2026-10-20 11:28 ` Robin Murphy [this message]
2026-10-21 3:12 ` Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 08/11] iommu/tegra-smmu: Defer display client translation to driver handover Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 09/11] gpu: host1x: Drop release of legacy 32-bit ARM DMA domain Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 10/11] drm/tegra: " Mikko Perttunen
2026-10-16 6:46 ` [PATCH v2 11/11] iommu/tegra-smmu: Use a DMA API default domain per swgroup Mikko Perttunen
2026-10-20 15:30 ` Robin Murphy
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=be6cd787-8502-4499-ad62-597c1b9b7702@arm.com \
--to=robin.murphy@arm.com \
--cc=airlied@gmail.com \
--cc=alim.akhtar@samsung.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert+renesas@glider.be \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux.dev \
--cc=jernej.skrabec@gmail.com \
--cc=jgg@ziepe.ca \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=matthias.bgg@gmail.com \
--cc=mperttunen@nvidia.com \
--cc=peter.griffin@linaro.org \
--cc=robin.clark@oss.qualcomm.com \
--cc=samuel@sholland.org \
--cc=simona@ffwll.ch \
--cc=thierry.reding@kernel.org \
--cc=vdumpa@nvidia.com \
--cc=wens@kernel.org \
--cc=will@kernel.org \
--cc=yong.wu@mediatek.com \
/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
all inboxes | Powered by JetHome®