]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
dma-debug: add checking for map/unmap_page/single
authorJoerg Roedel <joerg.roedel@amd.com>
Fri, 9 Jan 2009 13:14:49 +0000 (14:14 +0100)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 5 Mar 2009 19:35:18 +0000 (20:35 +0100)
Impact: add debug callbacks for dma_{un}map_[page|single]

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
include/linux/dma-debug.h
lib/dma-debug.c

index 345d5387a30d2be6b09a76c59cca20ef673c1fe6..65f73526ba2c36ad7bed61f02747acf8412f193f 100644 (file)
@@ -28,12 +28,35 @@ struct device;
 
 extern void dma_debug_init(u32 num_entries);
 
+extern void debug_dma_map_page(struct device *dev, struct page *page,
+                              size_t offset, size_t size,
+                              int direction, dma_addr_t dma_addr,
+                              bool map_single);
+
+extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
+                                size_t size, int direction, bool map_single);
+
+
 #else /* CONFIG_DMA_API_DEBUG */
 
 static inline void dma_debug_init(u32 num_entries)
 {
 }
 
+static inline void debug_dma_map_page(struct device *dev, struct page *page,
+                                     size_t offset, size_t size,
+                                     int direction, dma_addr_t dma_addr,
+                                     bool map_single)
+{
+}
+
+static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
+                                       size_t size, int direction,
+                                       bool map_single)
+{
+}
+
+
 #endif /* CONFIG_DMA_API_DEBUG */
 
 #endif /* __DMA_DEBUG_H */
index d0cb47a4211eeeb290fd3748ae64d505a8aa7056..a2ed2b76968550cc9d776fe24fc54209eed22e3a 100644 (file)
@@ -566,3 +566,56 @@ out:
 
 }
 
+void debug_dma_map_page(struct device *dev, struct page *page, size_t offset,
+                       size_t size, int direction, dma_addr_t dma_addr,
+                       bool map_single)
+{
+       struct dma_debug_entry *entry;
+
+       if (unlikely(global_disable))
+               return;
+
+       if (unlikely(dma_mapping_error(dev, dma_addr)))
+               return;
+
+       entry = dma_entry_alloc();
+       if (!entry)
+               return;
+
+       entry->dev       = dev;
+       entry->type      = dma_debug_page;
+       entry->paddr     = page_to_phys(page) + offset;
+       entry->dev_addr  = dma_addr;
+       entry->size      = size;
+       entry->direction = direction;
+
+       if (map_single) {
+               entry->type = dma_debug_single;
+               check_for_stack(dev, page_address(page) + offset);
+       }
+
+       add_dma_entry(entry);
+}
+EXPORT_SYMBOL(debug_dma_map_page);
+
+void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
+                         size_t size, int direction, bool map_single)
+{
+       struct dma_debug_entry ref = {
+               .type           = dma_debug_page,
+               .dev            = dev,
+               .dev_addr       = addr,
+               .size           = size,
+               .direction      = direction,
+       };
+
+       if (unlikely(global_disable))
+               return;
+
+       if (map_single)
+               ref.type = dma_debug_single;
+
+       check_unmap(&ref);
+}
+EXPORT_SYMBOL(debug_dma_unmap_page);
+