]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - lib/dma-debug.c
Merge branch 'akpm-current/current'
[karo-tx-linux.git] / lib / dma-debug.c
index fcb65d2a0b947e85e335599229bd3a44a1c425d7..af6262b4e02c62c11bbf6295abc22c38ca4bc5a1 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/sched.h>
 #include <linux/ctype.h>
 #include <linux/list.h>
+#include <linux/poison.h>
 #include <linux/slab.h>
 
 #include <asm/sections.h>
@@ -1249,6 +1250,14 @@ static void check_sync(struct device *dev,
                                dir2name[entry->direction],
                                dir2name[ref->direction]);
 
+       if (ref->sg_call_ents && ref->type == dma_debug_sg &&
+           ref->sg_call_ents != entry->sg_call_ents) {
+               err_printk(ref->dev, entry, "DMA-API: device driver syncs "
+                          "DMA sg list with different entry count "
+                          "[map count=%d] [sync count=%d]\n",
+                          entry->sg_call_ents, ref->sg_call_ents);
+       }
+
 out:
        put_hash_bucket(bucket, &flags);
 }
@@ -1439,7 +1448,7 @@ void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
 EXPORT_SYMBOL(debug_dma_unmap_sg);
 
 void debug_dma_alloc_coherent(struct device *dev, size_t size,
-                             dma_addr_t dma_addr, void *virt)
+                             dma_addr_t dma_addr, void *virt, gfp_t flags)
 {
        struct dma_debug_entry *entry;
 
@@ -1449,6 +1458,9 @@ void debug_dma_alloc_coherent(struct device *dev, size_t size,
        if (unlikely(virt == NULL))
                return;
 
+       if (IS_ENABLED(CONFIG_DMA_API_DEBUG_POISON) && !(flags & __GFP_ZERO))
+               memset(virt, DMA_ALLOC_POISON, size);
+
        entry = dma_entry_alloc();
        if (!entry)
                return;