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>
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,
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;
}