aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/dma-debug.h
diff options
context:
space:
mode:
authorStephen Boyd <swboyd@chromium.org>2018-10-08 03:20:07 -0400
committerChristoph Hellwig <hch@lst.de>2018-10-08 03:44:17 -0400
commit99c65fa7c59ff558e70db8aa61bbdece5d3a9588 (patch)
tree5a72a54e4d6d2104b3aeedd86d84563d2d545af5 /include/linux/dma-debug.h
parent1fc8e6423edb4bba365b0780c2fcddfb921b24b2 (diff)
dma-debug: Check for drivers mapping invalid addresses in dma_map_single()
I recently debugged a DMA mapping oops where a driver was trying to map a buffer returned from request_firmware() with dma_map_single(). Memory returned from request_firmware() is mapped into the vmalloc region and this isn't a valid region to map with dma_map_single() per the DMA documentation's "What memory is DMA'able?" section. Unfortunately, we don't really check that in the DMA debugging code, so enabling DMA debugging doesn't help catch this problem. Let's add a new DMA debug function to check for a vmalloc address or an invalid virtual address and print a warning if this happens. This makes it a little easier to debug these sorts of problems, instead of seeing odd behavior or crashes when drivers attempt to map the vmalloc space for DMA. Cc: Marek Szyprowski <m.szyprowski@samsung.com> Reviewed-by: Robin Murphy <robin.murphy@arm.com> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux/dma-debug.h')
-rw-r--r--include/linux/dma-debug.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h
index a785f2507159..30213adbb6b9 100644
--- a/include/linux/dma-debug.h
+++ b/include/linux/dma-debug.h
@@ -32,6 +32,9 @@ extern void dma_debug_add_bus(struct bus_type *bus);
32 32
33extern int dma_debug_resize_entries(u32 num_entries); 33extern int dma_debug_resize_entries(u32 num_entries);
34 34
35extern void debug_dma_map_single(struct device *dev, const void *addr,
36 unsigned long len);
37
35extern void debug_dma_map_page(struct device *dev, struct page *page, 38extern void debug_dma_map_page(struct device *dev, struct page *page,
36 size_t offset, size_t size, 39 size_t offset, size_t size,
37 int direction, dma_addr_t dma_addr, 40 int direction, dma_addr_t dma_addr,
@@ -103,6 +106,11 @@ static inline int dma_debug_resize_entries(u32 num_entries)
103 return 0; 106 return 0;
104} 107}
105 108
109static inline void debug_dma_map_single(struct device *dev, const void *addr,
110 unsigned long len)
111{
112}
113
106static inline void debug_dma_map_page(struct device *dev, struct page *page, 114static inline void debug_dma_map_page(struct device *dev, struct page *page,
107 size_t offset, size_t size, 115 size_t offset, size_t size,
108 int direction, dma_addr_t dma_addr, 116 int direction, dma_addr_t dma_addr,