Re: [PATCH v1 1/2] iommu: export iommu_get_dma_domain()

From: Robin Murphy

Date: Mon Sep 28 2026 - 07:35:41 EST


On 28/09/2026 6:38 am, Jianfeng Liu wrote:
drm/msm needs to recover the physical address behind a DMA address of
imported dma-bufs: with CONFIG_DMABUF_DEBUG=y the attachment sg_table
it hands to importers carries no struct page, and msm has to translate
sg_dma_address() back to a physical address through the attaching
device's DMA-API domain to map such buffers into its own pagetables
(see the follow-up drm/msm patch).

Export the helper so modularized drivers can use it.

NAK. Read the comment - this is an internal helper for iommu-dma (currently the only IOMMU_DOMAIN_DMA implementation) and is definitely not for random drivers to abuse. In fact it should really move to iommu-priv.h now that we have that.

If you want to do sketchy things with your device's DMA domain then use the public iommu_get_domain_for_dev() interface like everyone else.

Thanks,
Robin.


Cc: Joerg Roedel <joro@xxxxxxxxxx>
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: iommu@xxxxxxxxxxxxxxx

Signed-off-by: Jianfeng Liu <liujianfeng1994@xxxxxxxxx>
---

drivers/iommu/iommu.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index cd1bca7ede9af..330f9a79248bd 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2327,6 +2327,7 @@ struct iommu_domain *iommu_get_dma_domain(struct device *dev)
{
return dev->iommu_group->default_domain;
}
+EXPORT_SYMBOL_GPL(iommu_get_dma_domain);
static void *iommu_make_pasid_array_entry(struct iommu_domain *domain,
struct iommu_attach_handle *handle)