mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables
@ 2026-11-30 14:15 Sasha Levin
  2026-11-30 14:15 ` [PATCH 2/2] drm/msm: Fix the build without CONFIG_IOMMU_API Sasha Levin
  2026-11-30 15:05 ` [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables Konrad Dybcio
  0 siblings, 2 replies; 3+ messages in thread
From: Sasha Levin @ 2026-11-30 14:15 UTC (permalink / raw)
  To: Rob Clark
  Cc: Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
	dri-devel, freedreno, linux-kernel

struct map_ops has only function pointers, so CONFIG_RANDSTRUCT
randomizes its layout and it can't be initialized positionally. Builds
with RANDSTRUCT fail on both tables:

  drivers/gpu/drm/msm/msm_iommu.c:228:2: error: a randomized struct can only be initialized with a designated initializer
  drivers/gpu/drm/msm/msm_iommu.c:762:2: error: a randomized struct can only be initialized with a designated initializer

allmodconfig selects RANDSTRUCT_FULL when the compiler supports it and
no Rust toolchain is available, so KernelCI's allmodconfig builds
fail too.

Use designated initializers.

Fixes: aa20cf2a2960 ("drm/msm: Extract out map/unmap helpers")
Fixes: 1600c10eeda0 ("drm/msm: Convert iommu map/unmap to helpers")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/20261130033851.XvzzLGV5-lkp@intel.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Built drivers/gpu/drm/msm/msm_iommu.o with clang 21, x86_64 allmodconfig and
CONFIG_RANDSTRUCT_FULL=y on top of msm-next: fails before, builds after.

 drivers/gpu/drm/msm/msm_iommu.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index cc0856d4817d7..55655f25a1c75 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -225,7 +225,9 @@ __flush_pgtable(void *arg)
 }
 
 static const struct map_ops pgtable_ops = {
-	__unmap_pgtable, __map_pgtable, __flush_pgtable
+	.unmap = __unmap_pgtable,
+	.map = __map_pgtable,
+	.flush = __flush_pgtable,
 };
 
 static int msm_iommu_pagetable_unmap(struct msm_mmu *mmu, u64 iova, size_t size)
@@ -759,7 +761,9 @@ __flush_iommu(void *arg)
 }
 
 static const struct map_ops iommu_ops = {
-	__unmap_iommu, __map_iommu, __flush_iommu
+	.unmap = __unmap_iommu,
+	.map = __map_iommu,
+	.flush = __flush_iommu,
 };
 
 static int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova,

base-commit: dca2f1b25860f8caa0406f858e76a3a21671a012
-- 
2.53.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] drm/msm: Fix the build without CONFIG_IOMMU_API
  2026-11-30 14:15 [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables Sasha Levin
@ 2026-11-30 14:15 ` Sasha Levin
  2026-11-30 15:05 ` [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables Konrad Dybcio
  1 sibling, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-11-30 14:15 UTC (permalink / raw)
  To: Rob Clark
  Cc: Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
	dri-devel, freedreno, linux-kernel

__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 <sashal@kernel.org>
---
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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables
  2026-11-30 14:15 [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables Sasha Levin
  2026-11-30 14:15 ` [PATCH 2/2] drm/msm: Fix the build without CONFIG_IOMMU_API Sasha Levin
@ 2026-11-30 15:05 ` Konrad Dybcio
  1 sibling, 0 replies; 3+ messages in thread
From: Konrad Dybcio @ 2026-11-30 15:05 UTC (permalink / raw)
  To: Sasha Levin, Rob Clark
  Cc: Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
	dri-devel, freedreno, linux-kernel

On 11/30/26 3:15 PM, Sasha Levin wrote:
> struct map_ops has only function pointers, so CONFIG_RANDSTRUCT
> randomizes its layout and it can't be initialized positionally. Builds
> with RANDSTRUCT fail on both tables:
> 
>   drivers/gpu/drm/msm/msm_iommu.c:228:2: error: a randomized struct can only be initialized with a designated initializer
>   drivers/gpu/drm/msm/msm_iommu.c:762:2: error: a randomized struct can only be initialized with a designated initializer
> 
> allmodconfig selects RANDSTRUCT_FULL when the compiler supports it and
> no Rust toolchain is available, so KernelCI's allmodconfig builds
> fail too.
> 
> Use designated initializers.
> 
> Fixes: aa20cf2a2960 ("drm/msm: Extract out map/unmap helpers")
> Fixes: 1600c10eeda0 ("drm/msm: Convert iommu map/unmap to helpers")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/20261130033851.XvzzLGV5-lkp@intel.com/
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>

Konrad

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 14:15 [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables Sasha Levin
2026-11-30 14:15 ` [PATCH 2/2] drm/msm: Fix the build without CONFIG_IOMMU_API Sasha Levin
2026-11-30 15:05 ` [PATCH 1/2] drm/msm: Use designated initializers for the map_ops tables Konrad Dybcio

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®