Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64...
[linux-2.6-microblaze.git] / include / linux / dma-debug.h
1 /*
2  * Copyright (C) 2008 Advanced Micro Devices, Inc.
3  *
4  * Author: Joerg Roedel <joerg.roedel@amd.com>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published
8  * by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18  */
19
20 #ifndef __DMA_DEBUG_H
21 #define __DMA_DEBUG_H
22
23 #include <linux/types.h>
24
25 struct device;
26 struct scatterlist;
27 struct bus_type;
28
29 #ifdef CONFIG_DMA_API_DEBUG
30
31 extern void dma_debug_add_bus(struct bus_type *bus);
32
33 extern int dma_debug_resize_entries(u32 num_entries);
34
35 extern void debug_dma_map_single(struct device *dev, const void *addr,
36                                  unsigned long len);
37
38 extern void debug_dma_map_page(struct device *dev, struct page *page,
39                                size_t offset, size_t size,
40                                int direction, dma_addr_t dma_addr,
41                                bool map_single);
42
43 extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
44
45 extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
46                                  size_t size, int direction, bool map_single);
47
48 extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
49                              int nents, int mapped_ents, int direction);
50
51 extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
52                                int nelems, int dir);
53
54 extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
55                                      dma_addr_t dma_addr, void *virt);
56
57 extern void debug_dma_free_coherent(struct device *dev, size_t size,
58                                     void *virt, dma_addr_t addr);
59
60 extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
61                                    size_t size, int direction,
62                                    dma_addr_t dma_addr);
63
64 extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
65                                      size_t size, int direction);
66
67 extern void debug_dma_sync_single_for_cpu(struct device *dev,
68                                           dma_addr_t dma_handle, size_t size,
69                                           int direction);
70
71 extern void debug_dma_sync_single_for_device(struct device *dev,
72                                              dma_addr_t dma_handle,
73                                              size_t size, int direction);
74
75 extern void debug_dma_sync_single_range_for_cpu(struct device *dev,
76                                                 dma_addr_t dma_handle,
77                                                 unsigned long offset,
78                                                 size_t size,
79                                                 int direction);
80
81 extern void debug_dma_sync_single_range_for_device(struct device *dev,
82                                                    dma_addr_t dma_handle,
83                                                    unsigned long offset,
84                                                    size_t size, int direction);
85
86 extern void debug_dma_sync_sg_for_cpu(struct device *dev,
87                                       struct scatterlist *sg,
88                                       int nelems, int direction);
89
90 extern void debug_dma_sync_sg_for_device(struct device *dev,
91                                          struct scatterlist *sg,
92                                          int nelems, int direction);
93
94 extern void debug_dma_dump_mappings(struct device *dev);
95
96 extern void debug_dma_assert_idle(struct page *page);
97
98 #else /* CONFIG_DMA_API_DEBUG */
99
100 static inline void dma_debug_add_bus(struct bus_type *bus)
101 {
102 }
103
104 static inline int dma_debug_resize_entries(u32 num_entries)
105 {
106         return 0;
107 }
108
109 static inline void debug_dma_map_single(struct device *dev, const void *addr,
110                                         unsigned long len)
111 {
112 }
113
114 static inline void debug_dma_map_page(struct device *dev, struct page *page,
115                                       size_t offset, size_t size,
116                                       int direction, dma_addr_t dma_addr,
117                                       bool map_single)
118 {
119 }
120
121 static inline void debug_dma_mapping_error(struct device *dev,
122                                           dma_addr_t dma_addr)
123 {
124 }
125
126 static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
127                                         size_t size, int direction,
128                                         bool map_single)
129 {
130 }
131
132 static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
133                                     int nents, int mapped_ents, int direction)
134 {
135 }
136
137 static inline void debug_dma_unmap_sg(struct device *dev,
138                                       struct scatterlist *sglist,
139                                       int nelems, int dir)
140 {
141 }
142
143 static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
144                                             dma_addr_t dma_addr, void *virt)
145 {
146 }
147
148 static inline void debug_dma_free_coherent(struct device *dev, size_t size,
149                                            void *virt, dma_addr_t addr)
150 {
151 }
152
153 static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
154                                           size_t size, int direction,
155                                           dma_addr_t dma_addr)
156 {
157 }
158
159 static inline void debug_dma_unmap_resource(struct device *dev,
160                                             dma_addr_t dma_addr, size_t size,
161                                             int direction)
162 {
163 }
164
165 static inline void debug_dma_sync_single_for_cpu(struct device *dev,
166                                                  dma_addr_t dma_handle,
167                                                  size_t size, int direction)
168 {
169 }
170
171 static inline void debug_dma_sync_single_for_device(struct device *dev,
172                                                     dma_addr_t dma_handle,
173                                                     size_t size, int direction)
174 {
175 }
176
177 static inline void debug_dma_sync_single_range_for_cpu(struct device *dev,
178                                                        dma_addr_t dma_handle,
179                                                        unsigned long offset,
180                                                        size_t size,
181                                                        int direction)
182 {
183 }
184
185 static inline void debug_dma_sync_single_range_for_device(struct device *dev,
186                                                           dma_addr_t dma_handle,
187                                                           unsigned long offset,
188                                                           size_t size,
189                                                           int direction)
190 {
191 }
192
193 static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
194                                              struct scatterlist *sg,
195                                              int nelems, int direction)
196 {
197 }
198
199 static inline void debug_dma_sync_sg_for_device(struct device *dev,
200                                                 struct scatterlist *sg,
201                                                 int nelems, int direction)
202 {
203 }
204
205 static inline void debug_dma_dump_mappings(struct device *dev)
206 {
207 }
208
209 static inline void debug_dma_assert_idle(struct page *page)
210 {
211 }
212
213 #endif /* CONFIG_DMA_API_DEBUG */
214
215 #endif /* __DMA_DEBUG_H */