]> git.karo-electronics.de Git - karo-tx-linux.git/blob - include/asm-x86/dma-mapping_64.h
x86: move dma_unmap_single to common header
[karo-tx-linux.git] / include / asm-x86 / dma-mapping_64.h
1 #ifndef _X8664_DMA_MAPPING_H
2 #define _X8664_DMA_MAPPING_H 1
3
4 extern dma_addr_t bad_dma_address;
5 extern int iommu_merge;
6
7 static inline int dma_mapping_error(dma_addr_t dma_addr)
8 {
9         if (dma_ops->mapping_error)
10                 return dma_ops->mapping_error(dma_addr);
11
12         return (dma_addr == bad_dma_address);
13 }
14
15 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
16 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
17
18 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
19 #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
20
21 extern void *dma_alloc_coherent(struct device *dev, size_t size,
22                                 dma_addr_t *dma_handle, gfp_t gfp);
23 extern void dma_free_coherent(struct device *dev, size_t size, void *vaddr,
24                               dma_addr_t dma_handle);
25
26 #define dma_map_page(dev,page,offset,size,dir) \
27         dma_map_single((dev), page_address(page)+(offset), (size), (dir))
28
29 #define dma_unmap_page dma_unmap_single
30
31 static inline void
32 dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
33                         size_t size, int direction)
34 {
35         BUG_ON(!valid_dma_direction(direction));
36         if (dma_ops->sync_single_for_cpu)
37                 dma_ops->sync_single_for_cpu(hwdev, dma_handle, size,
38                                              direction);
39         flush_write_buffers();
40 }
41
42 static inline void
43 dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
44                            size_t size, int direction)
45 {
46         BUG_ON(!valid_dma_direction(direction));
47         if (dma_ops->sync_single_for_device)
48                 dma_ops->sync_single_for_device(hwdev, dma_handle, size,
49                                                 direction);
50         flush_write_buffers();
51 }
52
53 static inline void
54 dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
55                               unsigned long offset, size_t size, int direction)
56 {
57         BUG_ON(!valid_dma_direction(direction));
58         if (dma_ops->sync_single_range_for_cpu) {
59                 dma_ops->sync_single_range_for_cpu(hwdev, dma_handle, offset, size, direction);
60         }
61
62         flush_write_buffers();
63 }
64
65 static inline void
66 dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
67                                  unsigned long offset, size_t size, int direction)
68 {
69         BUG_ON(!valid_dma_direction(direction));
70         if (dma_ops->sync_single_range_for_device)
71                 dma_ops->sync_single_range_for_device(hwdev, dma_handle,
72                                                       offset, size, direction);
73
74         flush_write_buffers();
75 }
76
77 static inline void
78 dma_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg,
79                     int nelems, int direction)
80 {
81         BUG_ON(!valid_dma_direction(direction));
82         if (dma_ops->sync_sg_for_cpu)
83                 dma_ops->sync_sg_for_cpu(hwdev, sg, nelems, direction);
84         flush_write_buffers();
85 }
86
87 static inline void
88 dma_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg,
89                        int nelems, int direction)
90 {
91         BUG_ON(!valid_dma_direction(direction));
92         if (dma_ops->sync_sg_for_device) {
93                 dma_ops->sync_sg_for_device(hwdev, sg, nelems, direction);
94         }
95
96         flush_write_buffers();
97 }
98
99 static inline int
100 dma_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, int direction)
101 {
102         BUG_ON(!valid_dma_direction(direction));
103         return dma_ops->map_sg(hwdev, sg, nents, direction);
104 }
105
106 static inline void
107 dma_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents,
108              int direction)
109 {
110         BUG_ON(!valid_dma_direction(direction));
111         dma_ops->unmap_sg(hwdev, sg, nents, direction);
112 }
113
114 extern int dma_supported(struct device *hwdev, u64 mask);
115
116 /* same for gart, swiotlb, and nommu */
117 static inline int dma_get_cache_alignment(void)
118 {
119         return boot_cpu_data.x86_clflush_size;
120 }
121
122 #define dma_is_consistent(d, h) 1
123
124 extern int dma_set_mask(struct device *dev, u64 mask);
125
126 static inline void
127 dma_cache_sync(struct device *dev, void *vaddr, size_t size,
128         enum dma_data_direction dir)
129 {
130         flush_write_buffers();
131 }
132
133 extern struct device fallback_dev;
134 extern int panic_on_overflow;
135
136 #endif /* _X8664_DMA_MAPPING_H */