blob: 30213adbb6b9d2c48432bc7d6b6d7b113a9fab81 [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
Stephen Boyd99c65fa2018-10-08 00:20:07 -070035extern void debug_dma_map_single(struct device *dev, const void *addr,
36 unsigned long len);
37
Joerg Roedelf62bc982009-01-09 14:14:49 +010038extern 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
Shuah Khan6c9c6d62012-10-08 11:08:06 -060043extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
44
Joerg Roedelf62bc982009-01-09 14:14:49 +010045extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
46 size_t size, int direction, bool map_single);
47
Joerg Roedel972aa452009-01-09 14:19:54 +010048extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
49 int nents, int mapped_ents, int direction);
50
51extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
52 int nelems, int dir);
Joerg Roedelf62bc982009-01-09 14:14:49 +010053
Joerg Roedel6bfd4492009-01-09 14:38:50 +010054extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
55 dma_addr_t dma_addr, void *virt);
56
57extern void debug_dma_free_coherent(struct device *dev, size_t size,
58 void *virt, dma_addr_t addr);
59
Niklas Söderlund0e74b342016-08-10 13:22:15 +020060extern 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
64extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
65 size_t size, int direction);
66
Joerg Roedelb9d23172009-01-09 14:43:04 +010067extern void debug_dma_sync_single_for_cpu(struct device *dev,
68 dma_addr_t dma_handle, size_t size,
69 int direction);
70
71extern void debug_dma_sync_single_for_device(struct device *dev,
72 dma_addr_t dma_handle,
73 size_t size, int direction);
74
Joerg Roedel948408b2009-01-09 14:55:38 +010075extern 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
81extern 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
Joerg Roedela31fba52009-01-09 15:01:12 +010086extern void debug_dma_sync_sg_for_cpu(struct device *dev,
87 struct scatterlist *sg,
88 int nelems, int direction);
89
90extern void debug_dma_sync_sg_for_device(struct device *dev,
91 struct scatterlist *sg,
92 int nelems, int direction);
93
David Woodhouseac26c182009-02-12 16:19:13 +010094extern void debug_dma_dump_mappings(struct device *dev);
95
Dan Williams0abdd7a2014-01-21 15:48:12 -080096extern void debug_dma_assert_idle(struct page *page);
97
Joerg Roedel6bf07872009-01-09 12:54:42 +010098#else /* CONFIG_DMA_API_DEBUG */
99
Ingo Molnar84be58d2009-03-18 11:50:29 +0100100static inline void dma_debug_add_bus(struct bus_type *bus)
Joerg Roedel41531c82009-03-16 17:32:14 +0100101{
102}
103
FUJITA Tomonorie6a1a892009-04-15 18:22:41 +0900104static inline int dma_debug_resize_entries(u32 num_entries)
105{
106 return 0;
107}
108
Stephen Boyd99c65fa2018-10-08 00:20:07 -0700109static inline void debug_dma_map_single(struct device *dev, const void *addr,
110 unsigned long len)
111{
112}
113
Joerg Roedelf62bc982009-01-09 14:14:49 +0100114static 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
Shuah Khan6c9c6d62012-10-08 11:08:06 -0600121static inline void debug_dma_mapping_error(struct device *dev,
122 dma_addr_t dma_addr)
123{
124}
125
Joerg Roedelf62bc982009-01-09 14:14:49 +0100126static 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
Joerg Roedel972aa452009-01-09 14:19:54 +0100132static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
133 int nents, int mapped_ents, int direction)
134{
135}
136
137static inline void debug_dma_unmap_sg(struct device *dev,
138 struct scatterlist *sglist,
139 int nelems, int dir)
140{
141}
Joerg Roedelf62bc982009-01-09 14:14:49 +0100142
Joerg Roedel6bfd4492009-01-09 14:38:50 +0100143static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
144 dma_addr_t dma_addr, void *virt)
145{
146}
147
148static inline void debug_dma_free_coherent(struct device *dev, size_t size,
149 void *virt, dma_addr_t addr)
150{
151}
152
Niklas Söderlund0e74b342016-08-10 13:22:15 +0200153static 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
159static inline void debug_dma_unmap_resource(struct device *dev,
160 dma_addr_t dma_addr, size_t size,
161 int direction)
162{
163}
164
Joerg Roedelb9d23172009-01-09 14:43:04 +0100165static 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
171static 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
Joerg Roedel948408b2009-01-09 14:55:38 +0100177static 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
185static 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
Joerg Roedela31fba52009-01-09 15:01:12 +0100193static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
194 struct scatterlist *sg,
195 int nelems, int direction)
196{
197}
198
199static inline void debug_dma_sync_sg_for_device(struct device *dev,
200 struct scatterlist *sg,
201 int nelems, int direction)
202{
203}
204
David Woodhouseac26c182009-02-12 16:19:13 +0100205static inline void debug_dma_dump_mappings(struct device *dev)
206{
207}
208
Dan Williams0abdd7a2014-01-21 15:48:12 -0800209static inline void debug_dma_assert_idle(struct page *page)
210{
211}
212
Joerg Roedel6bf07872009-01-09 12:54:42 +0100213#endif /* CONFIG_DMA_API_DEBUG */
214
Joerg Roedelf2f45e52009-01-09 12:19:52 +0100215#endif /* __DMA_DEBUG_H */