aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dma-debug.c
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2009-02-12 10:19:13 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-03-17 07:56:39 -0400
commitac26c18bd35d982d1ba06020a992b1085fefc3e2 (patch)
tree33f7fe1a22848c7dfdd002298f27efff103480a4 /lib/dma-debug.c
parenta31fba5d68cebf8f5fefd03e079dab94875e25f5 (diff)
dma-debug: add function to dump dma mappings
This adds a function to dump the DMA mappings that the debugging code is aware of -- either for a single device, or for _all_ devices. This can be useful for debugging -- sticking a call to it in the DMA page fault handler, for example, to see if the faulting address _should_ be mapped or not, and hence work out whether it's IOMMU bugs we're seeing, or driver bugs. Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'lib/dma-debug.c')
-rw-r--r--lib/dma-debug.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 9d11e89c2ee2..91ed1dfdbaac 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 */