1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _LINUX_DMA_MAPPING_H 3 #define _LINUX_DMA_MAPPING_H 4 5 #ifdef CONFIG_HAS_DMA 6 # error Virtio userspace code does not support CONFIG_HAS_DMA 7 #endif 8 9 enum dma_data_direction { 10 DMA_BIDIRECTIONAL = 0, 11 DMA_TO_DEVICE = 1, 12 DMA_FROM_DEVICE = 2, 13 DMA_NONE = 3, 14 }; 15 16 #define dma_alloc_coherent(d, s, hp, f) ({ \ 17 void *__dma_alloc_coherent_p = kmalloc((s), (f)); \ 18 *(hp) = (unsigned long)__dma_alloc_coherent_p; \ 19 __dma_alloc_coherent_p; \ 20 }) 21 22 #define dma_free_coherent(d, s, p, h) kfree(p) 23 24 #define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o)) 25 #define dma_map_page_attrs(d, p, o, s, dir, a) (page_to_phys(p) + (o)) 26 27 #define dma_map_single(d, p, s, dir) (virt_to_phys(p)) 28 #define dma_map_single_attrs(d, p, s, dir, a) (virt_to_phys(p)) 29 #define dma_mapping_error(...) (0) 30 31 #define dma_unmap_single(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0) 32 #define dma_unmap_page(d, a, s, r) do { (void)(d); (void)(a); (void)(s); (void)(r); } while (0) 33 #define dma_unmap_page_attrs(d, a, s, r, t) do { \ 34 (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \ 35 } while (0) 36 37 #define sg_dma_address(sg) (0) 38 #define sg_dma_len(sg) (0) 39 #define dma_need_sync(v, a) (0) 40 #define dma_unmap_single_attrs(d, a, s, r, t) do { \ 41 (void)(d); (void)(a); (void)(s); (void)(r); (void)(t); \ 42 } while (0) 43 #define dma_sync_single_range_for_cpu(d, a, o, s, r) do { \ 44 (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \ 45 } while (0) 46 #define dma_sync_single_range_for_device(d, a, o, s, r) do { \ 47 (void)(d); (void)(a); (void)(o); (void)(s); (void)(r); \ 48 } while (0) 49 #define dma_max_mapping_size(...) SIZE_MAX 50 51 /* 52 * A dma_addr_t can hold any valid DMA or bus address for the platform. It can 53 * be given to a device to use as a DMA source or target. It is specific to a 54 * given device and there may be a translation between the CPU physical address 55 * space and the bus address space. 56 * 57 * DMA_MAPPING_ERROR is the magic error code if a mapping failed. It should not 58 * be used directly in drivers, but checked for using dma_mapping_error() 59 * instead. 60 */ 61 #define DMA_MAPPING_ERROR (~(dma_addr_t)0) 62 63 #define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11) 64 65 #endif 66