aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-03-31 08:08:09 -0400
committerJoerg Roedel <joerg.roedel@amd.com>2011-04-07 10:31:19 -0400
commitba4b87ad5497cba555954885db99c99627f93748 (patch)
treec83af58e944639ea32418a84491469ddf3722b1c /lib
parent6221f222c0ebf1acdf7abcf927178f40e1a65e2a (diff)
dma-debug: print information about leaked entry
When driver leak dma mapping, print additional information about one of leaked entries, to to help investigate problem. Patch should be useful for debugging drivers, which maps many different class of buffers. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dma-debug.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 4bfb0471f106..db07bfd9298e 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -649,7 +649,7 @@ out_err:
649 return -ENOMEM; 649 return -ENOMEM;
650} 650}
651 651
652static int device_dma_allocations(struct device *dev) 652static int device_dma_allocations(struct device *dev, struct dma_debug_entry **out_entry)
653{ 653{
654 struct dma_debug_entry *entry; 654 struct dma_debug_entry *entry;
655 unsigned long flags; 655 unsigned long flags;
@@ -660,8 +660,10 @@ static int device_dma_allocations(struct device *dev)
660 for (i = 0; i < HASH_SIZE; ++i) { 660 for (i = 0; i < HASH_SIZE; ++i) {
661 spin_lock(&dma_entry_hash[i].lock); 661 spin_lock(&dma_entry_hash[i].lock);
662 list_for_each_entry(entry, &dma_entry_hash[i].list, list) { 662 list_for_each_entry(entry, &dma_entry_hash[i].list, list) {
663 if (entry->dev == dev) 663 if (entry->dev == dev) {
664 count += 1; 664 count += 1;
665 *out_entry = entry;
666 }
665 } 667 }
666 spin_unlock(&dma_entry_hash[i].lock); 668 spin_unlock(&dma_entry_hash[i].lock);
667 } 669 }
@@ -674,6 +676,7 @@ static int device_dma_allocations(struct device *dev)
674static int dma_debug_device_change(struct notifier_block *nb, unsigned long action, void *data) 676static int dma_debug_device_change(struct notifier_block *nb, unsigned long action, void *data)
675{ 677{
676 struct device *dev = data; 678 struct device *dev = data;
679 struct dma_debug_entry *uninitialized_var(entry);
677 int count; 680 int count;
678 681
679 if (global_disable) 682 if (global_disable)
@@ -681,12 +684,17 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
681 684
682 switch (action) { 685 switch (action) {
683 case BUS_NOTIFY_UNBOUND_DRIVER: 686 case BUS_NOTIFY_UNBOUND_DRIVER:
684 count = device_dma_allocations(dev); 687 count = device_dma_allocations(dev, &entry);
685 if (count == 0) 688 if (count == 0)
686 break; 689 break;
687 err_printk(dev, NULL, "DMA-API: device driver has pending " 690 err_printk(dev, entry, "DMA-API: device driver has pending "
688 "DMA allocations while released from device " 691 "DMA allocations while released from device "
689 "[count=%d]\n", count); 692 "[count=%d]\n"
693 "One of leaked entries details: "
694 "[device address=0x%016llx] [size=%llu bytes] "
695 "[mapped with %s] [mapped as %s]\n",
696 count, entry->dev_addr, entry->size,
697 dir2name[entry->direction], type2name[entry->type]);
690 break; 698 break;
691 default: 699 default:
692 break; 700 break;