Skip to content

Commit ba4b87a

Browse files
Stanislaw GruszkaJoerg Roedel
Stanislaw Gruszka
authored and
Joerg Roedel
committed
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 <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 6221f22 commit ba4b87a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/dma-debug.c

+13-5
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ static int dma_debug_fs_init(void)
649649
return -ENOMEM;
650650
}
651651

652-
static int device_dma_allocations(struct device *dev)
652+
static int device_dma_allocations(struct device *dev, struct dma_debug_entry **out_entry)
653653
{
654654
struct dma_debug_entry *entry;
655655
unsigned long flags;
@@ -660,8 +660,10 @@ static int device_dma_allocations(struct device *dev)
660660
for (i = 0; i < HASH_SIZE; ++i) {
661661
spin_lock(&dma_entry_hash[i].lock);
662662
list_for_each_entry(entry, &dma_entry_hash[i].list, list) {
663-
if (entry->dev == dev)
663+
if (entry->dev == dev) {
664664
count += 1;
665+
*out_entry = entry;
666+
}
665667
}
666668
spin_unlock(&dma_entry_hash[i].lock);
667669
}
@@ -674,19 +676,25 @@ static int device_dma_allocations(struct device *dev)
674676
static int dma_debug_device_change(struct notifier_block *nb, unsigned long action, void *data)
675677
{
676678
struct device *dev = data;
679+
struct dma_debug_entry *uninitialized_var(entry);
677680
int count;
678681

679682
if (global_disable)
680683
return 0;
681684

682685
switch (action) {
683686
case BUS_NOTIFY_UNBOUND_DRIVER:
684-
count = device_dma_allocations(dev);
687+
count = device_dma_allocations(dev, &entry);
685688
if (count == 0)
686689
break;
687-
err_printk(dev, NULL, "DMA-API: device driver has pending "
690+
err_printk(dev, entry, "DMA-API: device driver has pending "
688691
"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]);
690698
break;
691699
default:
692700
break;

0 commit comments

Comments
 (0)