From: Francois Dugast Date: Thu, 7 May 2026 09:16:06 +0000 (+0200) Subject: drm: Drop HPAGE_PMD_SIZE dependency in dma_iova_try_alloc calls X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9175f49330d199c03eb970f799526c9d479b5f1a;p=thirdparty%2Fkernel%2Flinux.git drm: Drop HPAGE_PMD_SIZE dependency in dma_iova_try_alloc calls 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 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 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 --- diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c index 365a9c0b522a7..958cb605aedd5 100644 --- a/drivers/gpu/drm/drm_gpusvm.c +++ b/drivers/gpu/drm/drm_gpusvm.c @@ -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, diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c index d82ea7ccb8da2..15c78eca180b7 100644 --- a/drivers/gpu/drm/drm_pagemap.c +++ b/drivers/gpu/drm/drm_pagemap.c @@ -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; }