Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
ccfe27d7 MS |
2 | /* |
3 | * Copyright (C) 2009-2010 PetaLogix | |
4 | * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corporation | |
5 | * | |
6 | * Provide default implementations of the DMA mapping callbacks for | |
7 | * directly mapped busses. | |
8 | */ | |
9 | ||
10 | #include <linux/device.h> | |
5411ad27 | 11 | #include <linux/dma-noncoherent.h> |
5a0e3ad6 | 12 | #include <linux/gfp.h> |
ccfe27d7 | 13 | #include <linux/dma-debug.h> |
66421a64 | 14 | #include <linux/export.h> |
6bd55f0b | 15 | #include <linux/bug.h> |
64dc8700 | 16 | #include <asm/cacheflush.h> |
ccfe27d7 | 17 | |
5411ad27 CH |
18 | static void __dma_sync(struct device *dev, phys_addr_t paddr, size_t size, |
19 | enum dma_data_direction direction) | |
64dc8700 CH |
20 | { |
21 | switch (direction) { | |
22 | case DMA_TO_DEVICE: | |
23 | case DMA_BIDIRECTIONAL: | |
24 | flush_dcache_range(paddr, paddr + size); | |
25 | break; | |
26 | case DMA_FROM_DEVICE: | |
27 | invalidate_dcache_range(paddr, paddr + size); | |
28 | break; | |
29 | default: | |
30 | BUG(); | |
31 | } | |
32 | } | |
33 | ||
5411ad27 CH |
34 | void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr, |
35 | size_t size, enum dma_data_direction dir) | |
ccfe27d7 | 36 | { |
5411ad27 | 37 | __dma_sync(dev, paddr, size, dir); |
ccfe27d7 MS |
38 | } |
39 | ||
5411ad27 CH |
40 | void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, |
41 | size_t size, enum dma_data_direction dir) | |
ccfe27d7 | 42 | { |
5411ad27 | 43 | __dma_sync(dev, paddr, size, dir); |
ccfe27d7 | 44 | } |