[PATCH 10/16] dma-debug: add add checking for map/unmap_sg

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Joerg Roedel
Date: Friday, January 9, 2009 - 9:19 am

Impact: add debug callbacks for dma_{un}map_sg

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 include/linux/dma-debug.h |   15 ++++++++++++
 lib/dma-debug.c           |   53 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/include/linux/dma-debug.h b/include/linux/dma-debug.h
index 82ae9ca..b2131f4 100644
--- a/include/linux/dma-debug.h
+++ b/include/linux/dma-debug.h
@@ -34,6 +34,11 @@ extern void debug_map_single(struct device *dev, void *ptr, size_t size,
 extern void debug_unmap_single(struct device *dev, dma_addr_t addr,
 			       size_t size, int direction);
 
+extern void debug_map_sg(struct device *dev, struct scatterlist *sg,
+			 int nents, int direction);
+
+extern void debug_unmap_sg(struct device *dev, struct scatterlist *sglist,
+			   int nelems, int dir);
 
 #else /* CONFIG_DMA_API_DEBUG */
 
@@ -52,6 +57,16 @@ static inline void debug_unmap_single(struct device *dev, dma_addr_t addr,
 {
 }
 
+static inline void debug_map_sg(struct device *dev, struct scatterlist *sg,
+				int nents, int direction)
+{
+}
+
+static inline void debug_unmap_sg(struct device *dev,
+				  struct scatterlist *sglist,
+				  int nelems, int dir)
+{
+}
 
 #endif /* CONFIG_DMA_API_DEBUG */
 
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index d4d14e5..e6d45f9 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -17,6 +17,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
+#include <linux/scatterlist.h>
 #include <linux/dma-mapping.h>
 #include <linux/dma-debug.h>
 #include <linux/spinlock.h>
@@ -551,3 +552,55 @@ void debug_unmap_single(struct device *dev, dma_addr_t addr,
 }
 EXPORT_SYMBOL(debug_unmap_single);
 
+void debug_map_sg(struct device *dev, struct scatterlist *sg,
+		  int nents, int direction)
+{
+	struct dma_debug_entry *entry;
+	struct scatterlist *s;
+	int i;
+
+	if (global_disable)
+		return;
+
+	for_each_sg(sg, s, nents, i) {
+		entry = dma_entry_alloc();
+		if (!entry)
+			return;
+
+		entry->type      = dma_debug_sg;
+		entry->dev       = dev;
+		entry->cpu_addr  = sg_virt(s);
+		entry->size      = s->length;
+		entry->dev_addr  = s->dma_address;
+		entry->direction = direction;
+
+		add_dma_entry(entry);
+	}
+}
+EXPORT_SYMBOL(debug_map_sg);
+
+void debug_unmap_sg(struct device *dev, struct scatterlist *sglist,
+		    int nelems, int dir)
+{
+	struct scatterlist *s;
+	int i;
+
+	if (global_disable)
+		return;
+
+	for_each_sg(sglist, s, nelems, i) {
+
+		struct dma_debug_entry ref = {
+			.type           = dma_debug_sg,
+			.dev            = dev,
+			.cpu_addr       = sg_virt(s),
+			.dev_addr       = s->dma_address,
+			.size           = s->length,
+			.direction      = dir,
+		};
+
+		check_unmap(&ref);
+	}
+}
+EXPORT_SYMBOL(debug_unmap_sg);
+
-- 
1.5.6.4


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/16] DMA-API debugging facility v2, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 01/16] dma-debug: add Kconfig entry, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 04/16] dma-debug: add allocator code, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 05/16] dma-debug: add initialization code, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 07/16] dma-debug: add debugfs interface, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 08/16] dma-debug: add core checking functions, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 10/16] dma-debug: add add checking for map/unmap_sg, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 12/16] dma-debug: add checks for sync_single_*, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 15/16] dma-debug: x86 architecture bindings, Joerg Roedel, (Fri Jan 9, 9:19 am)
[PATCH 16/16] dma-debug: Documentation update, Joerg Roedel, (Fri Jan 9, 9:19 am)
Re: [PATCH 05/16] dma-debug: add initialization code, Evgeniy Polyakov, (Fri Jan 9, 10:58 am)
Re: [PATCH 05/16] dma-debug: add initialization code, Joerg Roedel, (Fri Jan 9, 11:17 am)
Re: [PATCH 01/16] dma-debug: add Kconfig entry, Randy Dunlap, (Fri Jan 9, 1:12 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, Michael Chan, (Fri Jan 9, 2:24 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, Joerg Roedel, (Fri Jan 9, 3:33 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, Joerg Roedel, (Fri Jan 9, 3:37 pm)
Re: [PATCH 15/16] dma-debug: x86 architecture bindings, Ingo Molnar, (Sat Jan 10, 4:04 pm)
Re: [PATCH 07/16] dma-debug: add debugfs interface, Ingo Molnar, (Sat Jan 10, 4:08 pm)
Re: [PATCH 07/16] dma-debug: add debugfs interface, Ingo Molnar, (Sat Jan 10, 4:15 pm)
Re: [PATCH 04/16] dma-debug: add allocator code, Ingo Molnar, (Sat Jan 10, 4:43 pm)
Re: [PATCH 15/16] dma-debug: x86 architecture bindings, Ingo Molnar, (Sat Jan 10, 4:48 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, Ingo Molnar, (Sat Jan 10, 4:54 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, FUJITA Tomonori, (Sat Jan 10, 11:25 pm)
Re: [PATCH 15/16] dma-debug: x86 architecture bindings, FUJITA Tomonori, (Sat Jan 10, 11:25 pm)
Re: [PATCH 07/16] dma-debug: add debugfs interface, Joerg Roedel, (Sun Jan 11, 12:52 am)
Re: [PATCH 08/16] dma-debug: add core checking functions, Joerg Roedel, (Sun Jan 11, 12:54 am)
Re: [PATCH 08/16] dma-debug: add core checking functions, Joerg Roedel, (Sun Jan 11, 12:57 am)
Re: [PATCH 15/16] dma-debug: x86 architecture bindings, Joerg Roedel, (Sun Jan 11, 1:08 am)
Re: [PATCH 0/16] DMA-API debugging facility v2, Joerg Roedel, (Sun Jan 11, 1:11 am)
Re: [PATCH 07/16] dma-debug: add debugfs interface, Joerg Roedel, (Wed Jan 14, 8:22 am)
Re: [PATCH 0/16] DMA-API debugging facility v2, David Woodhouse, (Thu Feb 5, 3:52 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, Chris Wright, (Thu Feb 5, 7:05 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, Chris Wright, (Thu Feb 5, 7:27 pm)
Re: [PATCH 0/16] DMA-API debugging facility v2, David Woodhouse, (Fri Feb 6, 12:56 am)
Re: [PATCH 0/16] DMA-API debugging facility v2, Chris Wright, (Fri Feb 6, 9:08 am)
Re: [PATCH 0/16] DMA-API debugging facility v2, Chris Wright, (Fri Feb 6, 11:20 am)
Re: [PATCH 0/16] DMA-API debugging facility v2, Joerg Roedel, (Thu Feb 12, 7:48 am)
Re: [PATCH 0/16] DMA-API debugging facility v2, Joerg Roedel, (Thu Feb 12, 8:20 am)