[PATCH 09/10] x86: add checks for sync_single_range* code

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Joerg Roedel
Date: Friday, November 21, 2008 - 9:26 am

Impact: detect bugs in sync_single_range* usage

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/include/asm/dma-mapping.h |    4 ++++
 arch/x86/include/asm/dma_debug.h   |   26 ++++++++++++++++++++++++++
 arch/x86/kernel/pci-dma-debug.c    |   17 +++++++++++++++++
 3 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h
index 63bed40..2b6399d 100644
--- a/arch/x86/include/asm/dma-mapping.h
+++ b/arch/x86/include/asm/dma-mapping.h
@@ -185,6 +185,8 @@ dma_sync_single_range_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
 	if (ops->sync_single_range_for_cpu)
 		ops->sync_single_range_for_cpu(hwdev, dma_handle, offset,
 					       size, direction);
+	debug_sync_single_range_for_cpu(hwdev, dma_handle, offset,
+					size, direction);
 	flush_write_buffers();
 }
 
@@ -199,6 +201,8 @@ dma_sync_single_range_for_device(struct device *hwdev, dma_addr_t dma_handle,
 	if (ops->sync_single_range_for_device)
 		ops->sync_single_range_for_device(hwdev, dma_handle,
 						  offset, size, direction);
+	debug_sync_single_range_for_device(hwdev, dma_handle, offset,
+					   size, direction);
 	flush_write_buffers();
 }
 
diff --git a/arch/x86/include/asm/dma_debug.h b/arch/x86/include/asm/dma_debug.h
index 8262cd1..bc4a841 100644
--- a/arch/x86/include/asm/dma_debug.h
+++ b/arch/x86/include/asm/dma_debug.h
@@ -75,6 +75,17 @@ extern
 void debug_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
 				  size_t size, int direction);
 
+extern
+void debug_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
+				     unsigned long offset, size_t size,
+				     int direction);
+
+extern
+void debug_sync_single_range_for_device(struct device *dev,
+					dma_addr_t dma_handle,
+					unsigned long offset,
+					size_t size, int direction);
+
 #else /* CONFIG_DMA_API_DEBUG */
 
 static inline
@@ -130,6 +141,21 @@ void debug_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
 {
 }
 
+static inline
+void debug_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
+				     unsigned long offset, size_t size,
+				     int direction)
+{
+}
+
+static inline
+void debug_sync_single_range_for_device(struct device *dev,
+					dma_addr_t dma_handle,
+					unsigned long offset,
+					size_t size, int direction)
+{
+}
+
 #endif /* CONFIG_DMA_API_DEBUG */
 
 #endif /* __ASM_X86_DMA_DEBUG */
diff --git a/arch/x86/kernel/pci-dma-debug.c b/arch/x86/kernel/pci-dma-debug.c
index 1dfcd33..92b9491 100644
--- a/arch/x86/kernel/pci-dma-debug.c
+++ b/arch/x86/kernel/pci-dma-debug.c
@@ -422,3 +422,20 @@ void debug_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
 }
 EXPORT_SYMBOL(debug_sync_single_for_device);
 
+void debug_sync_single_range_for_cpu(struct device *dev, dma_addr_t dma_handle,
+				     unsigned long offset, size_t size,
+				     int direction)
+{
+	check_sync(dev, dma_handle, size, offset, direction, true);
+}
+EXPORT_SYMBOL(debug_sync_single_range_for_cpu);
+
+void debug_sync_single_range_for_device(struct device *dev,
+					dma_addr_t dma_handle,
+					unsigned long offset,
+					size_t size, int direction)
+{
+	check_sync(dev, dma_handle, size, offset, direction, false);
+}
+EXPORT_SYMBOL(debug_sync_single_range_for_device);
+
-- 
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/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 06/10] x86: add check code for map/unmap_sg code, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 08/10] x86: add checks for sync_single* code, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 09/10] x86: add checks for sync_single_range* code, Joerg Roedel, (Fri Nov 21, 9:26 am)
[PATCH 10/10] x86: add checks for sync_sg* code, Joerg Roedel, (Fri Nov 21, 9:26 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 9:37 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:40 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:52 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 9:54 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 9:57 am)
Re: [PATCH 10/10] x86: add checks for sync_sg* code, Ingo Molnar, (Fri Nov 21, 9:59 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 10:03 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 10:06 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 10:18 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 10:20 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 10:22 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Fri Nov 21, 10:24 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Fri Nov 21, 10:27 am)
Re: [PATCH 0/10] DMA-API debugging facility, Ingo Molnar, (Fri Nov 21, 10:45 am)
Re: [PATCH 0/10] DMA-API debugging facility, FUJITA Tomonori, (Fri Nov 21, 8:27 pm)
Re: [PATCH 0/10] DMA-API debugging facility, FUJITA Tomonori, (Fri Nov 21, 8:27 pm)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Sat Nov 22, 2:29 am)
Re: [PATCH 0/10] DMA-API debugging facility, Joerg Roedel, (Sat Nov 22, 2:33 am)
Re: [PATCH 0/10] DMA-API debugging facility, FUJITA Tomonori, (Sat Nov 22, 3:16 am)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Thu Feb 5, 3:44 pm)
Re: [PATCH 0/10] DMA-API debugging facility, David Woodhouse, (Wed Feb 25, 1:11 am)
[PATCH] Support DMA-API debugging facility on PowerPC, David Woodhouse, (Wed Jul 1, 6:19 am)
Re: [PATCH] Support DMA-API debugging facility on PowerPC, Christoph Hellwig, (Wed Jul 1, 7:00 am)