Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sparc: Fix page alignment in dma mapping

'phys' may include an offset within the page, while previously used
'base_paddr' was already page-aligned. This caused incorrect DMA mapping
in dma_4u_map_phys and dma_4v_map_phys.

Fix both functions by masking 'phys' with IO_PAGE_MASK, covering both
generic SPARC code and sun4v.

Fixes: 38c0d0ebf520 ("sparc: Use physical address DMA mapping")
Reported-by: Stian Halseth <stian@itx.no>
Closes: https://github.com/sparclinux/issues/issues/75
Suggested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Stian Halseth <stian@itx.no>
Tested-by: Nathaniel Roach <nroach44@nroach44.id.au>
Tested-by: Han Gao <gaohan@iscas.ac.cn> # on SPARC Enterprise T5220
[mszyprow: adjusted commit description a bit]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20260218120056.3366-2-stian@itx.no

authored by

Stian Halseth and committed by
Marek Szyprowski
d5b5e814 47322c46

+4
+2
arch/sparc/kernel/iommu.c
··· 312 312 if (direction != DMA_TO_DEVICE) 313 313 iopte_protection |= IOPTE_WRITE; 314 314 315 + phys &= IO_PAGE_MASK; 316 + 315 317 for (i = 0; i < npages; i++, base++, phys += IO_PAGE_SIZE) 316 318 iopte_val(*base) = iopte_protection | phys; 317 319
+2
arch/sparc/kernel/pci_sun4v.c
··· 410 410 411 411 iommu_batch_start(dev, prot, entry); 412 412 413 + phys &= IO_PAGE_MASK; 414 + 413 415 for (i = 0; i < npages; i++, phys += IO_PAGE_SIZE) { 414 416 long err = iommu_batch_add(phys, mask); 415 417 if (unlikely(err < 0L))