]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm: Drop HPAGE_PMD_SIZE dependency in dma_iova_try_alloc calls
authorFrancois Dugast <francois.dugast@intel.com>
Thu, 7 May 2026 09:16:06 +0000 (11:16 +0200)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 7 May 2026 18:07:36 +0000 (14:07 -0400)
The phys argument to dma_iova_try_alloc() is used only to compute
the sub-granule offset (phys & (granule - 1)). Since HPAGE_PMD_SIZE
is a power of two larger than any IOMMU granule, this expression
always evaluates to zero.

Replace the ternary expressions with a plain 0, which is what the
API documentation recommends for callers doing PAGE_SIZE-aligned
transfers. This also removes the dependency on HPAGE_PMD_SIZE and
thus on CONFIG_PGTABLE_HAS_HUGE_LEAVES / HAVE_ARCH_TRANSPARENT_HUGEPAGE,
fixing build failures on architectures such as arm32 that lack that
config.

Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Assisted-by: GitHub Copilot:claude-sonnet-4.6 # Documentation
Link: https://lore.kernel.org/intel-xe/c36e7dfb-cf62-4d21-a3b1-f54cb43e0832@infradead.org/
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://patch.msgid.link/20260507091606.1067973-1-francois.dugast@intel.com
Fixes: 2e0cd372b897 ("drm/pagemap: Use dma-map IOVA alloc, link, and sync API for DRM pagemap")
Fixes: 37ad039fb367 ("drm/gpusvm: Use dma-map IOVA alloc, link, and sync API in GPU SVM")
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/drm_gpusvm.c
drivers/gpu/drm/drm_pagemap.c

index 365a9c0b522a737c538021e1785fe21efb9842bb..958cb605aedd530733d426551351f0737c54f43c 100644 (file)
@@ -1556,10 +1556,7 @@ map_pages:
 
                        if (!i)
                                dma_iova_try_alloc(gpusvm->drm->dev, state,
-                                                  npages * PAGE_SIZE >=
-                                                  HPAGE_PMD_SIZE ?
-                                                  HPAGE_PMD_SIZE : 0,
-                                                  npages * PAGE_SIZE);
+                                                  0, npages * PAGE_SIZE);
 
                        if (dma_use_iova(state)) {
                                err = dma_iova_link(gpusvm->drm->dev, state,
index d82ea7ccb8da28642e1714aec7ffcce63fa1848f..15c78eca180b7b744051115d1d307818dd8b150e 100644 (file)
@@ -347,10 +347,7 @@ drm_pagemap_migrate_map_system_pages(struct device *dev,
 
                if (!try_alloc) {
                        dma_iova_try_alloc(dev, &state->dma_state,
-                                          (npages - i) * PAGE_SIZE >=
-                                          HPAGE_PMD_SIZE ?
-                                          HPAGE_PMD_SIZE : 0,
-                                          npages * PAGE_SIZE);
+                                          0, npages * PAGE_SIZE);
                        try_alloc = true;
                }