]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dma-debug: enhance dma_debug_device_change() to check for mapping errors
authorShuah Khan <shuah.kh@samsung.com>
Mon, 16 Dec 2013 23:44:50 +0000 (10:44 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 16 Dec 2013 23:44:50 +0000 (10:44 +1100)
dma-debug checks to verify if driver validated the address returned by dma
mapping routines when driver does unmap.  If a driver doesn't call unmap,
failure to check mapping errors isn't detected and reported.

Enhance the existing bus notifier_call dma_debug_device_change() to check
for mapping errors at the same time it detects leaked dma buffers for
BUS_NOTIFY_UNBOUND_DRIVER event.  It scans for mapping errors and if any
found, prints one warning message that includes mapping error count.

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
Cc: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/dma-debug.c

index d87a17a819d07a58bc8f1dd40f2d41ae499935c8..e34865ef27e3cdbd2f8219d9ee468ff27c952958 100644 (file)
@@ -717,6 +717,7 @@ static int device_dma_allocations(struct device *dev, struct dma_debug_entry **o
        struct dma_debug_entry *entry;
        unsigned long flags;
        int count = 0, i;
+       int map_err_cnt = 0;
 
        local_irq_save(flags);
 
@@ -724,6 +725,8 @@ static int device_dma_allocations(struct device *dev, struct dma_debug_entry **o
                spin_lock(&dma_entry_hash[i].lock);
                list_for_each_entry(entry, &dma_entry_hash[i].list, list) {
                        if (entry->dev == dev) {
+                               if (entry->map_err_type == MAP_ERR_NOT_CHECKED)
+                                       map_err_cnt += 1;
                                count += 1;
                                *out_entry = entry;
                        }
@@ -733,6 +736,10 @@ static int device_dma_allocations(struct device *dev, struct dma_debug_entry **o
 
        local_irq_restore(flags);
 
+       if (map_err_cnt)
+               dev_warn(entry->dev,
+                       "DMA-API: device driver failed to check map errors: "
+                       "[count] = %d\n", map_err_cnt);
        return count;
 }