@@ -158,6 +158,7 @@ dma_sync_single_for_cpu(struct device *hwdev, dma_addr_t dma_handle,
BUG_ON(!valid_dma_direction(direction));
if (ops->sync_single_for_cpu)
ops->sync_single_for_cpu(hwdev, dma_handle, size, direction);
+ debug_sync_single_for_cpu(hwdev, dma_handle, size, direction);
flush_write_buffers();
}
@@ -170,6 +171,7 @@ dma_sync_single_for_device(struct device *hwdev, dma_addr_t dma_handle,
BUG_ON(!valid_dma_direction(direction));
if (ops->sync_single_for_device)
ops->sync_single_for_device(hwdev, dma_handle, size, direction);
+ debug_sync_single_for_device(hwdev, dma_handle, size, direction);
flush_write_buffers();
}
@@ -67,6 +67,14 @@ extern
void debug_free_coherent(struct device *dev, size_t size,
void *virt, dma_addr_t addr);
+extern
+void debug_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+ size_t size, int direction);
+
+extern
+void debug_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+ size_t size, int direction);
+
#else /* CONFIG_DMA_API_DEBUG */
static inline
@@ -110,6 +118,18 @@ void debug_free_coherent(struct device *dev, size_t size,
{
}
+static inline
+void debug_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+ size_t size, int direction)
+{
+}
+
+static inline
+void debug_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+ size_t size, int direction)
+{
+}
+
#endif /* CONFIG_DMA_API_DEBUG */
#endif /* __ASM_X86_DMA_DEBUG */
@@ -408,3 +408,17 @@ void debug_free_coherent(struct device *dev, size_t size,
}
EXPORT_SYMBOL(debug_free_coherent);
+void debug_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle,
+ size_t size, int direction)
+{
+ check_sync(dev, dma_handle, size, 0, direction, true);
+}
+EXPORT_SYMBOL(debug_sync_single_for_cpu);
+
+void debug_sync_single_for_device(struct device *dev, dma_addr_t dma_handle,
+ size_t size, int direction)
+{
+ check_sync(dev, dma_handle, size, 0, direction, false);
+}
+EXPORT_SYMBOL(debug_sync_single_for_device);
+
Impact: detect bugs in sync_single* usage Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> --- arch/x86/include/asm/dma-mapping.h | 2 ++ arch/x86/include/asm/dma_debug.h | 20 ++++++++++++++++++++ arch/x86/kernel/pci-dma-debug.c | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 0 deletions(-)