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.

x86: Use physical address for DMA mapping

Perform mechanical conversion from DMA .map_page to .map_phys.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Link: https://lore.kernel.org/r/20251015-remove-map-page-v5-12-3bbfe3a25cdf@kernel.org

authored by

Leon Romanovsky and committed by
Marek Szyprowski
33d2c5ee 38c0d0eb

+10 -9
+10 -9
arch/x86/kernel/amd_gart_64.c
··· 222 222 } 223 223 224 224 /* Map a single area into the IOMMU */ 225 - static dma_addr_t gart_map_page(struct device *dev, struct page *page, 226 - unsigned long offset, size_t size, 227 - enum dma_data_direction dir, 225 + static dma_addr_t gart_map_phys(struct device *dev, phys_addr_t paddr, 226 + size_t size, enum dma_data_direction dir, 228 227 unsigned long attrs) 229 228 { 230 229 unsigned long bus; 231 - phys_addr_t paddr = page_to_phys(page) + offset; 230 + 231 + if (unlikely(attrs & DMA_ATTR_MMIO)) 232 + return DMA_MAPPING_ERROR; 232 233 233 234 if (!need_iommu(dev, paddr, size)) 234 235 return paddr; ··· 243 242 /* 244 243 * Free a DMA mapping. 245 244 */ 246 - static void gart_unmap_page(struct device *dev, dma_addr_t dma_addr, 245 + static void gart_unmap_phys(struct device *dev, dma_addr_t dma_addr, 247 246 size_t size, enum dma_data_direction dir, 248 247 unsigned long attrs) 249 248 { ··· 283 282 for_each_sg(sg, s, nents, i) { 284 283 if (!s->dma_length || !s->length) 285 284 break; 286 - gart_unmap_page(dev, s->dma_address, s->dma_length, dir, 0); 285 + gart_unmap_phys(dev, s->dma_address, s->dma_length, dir, 0); 287 286 } 288 287 } 289 288 ··· 488 487 gart_free_coherent(struct device *dev, size_t size, void *vaddr, 489 488 dma_addr_t dma_addr, unsigned long attrs) 490 489 { 491 - gart_unmap_page(dev, dma_addr, size, DMA_BIDIRECTIONAL, 0); 490 + gart_unmap_phys(dev, dma_addr, size, DMA_BIDIRECTIONAL, 0); 492 491 dma_direct_free(dev, size, vaddr, dma_addr, attrs); 493 492 } 494 493 ··· 669 668 static const struct dma_map_ops gart_dma_ops = { 670 669 .map_sg = gart_map_sg, 671 670 .unmap_sg = gart_unmap_sg, 672 - .map_page = gart_map_page, 673 - .unmap_page = gart_unmap_page, 671 + .map_phys = gart_map_phys, 672 + .unmap_phys = gart_unmap_phys, 674 673 .alloc = gart_alloc_coherent, 675 674 .free = gart_free_coherent, 676 675 .mmap = dma_common_mmap,