Skip to content

Commit 34dc0ea

Browse files
author
Christoph Hellwig
committed
dma-direct: provide mmap and get_sgtable method overrides
For dma-direct we know that the DMA address is an encoding of the physical address that we can trivially decode. Use that fact to provide implementations that do not need the arch_dma_coherent_to_pfn architecture hook. Note that we still can only support mmap of non-coherent memory only if the architecture provides a way to set an uncached bit in the page tables. This must be true for architectures that use the generic remap helpers, but other architectures can also manually select it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent 4e1003a commit 34dc0ea

16 files changed

Lines changed: 85 additions & 75 deletions

File tree

‎arch/arc/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
config ARC
77
def_bool y
88
select ARC_TIMERS
9-
select ARCH_HAS_DMA_COHERENT_TO_PFN
109
select ARCH_HAS_DMA_PREP_COHERENT
1110
select ARCH_HAS_PTE_SPECIAL
1211
select ARCH_HAS_SETUP_DMA_OPS

‎arch/arm/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ config ARM
77
select ARCH_HAS_BINFMT_FLAT
88
select ARCH_HAS_DEBUG_VIRTUAL if MMU
99
select ARCH_HAS_DEVMEM_IS_ALLOWED
10-
select ARCH_HAS_DMA_COHERENT_TO_PFN if SWIOTLB
1110
select ARCH_HAS_DMA_WRITE_COMBINE if !ARM_DMA_MEM_BUFFERABLE
1211
select ARCH_HAS_ELF_RANDOMIZE
1312
select ARCH_HAS_FORTIFY_SOURCE

‎arch/arm/mm/dma-mapping.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,12 +2346,6 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
23462346
size, dir);
23472347
}
23482348

2349-
long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,
2350-
dma_addr_t dma_addr)
2351-
{
2352-
return dma_to_pfn(dev, dma_addr);
2353-
}
2354-
23552349
void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
23562350
gfp_t gfp, unsigned long attrs)
23572351
{

‎arch/arm64/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ config ARM64
1212
select ARCH_CLOCKSOURCE_DATA
1313
select ARCH_HAS_DEBUG_VIRTUAL
1414
select ARCH_HAS_DEVMEM_IS_ALLOWED
15-
select ARCH_HAS_DMA_COHERENT_TO_PFN
1615
select ARCH_HAS_DMA_PREP_COHERENT
1716
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
1817
select ARCH_HAS_FAST_MULTIPLIER

‎arch/ia64/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ config IA64
3333
select HAVE_ARCH_TRACEHOOK
3434
select HAVE_MEMBLOCK_NODE_MAP
3535
select HAVE_VIRT_CPU_ACCOUNTING
36-
select ARCH_HAS_DMA_COHERENT_TO_PFN
36+
select DMA_NONCOHERENT_MMAP
3737
select ARCH_HAS_SYNC_DMA_FOR_CPU
3838
select VIRT_TO_BUS
3939
select GENERIC_IRQ_PROBE

‎arch/ia64/kernel/dma-mapping.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
1919
{
2020
dma_direct_free_pages(dev, size, cpu_addr, dma_addr, attrs);
2121
}
22-
23-
long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,
24-
dma_addr_t dma_addr)
25-
{
26-
return page_to_pfn(virt_to_page(cpu_addr));
27-
}

‎arch/microblaze/Kconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ config MICROBLAZE
44
select ARCH_32BIT_OFF_T
55
select ARCH_NO_SWAP
66
select ARCH_HAS_BINFMT_FLAT if !MMU
7-
select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU
87
select ARCH_HAS_DMA_PREP_COHERENT
98
select ARCH_HAS_GCOV_PROFILE_ALL
109
select ARCH_HAS_SYNC_DMA_FOR_CPU

‎arch/mips/Kconfig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,9 +1134,9 @@ config DMA_NONCOHERENT
11341134
select ARCH_HAS_DMA_WRITE_COMBINE
11351135
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
11361136
select ARCH_HAS_UNCACHED_SEGMENT
1137-
select NEED_DMA_MAP_STATE
1138-
select ARCH_HAS_DMA_COHERENT_TO_PFN
1137+
select DMA_NONCOHERENT_MMAP
11391138
select DMA_NONCOHERENT_CACHE_SYNC
1139+
select NEED_DMA_MAP_STATE
11401140

11411141
config SYS_HAS_EARLY_PRINTK
11421142
bool

‎arch/mips/mm/dma-noncoherent.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ void *cached_kernel_address(void *addr)
5959
return __va(addr) - UNCAC_BASE;
6060
}
6161

62-
long arch_dma_coherent_to_pfn(struct device *dev, void *cpu_addr,
63-
dma_addr_t dma_addr)
64-
{
65-
return page_to_pfn(virt_to_page(cached_kernel_address(cpu_addr)));
66-
}
67-
6862
static inline void dma_sync_virt(void *addr, size_t size,
6963
enum dma_data_direction dir)
7064
{

‎arch/powerpc/platforms/Kconfig.cputype‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ config NOT_COHERENT_CACHE
459459
bool
460460
depends on 4xx || PPC_8xx || E200 || PPC_MPC512x || \
461461
GAMECUBE_COMMON || AMIGAONE
462-
select ARCH_HAS_DMA_COHERENT_TO_PFN
463462
select ARCH_HAS_DMA_PREP_COHERENT
464463
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
465464
select ARCH_HAS_SYNC_DMA_FOR_CPU

0 commit comments

Comments
 (0)