diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/asm-generic/dma-mapping.h | 9 | ||||
| -rw-r--r-- | include/linux/dma-direct.h | 7 | ||||
| -rw-r--r-- | include/linux/dma-mapping.h | 1 | ||||
| -rw-r--r-- | include/linux/dma-noncoherent.h | 47 |
4 files changed, 63 insertions, 1 deletions
diff --git a/include/asm-generic/dma-mapping.h b/include/asm-generic/dma-mapping.h index 880a292d792f..ad2868263867 100644 --- a/include/asm-generic/dma-mapping.h +++ b/include/asm-generic/dma-mapping.h | |||
| @@ -4,7 +4,16 @@ | |||
| 4 | 4 | ||
| 5 | static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) | 5 | static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) |
| 6 | { | 6 | { |
| 7 | /* | ||
| 8 | * Use the non-coherent ops if available. If an architecture wants a | ||
| 9 | * more fine-grained selection of operations it will have to implement | ||
| 10 | * get_arch_dma_ops itself or use the per-device dma_ops. | ||
| 11 | */ | ||
| 12 | #ifdef CONFIG_DMA_NONCOHERENT_OPS | ||
| 13 | return &dma_noncoherent_ops; | ||
| 14 | #else | ||
| 7 | return &dma_direct_ops; | 15 | return &dma_direct_ops; |
| 16 | #endif | ||
| 8 | } | 17 | } |
| 9 | 18 | ||
| 10 | #endif /* _ASM_GENERIC_DMA_MAPPING_H */ | 19 | #endif /* _ASM_GENERIC_DMA_MAPPING_H */ |
diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h index 53ad6a47f513..8d9f33febde5 100644 --- a/include/linux/dma-direct.h +++ b/include/linux/dma-direct.h | |||
| @@ -59,6 +59,11 @@ void *dma_direct_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | |||
| 59 | gfp_t gfp, unsigned long attrs); | 59 | gfp_t gfp, unsigned long attrs); |
| 60 | void dma_direct_free(struct device *dev, size_t size, void *cpu_addr, | 60 | void dma_direct_free(struct device *dev, size_t size, void *cpu_addr, |
| 61 | dma_addr_t dma_addr, unsigned long attrs); | 61 | dma_addr_t dma_addr, unsigned long attrs); |
| 62 | dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, | ||
| 63 | unsigned long offset, size_t size, enum dma_data_direction dir, | ||
| 64 | unsigned long attrs); | ||
| 65 | int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, | ||
| 66 | enum dma_data_direction dir, unsigned long attrs); | ||
| 62 | int dma_direct_supported(struct device *dev, u64 mask); | 67 | int dma_direct_supported(struct device *dev, u64 mask); |
| 63 | 68 | int dma_direct_mapping_error(struct device *dev, dma_addr_t dma_addr); | |
| 64 | #endif /* _LINUX_DMA_DIRECT_H */ | 69 | #endif /* _LINUX_DMA_DIRECT_H */ |
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 25a9a2b04f78..4be070df5fc5 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
| @@ -136,6 +136,7 @@ struct dma_map_ops { | |||
| 136 | }; | 136 | }; |
| 137 | 137 | ||
| 138 | extern const struct dma_map_ops dma_direct_ops; | 138 | extern const struct dma_map_ops dma_direct_ops; |
| 139 | extern const struct dma_map_ops dma_noncoherent_ops; | ||
| 139 | extern const struct dma_map_ops dma_virt_ops; | 140 | extern const struct dma_map_ops dma_virt_ops; |
| 140 | 141 | ||
| 141 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) | 142 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) |
diff --git a/include/linux/dma-noncoherent.h b/include/linux/dma-noncoherent.h new file mode 100644 index 000000000000..10b2654d549b --- /dev/null +++ b/include/linux/dma-noncoherent.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
| 2 | #ifndef _LINUX_DMA_NONCOHERENT_H | ||
| 3 | #define _LINUX_DMA_NONCOHERENT_H 1 | ||
| 4 | |||
| 5 | #include <linux/dma-mapping.h> | ||
| 6 | |||
| 7 | void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, | ||
| 8 | gfp_t gfp, unsigned long attrs); | ||
| 9 | void arch_dma_free(struct device *dev, size_t size, void *cpu_addr, | ||
| 10 | dma_addr_t dma_addr, unsigned long attrs); | ||
| 11 | |||
| 12 | #ifdef CONFIG_DMA_NONCOHERENT_MMAP | ||
| 13 | int arch_dma_mmap(struct device *dev, struct vm_area_struct *vma, | ||
| 14 | void *cpu_addr, dma_addr_t dma_addr, size_t size, | ||
| 15 | unsigned long attrs); | ||
| 16 | #else | ||
| 17 | #define arch_dma_mmap NULL | ||
| 18 | #endif /* CONFIG_DMA_NONCOHERENT_MMAP */ | ||
| 19 | |||
| 20 | #ifdef CONFIG_DMA_NONCOHERENT_CACHE_SYNC | ||
| 21 | void arch_dma_cache_sync(struct device *dev, void *vaddr, size_t size, | ||
| 22 | enum dma_data_direction direction); | ||
| 23 | #else | ||
| 24 | #define arch_dma_cache_sync NULL | ||
| 25 | #endif /* CONFIG_DMA_NONCOHERENT_CACHE_SYNC */ | ||
| 26 | |||
| 27 | #ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_DEVICE | ||
| 28 | void arch_sync_dma_for_device(struct device *dev, phys_addr_t paddr, | ||
| 29 | size_t size, enum dma_data_direction dir); | ||
| 30 | #else | ||
| 31 | static inline void arch_sync_dma_for_device(struct device *dev, | ||
| 32 | phys_addr_t paddr, size_t size, enum dma_data_direction dir) | ||
| 33 | { | ||
| 34 | } | ||
| 35 | #endif /* ARCH_HAS_SYNC_DMA_FOR_DEVICE */ | ||
| 36 | |||
| 37 | #ifdef CONFIG_ARCH_HAS_SYNC_DMA_FOR_CPU | ||
| 38 | void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, | ||
| 39 | size_t size, enum dma_data_direction dir); | ||
| 40 | #else | ||
| 41 | static inline void arch_sync_dma_for_cpu(struct device *dev, | ||
| 42 | phys_addr_t paddr, size_t size, enum dma_data_direction dir) | ||
| 43 | { | ||
| 44 | } | ||
| 45 | #endif /* ARCH_HAS_SYNC_DMA_FOR_CPU */ | ||
| 46 | |||
| 47 | #endif /* _LINUX_DMA_NONCOHERENT_H */ | ||
