blob: a785f25071592eabbd986d0b39498878520371ca [file] [log] [blame]
Joerg Roedelf2f45e52009-01-09 12:19:52 +01001/*
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
Joerg Roedel6bf07872009-01-09 12:54:42 +010023#include <linux/types.h>
24
Joerg Roedelf2f45e52009-01-09 12:19:52 +010025struct device;
Joerg Roedel972aa452009-01-09 14:19:54 +010026struct scatterlist;
Joerg Roedel41531c82009-03-16 17:32:14 +010027struct bus_type;
Joerg Roedelf2f45e52009-01-09 12:19:52 +010028
Joerg Roedel6bf07872009-01-09 12:54:42 +010029#ifdef CONFIG_DMA_API_DEBUG
30
Joerg Roedel41531c82009-03-16 17:32:14 +010031extern void dma_debug_add_bus(struct bus_type *bus);
32
FUJITA Tomonorie6a1a892009-04-15 18:22:41 +090033extern int dma_debug_resize_entries(u32 num_entries);
34
Joerg Roedelf62bc982009-01-09 14:14:49 +010035extern void debug_dma_map_page(struct device *dev, struct page *page,
36 size_t offset, size_t size,
37 int direction, dma_addr_t dma_addr,
38 bool map_single);
39
Shuah Khan6c9c6d62012-10-08 11:08:06 -060040extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
41
Joerg Roedelf62bc982009-01-09 14:14:49 +010042extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
43 size_t size, int direction, bool map_single);
44
Joerg Roedel972aa452009-01-09 14:19:54 +010045extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
46 int nents, int mapped_ents, int direction);
47
48extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
49 int nelems, int dir);
Joerg Roedelf62bc982009-01-09 14:14:49 +010050
Joerg Roedel6bfd4492009-01-09 14:38:50 +010051extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
52 dma_addr_t dma_addr, void *virt);
53
54extern void debug_dma_free_coherent(struct device *dev, size_t size,
55 void *virt, dma_addr_t addr);
56
Niklas Söderlund0e74b342016-08-10 13:22:15 +020057extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
58 size_t size, int direction,
59 dma_addr_t dma_addr);
60
61extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
62 size_t size, int direction);
63
Joerg Roedelb9d23172009-01-09 14:43:04 +010064extern void debug_dma_sync_single_for_cpu(struct device *dev,
65 dma_addr_t dma_handle, size_t size,
66 int direction);
67
68extern void debug_dma_sync_single_for_device(struct device *dev,
69 dma_addr_t dma_handle,
70 size_t size, int direction);
71
Joerg Roedel948408b2009-01-09 14:55:38 +010072extern void debug_dma_sync_single_range_for_cpu(struct device *dev,
73 dma_addr_t dma_handle,
74 unsigned long offset,
75 size_t size,
76 int direction);
77
78extern void debug_dma_sync_single_range_for_device(struct device *dev,
79 dma_addr_t dma_handle,
80 unsigned long offset,
81 size_t size, int direction);
82
Joerg Roedela31fba52009-01-09 15:01:12 +010083extern void debug_dma_sync_sg_for_cpu(struct device *dev,
84 struct scatterlist *sg,
85 int nelems, int direction);
86
87extern void debug_dma_sync_sg_for_device(struct device *dev,
88 struct scatterlist *sg,
89 int nelems, int direction);
90
David Woodhouseac26c182009-02-12 16:19:13 +010091extern void debug_dma_dump_mappings(struct device *dev);
92
Dan Williams0abdd7a2014-01-21 15:48:12 -080093extern void debug_dma_assert_idle(struct page *page);
94
Joerg Roedel6bf07872009-01-09 12:54:42 +010095#else /* CONFIG_DMA_API_DEBUG */
96
Ingo Molnar84be58d2009-03-18 11:50:29 +010097static inline void dma_debug_add_bus(struct bus_type *bus)
Joerg Roedel41531c82009-03-16 17:32:14 +010098{
99}
100
FUJITA Tomonorie6a1a892009-04-15 18:22:41 +0900101static inline int dma_debug_resize_entries(u32 num_entries)
102{
103 return 0;
104}
105
Joerg Roedelf62bc982009-01-09 14:14:49 +0100106static inline void debug_dma_map_page(struct device *dev, struct page *page,
107 size_t offset, size_t size,
108 int direction, dma_addr_t dma_addr,
109 bool map_single)
110{
111}
112
Shuah Khan6c9c6d62012-10-08 11:08:06 -0600113static inline void debug_dma_mapping_error(struct device *dev,
114 dma_addr_t dma_addr)
115{
116}
117
Joerg Roedelf62bc982009-01-09 14:14:49 +0100118static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
119 size_t size, int direction,
120 bool map_single)
121{
122}
123
Joerg Roedel972aa452009-01-09 14:19:54 +0100124static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
125 int nents, int mapped_ents, int direction)
126{
127}
128
129static inline void debug_dma_unmap_sg(struct device *dev,
130 struct scatterlist *sglist,
131 int nelems, int dir)
132{
133}
Joerg Roedelf62bc982009-01-09 14:14:49 +0100134
Joerg Roedel6bfd4492009-01-09 14:38:50 +0100135static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
136 dma_addr_t dma_addr, void *virt)
137{
138}
139
140static inline void debug_dma_free_coherent(struct device *dev, size_t size,
141 void *virt, dma_addr_t addr)
142{
143}
144
Niklas Söderlund0e74b342016-08-10 13:22:15 +0200145static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
146 size_t size, int direction,
147 dma_addr_t dma_addr)
148{
149}
150
151static inline void debug_dma_unmap_resource(struct device *dev,
152 dma_addr_t dma_addr, size_t size,
153 int direction)
154{
155}
156
Joerg Roedelb9d23172009-01-09 14:43:04 +0100157static inline void debug_dma_sync_single_for_cpu(struct device *dev,
158 dma_addr_t dma_handle,
159 size_t size, int direction)
160{
161}
162
163static inline void debug_dma_sync_single_for_device(struct device *dev,
164 dma_addr_t dma_handle,
165 size_t size, int direction)
166{
167}
168
Joerg Roedel948408b2009-01-09 14:55:38 +0100169static inline void debug_dma_sync_single_range_for_cpu(struct device *dev,
170 dma_addr_t dma_handle,
171 unsigned long offset,
172 size_t size,
173 int direction)
174{
175}
176
177static inline void debug_dma_sync_single_range_for_device(struct device *dev,
178 dma_addr_t dma_handle,
179 unsigned long offset,
180 size_t size,
181 int direction)
182{
183}
184
Joerg Roedela31fba52009-01-09 15:01:12 +0100185static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
186 struct scatterlist *sg,
187 int nelems, int direction)
188{
189}
190
191static inline void debug_dma_sync_sg_for_device(struct device *dev,
192 struct scatterlist *sg,
193 int nelems, int direction)
194{
195}
196
David Woodhouseac26c182009-02-12 16:19:13 +0100197static inline void debug_dma_dump_mappings(struct device *dev)
198{
199}
200
Dan Williams0abdd7a2014-01-21 15:48:12 -0800201static inline void debug_dma_assert_idle(struct page *page)
202{
203}
204
Joerg Roedel6bf07872009-01-09 12:54:42 +0100205#endif /* CONFIG_DMA_API_DEBUG */
206
Joerg Roedelf2f45e52009-01-09 12:19:52 +0100207#endif /* __DMA_DEBUG_H */