Skip to content

Commit bc3ec75

Browse files
author
Christoph Hellwig
committed
dma-mapping: merge direct and noncoherent ops
All the cache maintainance is already stubbed out when not enabled, but merging the two allows us to nicely handle the case where cache maintainance is required for some devices, but not others. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Paul Burton <paul.burton@mips.com> # MIPS parts
1 parent f3ecc0f commit bc3ec75

29 files changed

Lines changed: 160 additions & 192 deletions

File tree

arch/arc/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ config ARC
1717
select BUILDTIME_EXTABLE_SORT
1818
select CLONE_BACKWARDS
1919
select COMMON_CLK
20-
select DMA_NONCOHERENT_OPS
20+
select DMA_DIRECT_OPS
2121
select DMA_NONCOHERENT_MMAP
2222
select GENERIC_ATOMIC64 if !ISA_ARCV2 || !(ARC_HAS_LL64 && ARC_HAS_LLSC)
2323
select GENERIC_CLOCKEVENTS

arch/arc/mm/dma.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,21 +167,19 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr,
167167
}
168168

169169
/*
170-
* Plug in coherent or noncoherent dma ops
170+
* Plug in direct dma map ops.
171171
*/
172172
void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size,
173173
const struct iommu_ops *iommu, bool coherent)
174174
{
175175
/*
176176
* IOC hardware snoops all DMA traffic keeping the caches consistent
177177
* with memory - eliding need for any explicit cache maintenance of
178-
* DMA buffers - so we can use dma_direct cache ops.
178+
* DMA buffers.
179179
*/
180-
if (is_isa_arcv2() && ioc_enable && coherent) {
181-
set_dma_ops(dev, &dma_direct_ops);
182-
dev_info(dev, "use dma_direct_ops cache ops\n");
183-
} else {
184-
set_dma_ops(dev, &dma_noncoherent_ops);
185-
dev_info(dev, "use dma_noncoherent_ops cache ops\n");
186-
}
180+
if (is_isa_arcv2() && ioc_enable && coherent)
181+
dev->dma_coherent = true;
182+
183+
dev_info(dev, "use %sncoherent DMA ops\n",
184+
dev->dma_coherent ? "" : "non");
187185
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ static void *arm_nommu_dma_alloc(struct device *dev, size_t size,
4747
*/
4848

4949
if (attrs & DMA_ATTR_NON_CONSISTENT)
50-
return dma_direct_alloc(dev, size, dma_handle, gfp, attrs);
50+
return dma_direct_alloc_pages(dev, size, dma_handle, gfp,
51+
attrs);
5152

5253
ret = dma_alloc_from_global_coherent(size, dma_handle);
5354

@@ -70,7 +71,7 @@ static void arm_nommu_dma_free(struct device *dev, size_t size,
7071
unsigned long attrs)
7172
{
7273
if (attrs & DMA_ATTR_NON_CONSISTENT) {
73-
dma_direct_free(dev, size, cpu_addr, dma_addr, attrs);
74+
dma_direct_free_pages(dev, size, cpu_addr, dma_addr, attrs);
7475
} else {
7576
int ret = dma_release_from_global_coherent(get_order(size),
7677
cpu_addr);

arch/c6x/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config C6X
99
select ARCH_HAS_SYNC_DMA_FOR_CPU
1010
select ARCH_HAS_SYNC_DMA_FOR_DEVICE
1111
select CLKDEV_LOOKUP
12-
select DMA_NONCOHERENT_OPS
12+
select DMA_DIRECT_OPS
1313
select GENERIC_ATOMIC64
1414
select GENERIC_IRQ_SHOW
1515
select HAVE_ARCH_TRACEHOOK

arch/hexagon/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ config HEXAGON
3030
select GENERIC_CLOCKEVENTS_BROADCAST
3131
select MODULES_USE_ELF_RELA
3232
select GENERIC_CPU_DEVICES
33-
select DMA_NONCOHERENT_OPS
33+
select DMA_DIRECT_OPS
3434
---help---
3535
Qualcomm Hexagon is a processor architecture designed for high
3636
performance and low power across a wide variety of applications.

arch/m68k/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ config M68K
2626
select MODULES_USE_ELF_RELA
2727
select OLD_SIGSUSPEND3
2828
select OLD_SIGACTION
29-
select DMA_NONCOHERENT_OPS if HAS_DMA
29+
select DMA_DIRECT_OPS if HAS_DMA
3030
select HAVE_MEMBLOCK
3131
select ARCH_DISCARD_MEMBLOCK
3232
select NO_BOOTMEM

arch/microblaze/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ config MICROBLAZE
1111
select TIMER_OF
1212
select CLONE_BACKWARDS3
1313
select COMMON_CLK
14-
select DMA_NONCOHERENT_OPS
14+
select DMA_DIRECT_OPS
1515
select DMA_NONCOHERENT_MMAP
1616
select GENERIC_ATOMIC64
1717
select GENERIC_CLOCKEVENTS

arch/mips/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,6 @@ config DMA_NONCOHERENT
11211121
select NEED_DMA_MAP_STATE
11221122
select DMA_NONCOHERENT_MMAP
11231123
select DMA_NONCOHERENT_CACHE_SYNC
1124-
select DMA_NONCOHERENT_OPS
11251124

11261125
config SYS_HAS_EARLY_PRINTK
11271126
bool

arch/mips/include/asm/dma-mapping.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
1212
return &jazz_dma_ops;
1313
#elif defined(CONFIG_SWIOTLB)
1414
return &swiotlb_dma_ops;
15-
#elif defined(CONFIG_DMA_NONCOHERENT_OPS)
16-
return &dma_noncoherent_ops;
1715
#else
1816
return &dma_direct_ops;
1917
#endif

arch/mips/jazz/jazzdma.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -564,13 +564,13 @@ static void *jazz_dma_alloc(struct device *dev, size_t size,
564564
{
565565
void *ret;
566566

567-
ret = dma_direct_alloc(dev, size, dma_handle, gfp, attrs);
567+
ret = dma_direct_alloc_pages(dev, size, dma_handle, gfp, attrs);
568568
if (!ret)
569569
return NULL;
570570

571571
*dma_handle = vdma_alloc(virt_to_phys(ret), size);
572572
if (*dma_handle == VDMA_ERROR) {
573-
dma_direct_free(dev, size, ret, *dma_handle, attrs);
573+
dma_direct_free_pages(dev, size, ret, *dma_handle, attrs);
574574
return NULL;
575575
}
576576

@@ -587,7 +587,7 @@ static void jazz_dma_free(struct device *dev, size_t size, void *vaddr,
587587
vdma_free(dma_handle);
588588
if (!(attrs & DMA_ATTR_NON_CONSISTENT))
589589
vaddr = (void *)CAC_ADDR((unsigned long)vaddr);
590-
return dma_direct_free(dev, size, vaddr, dma_handle, attrs);
590+
dma_direct_free_pages(dev, size, vaddr, dma_handle, attrs);
591591
}
592592

593593
static dma_addr_t jazz_dma_map_page(struct device *dev, struct page *page,

0 commit comments

Comments
 (0)