Skip to content

Commit e4e3fff

Browse files
rleonmszyprow
authored andcommitted
MIPS/jazzdma: Provide physical address directly
MIPS jazz uses physical addresses for mapping pages, so convert it to get them directly from DMA mapping routine. 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-8-3bbfe3a25cdf@kernel.org
1 parent 6aaecdf commit e4e3fff

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

arch/mips/jazz/jazzdma.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,24 @@ static void jazz_dma_free(struct device *dev, size_t size, void *vaddr,
521521
__free_pages(virt_to_page(vaddr), get_order(size));
522522
}
523523

524-
static dma_addr_t jazz_dma_map_page(struct device *dev, struct page *page,
525-
unsigned long offset, size_t size, enum dma_data_direction dir,
526-
unsigned long attrs)
524+
static dma_addr_t jazz_dma_map_phys(struct device *dev, phys_addr_t phys,
525+
size_t size, enum dma_data_direction dir, unsigned long attrs)
527526
{
528-
phys_addr_t phys = page_to_phys(page) + offset;
527+
if (unlikely(attrs & DMA_ATTR_MMIO))
528+
/*
529+
* This check is included because older versions of the code lacked
530+
* MMIO path support, and my ability to test this path is limited.
531+
* However, from a software technical standpoint, there is no restriction,
532+
* as the following code operates solely on physical addresses.
533+
*/
534+
return DMA_MAPPING_ERROR;
529535

530536
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
531537
arch_sync_dma_for_device(phys, size, dir);
532538
return vdma_alloc(phys, size);
533539
}
534540

535-
static void jazz_dma_unmap_page(struct device *dev, dma_addr_t dma_addr,
541+
static void jazz_dma_unmap_phys(struct device *dev, dma_addr_t dma_addr,
536542
size_t size, enum dma_data_direction dir, unsigned long attrs)
537543
{
538544
if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
@@ -607,8 +613,8 @@ static void jazz_dma_sync_sg_for_cpu(struct device *dev,
607613
const struct dma_map_ops jazz_dma_ops = {
608614
.alloc = jazz_dma_alloc,
609615
.free = jazz_dma_free,
610-
.map_page = jazz_dma_map_page,
611-
.unmap_page = jazz_dma_unmap_page,
616+
.map_phys = jazz_dma_map_phys,
617+
.unmap_phys = jazz_dma_unmap_phys,
612618
.map_sg = jazz_dma_map_sg,
613619
.unmap_sg = jazz_dma_unmap_sg,
614620
.sync_single_for_cpu = jazz_dma_sync_single_for_cpu,

0 commit comments

Comments
 (0)