diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 16:41:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-03-30 16:41:00 -0400 |
commit | 712b0006bf3a9ed0b14a56c3291975e582127766 (patch) | |
tree | aff33e947673137ae21734321e1f036600297223 /include | |
parent | e1c502482853f84606928f5a2f2eb6da1993cda1 (diff) | |
parent | b0d44c0dbbd52effb731b1c0af9afd56215c48de (diff) |
Merge branch 'iommu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'iommu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (60 commits)
dma-debug: make memory range checks more consistent
dma-debug: warn of unmapping an invalid dma address
dma-debug: fix dma_debug_add_bus() definition for !CONFIG_DMA_API_DEBUG
dma-debug/x86: register pci bus for dma-debug leak detection
dma-debug: add a check dma memory leaks
dma-debug: add checks for kernel text and rodata
dma-debug: print stacktrace of mapping path on unmap error
dma-debug: Documentation update
dma-debug: x86 architecture bindings
dma-debug: add function to dump dma mappings
dma-debug: add checks for sync_single_sg_*
dma-debug: add checks for sync_single_range_*
dma-debug: add checks for sync_single_*
dma-debug: add checking for [alloc|free]_coherent
dma-debug: add add checking for map/unmap_sg
dma-debug: add checking for map/unmap_page/single
dma-debug: add core checking functions
dma-debug: add debugfs interface
dma-debug: add kernel command line parameters
dma-debug: add initialization code
...
Fix trivial conflicts due to whitespace changes in arch/x86/kernel/pci-nommu.c
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/dma-debug.h | 174 | ||||
-rw-r--r-- | include/linux/dma-mapping.h | 48 | ||||
-rw-r--r-- | include/linux/intel-iommu.h | 7 | ||||
-rw-r--r-- | include/linux/swiotlb.h | 41 |
4 files changed, 240 insertions, 30 deletions
diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h new file mode 100644 index 000000000000..28d53cb7b5a2 --- /dev/null +++ b/include/linux/dma-debug.h | |||
@@ -0,0 +1,174 @@ | |||
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 void dma_debug_init(u32 num_entries); | ||
34 | |||
35 | extern 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 | |||
40 | extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, | ||
41 | size_t size, int direction, bool map_single); | ||
42 | |||
43 | extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, | ||
44 | int nents, int mapped_ents, int direction); | ||
45 | |||
46 | extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, | ||
47 | int nelems, int dir); | ||
48 | |||
49 | extern void debug_dma_alloc_coherent(struct device *dev, size_t size, | ||
50 | dma_addr_t dma_addr, void *virt); | ||
51 | |||
52 | extern void debug_dma_free_coherent(struct device *dev, size_t size, | ||
53 | void *virt, dma_addr_t addr); | ||
54 | |||
55 | extern void debug_dma_sync_single_for_cpu(struct device *dev, | ||
56 | dma_addr_t dma_handle, size_t size, | ||
57 | int direction); | ||
58 | |||
59 | extern void debug_dma_sync_single_for_device(struct device *dev, | ||
60 | dma_addr_t dma_handle, | ||
61 | size_t size, int direction); | ||
62 | |||
63 | extern void debug_dma_sync_single_range_for_cpu(struct device *dev, | ||
64 | dma_addr_t dma_handle, | ||
65 | unsigned long offset, | ||
66 | size_t size, | ||
67 | int direction); | ||
68 | |||
69 | extern void debug_dma_sync_single_range_for_device(struct device *dev, | ||
70 | dma_addr_t dma_handle, | ||
71 | unsigned long offset, | ||
72 | size_t size, int direction); | ||
73 | |||
74 | extern void debug_dma_sync_sg_for_cpu(struct device *dev, | ||
75 | struct scatterlist *sg, | ||
76 | int nelems, int direction); | ||
77 | |||
78 | extern void debug_dma_sync_sg_for_device(struct device *dev, | ||
79 | struct scatterlist *sg, | ||
80 | int nelems, int direction); | ||
81 | |||
82 | extern void debug_dma_dump_mappings(struct device *dev); | ||
83 | |||
84 | #else /* CONFIG_DMA_API_DEBUG */ | ||
85 | |||
86 | static inline void dma_debug_add_bus(struct bus_type *bus) | ||
87 | { | ||
88 | } | ||
89 | |||
90 | static inline void dma_debug_init(u32 num_entries) | ||
91 | { | ||
92 | } | ||
93 | |||
94 | static inline void debug_dma_map_page(struct device *dev, struct page *page, | ||
95 | size_t offset, size_t size, | ||
96 | int direction, dma_addr_t dma_addr, | ||
97 | bool map_single) | ||
98 | { | ||
99 | } | ||
100 | |||
101 | static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, | ||
102 | size_t size, int direction, | ||
103 | bool map_single) | ||
104 | { | ||
105 | } | ||
106 | |||
107 | static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, | ||
108 | int nents, int mapped_ents, int direction) | ||
109 | { | ||
110 | } | ||
111 | |||
112 | static inline void debug_dma_unmap_sg(struct device *dev, | ||
113 | struct scatterlist *sglist, | ||
114 | int nelems, int dir) | ||
115 | { | ||
116 | } | ||
117 | |||
118 | static inline void debug_dma_alloc_coherent(struct device *dev, size_t size, | ||
119 | dma_addr_t dma_addr, void *virt) | ||
120 | { | ||
121 | } | ||
122 | |||
123 | static inline void debug_dma_free_coherent(struct device *dev, size_t size, | ||
124 | void *virt, dma_addr_t addr) | ||
125 | { | ||
126 | } | ||
127 | |||
128 | static inline void debug_dma_sync_single_for_cpu(struct device *dev, | ||
129 | dma_addr_t dma_handle, | ||
130 | size_t size, int direction) | ||
131 | { | ||
132 | } | ||
133 | |||
134 | static inline void debug_dma_sync_single_for_device(struct device *dev, | ||
135 | dma_addr_t dma_handle, | ||
136 | size_t size, int direction) | ||
137 | { | ||
138 | } | ||
139 | |||
140 | static inline void debug_dma_sync_single_range_for_cpu(struct device *dev, | ||
141 | dma_addr_t dma_handle, | ||
142 | unsigned long offset, | ||
143 | size_t size, | ||
144 | int direction) | ||
145 | { | ||
146 | } | ||
147 | |||
148 | static inline void debug_dma_sync_single_range_for_device(struct device *dev, | ||
149 | dma_addr_t dma_handle, | ||
150 | unsigned long offset, | ||
151 | size_t size, | ||
152 | int direction) | ||
153 | { | ||
154 | } | ||
155 | |||
156 | static inline void debug_dma_sync_sg_for_cpu(struct device *dev, | ||
157 | struct scatterlist *sg, | ||
158 | int nelems, int direction) | ||
159 | { | ||
160 | } | ||
161 | |||
162 | static inline void debug_dma_sync_sg_for_device(struct device *dev, | ||
163 | struct scatterlist *sg, | ||
164 | int nelems, int direction) | ||
165 | { | ||
166 | } | ||
167 | |||
168 | static inline void debug_dma_dump_mappings(struct device *dev) | ||
169 | { | ||
170 | } | ||
171 | |||
172 | #endif /* CONFIG_DMA_API_DEBUG */ | ||
173 | |||
174 | #endif /* __DMA_DEBUG_H */ | ||
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index ba9114ec5d3a..d7d090d21031 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h | |||
@@ -3,6 +3,8 @@ | |||
3 | 3 | ||
4 | #include <linux/device.h> | 4 | #include <linux/device.h> |
5 | #include <linux/err.h> | 5 | #include <linux/err.h> |
6 | #include <linux/dma-attrs.h> | ||
7 | #include <linux/scatterlist.h> | ||
6 | 8 | ||
7 | /* These definitions mirror those in pci.h, so they can be used | 9 | /* These definitions mirror those in pci.h, so they can be used |
8 | * interchangeably with their PCI_ counterparts */ | 10 | * interchangeably with their PCI_ counterparts */ |
@@ -13,6 +15,52 @@ enum dma_data_direction { | |||
13 | DMA_NONE = 3, | 15 | DMA_NONE = 3, |
14 | }; | 16 | }; |
15 | 17 | ||
18 | struct dma_map_ops { | ||
19 | void* (*alloc_coherent)(struct device *dev, size_t size, | ||
20 | dma_addr_t *dma_handle, gfp_t gfp); | ||
21 | void (*free_coherent)(struct device *dev, size_t size, | ||
22 | void *vaddr, dma_addr_t dma_handle); | ||
23 | dma_addr_t (*map_page)(struct device *dev, struct page *page, | ||
24 | unsigned long offset, size_t size, | ||
25 | enum dma_data_direction dir, | ||
26 | struct dma_attrs *attrs); | ||
27 | void (*unmap_page)(struct device *dev, dma_addr_t dma_handle, | ||
28 | size_t size, enum dma_data_direction dir, | ||
29 | struct dma_attrs *attrs); | ||
30 | int (*map_sg)(struct device *dev, struct scatterlist *sg, | ||
31 | int nents, enum dma_data_direction dir, | ||
32 | struct dma_attrs *attrs); | ||
33 | void (*unmap_sg)(struct device *dev, | ||
34 | struct scatterlist *sg, int nents, | ||
35 | enum dma_data_direction dir, | ||
36 | struct dma_attrs *attrs); | ||
37 | void (*sync_single_for_cpu)(struct device *dev, | ||
38 | dma_addr_t dma_handle, size_t size, | ||
39 | enum dma_data_direction dir); | ||
40 | void (*sync_single_for_device)(struct device *dev, | ||
41 | dma_addr_t dma_handle, size_t size, | ||
42 | enum dma_data_direction dir); | ||
43 | void (*sync_single_range_for_cpu)(struct device *dev, | ||
44 | dma_addr_t dma_handle, | ||
45 | unsigned long offset, | ||
46 | size_t size, | ||
47 | enum dma_data_direction dir); | ||
48 | void (*sync_single_range_for_device)(struct device *dev, | ||
49 | dma_addr_t dma_handle, | ||
50 | unsigned long offset, | ||
51 | size_t size, | ||
52 | enum dma_data_direction dir); | ||
53 | void (*sync_sg_for_cpu)(struct device *dev, | ||
54 | struct scatterlist *sg, int nents, | ||
55 | enum dma_data_direction dir); | ||
56 | void (*sync_sg_for_device)(struct device *dev, | ||
57 | struct scatterlist *sg, int nents, | ||
58 | enum dma_data_direction dir); | ||
59 | int (*mapping_error)(struct device *dev, dma_addr_t dma_addr); | ||
60 | int (*dma_supported)(struct device *dev, u64 mask); | ||
61 | int is_phys; | ||
62 | }; | ||
63 | |||
16 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) | 64 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) |
17 | 65 | ||
18 | /* | 66 | /* |
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h index 78c1262e8704..1d6c71d96ede 100644 --- a/include/linux/intel-iommu.h +++ b/include/linux/intel-iommu.h | |||
@@ -332,11 +332,4 @@ extern int qi_flush_iotlb(struct intel_iommu *iommu, u16 did, u64 addr, | |||
332 | 332 | ||
333 | extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); | 333 | extern int qi_submit_sync(struct qi_desc *desc, struct intel_iommu *iommu); |
334 | 334 | ||
335 | extern void *intel_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t); | ||
336 | extern void intel_free_coherent(struct device *, size_t, void *, dma_addr_t); | ||
337 | extern dma_addr_t intel_map_single(struct device *, phys_addr_t, size_t, int); | ||
338 | extern void intel_unmap_single(struct device *, dma_addr_t, size_t, int); | ||
339 | extern int intel_map_sg(struct device *, struct scatterlist *, int, int); | ||
340 | extern void intel_unmap_sg(struct device *, struct scatterlist *, int, int); | ||
341 | |||
342 | #endif | 335 | #endif |
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h index dedd3c0cfe30..ac9ff54f7cb3 100644 --- a/include/linux/swiotlb.h +++ b/include/linux/swiotlb.h | |||
@@ -31,7 +31,7 @@ extern dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, | |||
31 | phys_addr_t address); | 31 | phys_addr_t address); |
32 | extern phys_addr_t swiotlb_bus_to_phys(dma_addr_t address); | 32 | extern phys_addr_t swiotlb_bus_to_phys(dma_addr_t address); |
33 | 33 | ||
34 | extern int swiotlb_arch_range_needs_mapping(void *ptr, size_t size); | 34 | extern int swiotlb_arch_range_needs_mapping(phys_addr_t paddr, size_t size); |
35 | 35 | ||
36 | extern void | 36 | extern void |
37 | *swiotlb_alloc_coherent(struct device *hwdev, size_t size, | 37 | *swiotlb_alloc_coherent(struct device *hwdev, size_t size, |
@@ -41,20 +41,13 @@ extern void | |||
41 | swiotlb_free_coherent(struct device *hwdev, size_t size, | 41 | swiotlb_free_coherent(struct device *hwdev, size_t size, |
42 | void *vaddr, dma_addr_t dma_handle); | 42 | void *vaddr, dma_addr_t dma_handle); |
43 | 43 | ||
44 | extern dma_addr_t | 44 | extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, |
45 | swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir); | 45 | unsigned long offset, size_t size, |
46 | 46 | enum dma_data_direction dir, | |
47 | extern void | 47 | struct dma_attrs *attrs); |
48 | swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, | 48 | extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dev_addr, |
49 | size_t size, int dir); | 49 | size_t size, enum dma_data_direction dir, |
50 | 50 | struct dma_attrs *attrs); | |
51 | extern dma_addr_t | ||
52 | swiotlb_map_single_attrs(struct device *hwdev, void *ptr, size_t size, | ||
53 | int dir, struct dma_attrs *attrs); | ||
54 | |||
55 | extern void | ||
56 | swiotlb_unmap_single_attrs(struct device *hwdev, dma_addr_t dev_addr, | ||
57 | size_t size, int dir, struct dma_attrs *attrs); | ||
58 | 51 | ||
59 | extern int | 52 | extern int |
60 | swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, | 53 | swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nents, |
@@ -66,36 +59,38 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nents, | |||
66 | 59 | ||
67 | extern int | 60 | extern int |
68 | swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, | 61 | swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, |
69 | int dir, struct dma_attrs *attrs); | 62 | enum dma_data_direction dir, struct dma_attrs *attrs); |
70 | 63 | ||
71 | extern void | 64 | extern void |
72 | swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl, | 65 | swiotlb_unmap_sg_attrs(struct device *hwdev, struct scatterlist *sgl, |
73 | int nelems, int dir, struct dma_attrs *attrs); | 66 | int nelems, enum dma_data_direction dir, |
67 | struct dma_attrs *attrs); | ||
74 | 68 | ||
75 | extern void | 69 | extern void |
76 | swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr, | 70 | swiotlb_sync_single_for_cpu(struct device *hwdev, dma_addr_t dev_addr, |
77 | size_t size, int dir); | 71 | size_t size, enum dma_data_direction dir); |
78 | 72 | ||
79 | extern void | 73 | extern void |
80 | swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, | 74 | swiotlb_sync_sg_for_cpu(struct device *hwdev, struct scatterlist *sg, |
81 | int nelems, int dir); | 75 | int nelems, enum dma_data_direction dir); |
82 | 76 | ||
83 | extern void | 77 | extern void |
84 | swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr, | 78 | swiotlb_sync_single_for_device(struct device *hwdev, dma_addr_t dev_addr, |
85 | size_t size, int dir); | 79 | size_t size, enum dma_data_direction dir); |
86 | 80 | ||
87 | extern void | 81 | extern void |
88 | swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, | 82 | swiotlb_sync_sg_for_device(struct device *hwdev, struct scatterlist *sg, |
89 | int nelems, int dir); | 83 | int nelems, enum dma_data_direction dir); |
90 | 84 | ||
91 | extern void | 85 | extern void |
92 | swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr, | 86 | swiotlb_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dev_addr, |
93 | unsigned long offset, size_t size, int dir); | 87 | unsigned long offset, size_t size, |
88 | enum dma_data_direction dir); | ||
94 | 89 | ||
95 | extern void | 90 | extern void |
96 | swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr, | 91 | swiotlb_sync_single_range_for_device(struct device *hwdev, dma_addr_t dev_addr, |
97 | unsigned long offset, size_t size, | 92 | unsigned long offset, size_t size, |
98 | int dir); | 93 | enum dma_data_direction dir); |
99 | 94 | ||
100 | extern int | 95 | extern int |
101 | swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr); | 96 | swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr); |