aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/dma-debug.h6
-rw-r--r--lib/dma-debug.c30
2 files changed, 36 insertions, 0 deletions
diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h
index 4985c6c5237..46a11c10da0 100644
--- a/include/linux/dma-debug.h
+++ b/include/linux/dma-debug.h
@@ -76,6 +76,8 @@ extern void debug_dma_sync_sg_for_device(struct device *dev,
76 struct scatterlist *sg, 76 struct scatterlist *sg,
77 int nelems, int direction); 77 int nelems, int direction);
78 78
79extern void debug_dma_dump_mappings(struct device *dev);
80
79#else /* CONFIG_DMA_API_DEBUG */ 81#else /* CONFIG_DMA_API_DEBUG */
80 82
81static inline void dma_debug_init(u32 num_entries) 83static inline void dma_debug_init(u32 num_entries)
@@ -156,6 +158,10 @@ static inline void debug_dma_sync_sg_for_device(struct device *dev,
156{ 158{
157} 159}
158 160
161static inline void debug_dma_dump_mappings(struct device *dev)
162{
163}
164
159#endif /* CONFIG_DMA_API_DEBUG */ 165#endif /* CONFIG_DMA_API_DEBUG */
160 166
161#endif /* __DMA_DEBUG_H */ 167#endif /* __DMA_DEBUG_H */
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 9d11e89c2ee..91ed1dfdbaa 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -194,6 +194,36 @@ static void hash_bucket_del(struct dma_debug_entry *entry)
194} 194}
195 195
196/* 196/*
197 * Dump mapping entries for debugging purposes
198 */
199void debug_dma_dump_mappings(struct device *dev)
200{
201 int idx;
202
203 for (idx = 0; idx < HASH_SIZE; idx++) {
204 struct hash_bucket *bucket = &dma_entry_hash[idx];
205 struct dma_debug_entry *entry;
206 unsigned long flags;
207
208 spin_lock_irqsave(&bucket->lock, flags);
209
210 list_for_each_entry(entry, &bucket->list, list) {
211 if (!dev || dev == entry->dev) {
212 dev_info(entry->dev,
213 "%s idx %d P=%Lx D=%Lx L=%Lx %s\n",
214 type2name[entry->type], idx,
215 (unsigned long long)entry->paddr,
216 entry->dev_addr, entry->size,
217 dir2name[entry->direction]);
218 }
219 }
220
221 spin_unlock_irqrestore(&bucket->lock, flags);
222 }
223}
224EXPORT_SYMBOL(debug_dma_dump_mappings);
225
226/*
197 * Wrapper function for adding an entry to the hash. 227 * Wrapper function for adding an entry to the hash.
198 * This function takes care of locking itself. 228 * This function takes care of locking itself.
199 */ 229 */