__map_iommu() and __unmap_iommu() call the domain's map_pages() and
unmap_pages() ops directly, but struct iommu_domain_ops is only defined
with CONFIG_IOMMU_API. imx_v6_v7_defconfig enables DRM_MSM without it
and fails to build:

  drivers/gpu/drm/msm/msm_iommu.c:742:27: error: invalid use of undefined type 
'const struct iommu_domain_ops'
  drivers/gpu/drm/msm/msm_iommu.c:750:27: error: invalid use of undefined type 
'const struct iommu_domain_ops'

Without CONFIG_IOMMU_API, iommu_paging_domain_alloc() always fails, so
msm_iommu_new() never creates an MMU and the two helpers can't be
reached. Give them stubs for that case.

Fixes: 1600c10eeda0 ("drm/msm: Convert iommu map/unmap to helpers")
Link: 
https://files.kernelci.org/kbuild-gcc-14-arm-imx_v6_v7_defconfig-6b0cabb2286e1965ecddf45b/build.log.gz
Signed-off-by: Sasha Levin <[email protected]>
---
Built drivers/gpu/drm/msm/msm_iommu.o with clang 21 and imx_v6_v7_defconfig on
top of msm-next: fails before, builds after. Also built with x86_64
allmodconfig (CONFIG_IOMMU_API=y). Not tested on hardware.

 drivers/gpu/drm/msm/msm_iommu.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index 55655f25a1c75..ff2e37f939780 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -737,6 +737,7 @@ static void msm_iommu_detach(struct msm_mmu *mmu)
        iommu_detach_device(iommu->domain, mmu->dev);
 }
 
+#ifdef CONFIG_IOMMU_API
 static size_t
 __unmap_iommu(void *arg, u64 iova, size_t pgsize, size_t pgcount)
 {
@@ -752,6 +753,21 @@ __map_iommu(void *arg, phys_addr_t paddr, u64 iova, size_t 
pgsize,
        return domain->ops->map_pages(domain, iova, paddr, pgsize, pgcount,
                                      prot, GFP_KERNEL, mapped);
 }
+#else
+/* No struct iommu_domain_ops, and msm_iommu_new() can't allocate a domain */
+static size_t
+__unmap_iommu(void *arg, u64 iova, size_t pgsize, size_t pgcount)
+{
+       return 0;
+}
+
+static int
+__map_iommu(void *arg, phys_addr_t paddr, u64 iova, size_t pgsize,
+           size_t pgcount, int prot, size_t *mapped)
+{
+       return -ENODEV;
+}
+#endif
 
 static void
 __flush_iommu(void *arg)
-- 
2.53.0

Reply via email to