Skip to content

Commit 85d65fb

Browse files
mszyprowgregkh
authored andcommitted
dma-debug: don't report false positives with DMA_BOUNCE_UNALIGNED_KMALLOC
commit 03521c8 upstream. Commit 370645f ("dma-mapping: force bouncing if the kmalloc() size is not cache-line-aligned") introduced DMA_BOUNCE_UNALIGNED_KMALLOC feature and permitted architecture specific code configure kmalloc slabs with sizes smaller than the value of dma_get_cache_alignment(). When that feature is enabled, the physical address of some small kmalloc()-ed buffers might be not aligned to the CPU cachelines, thus not really suitable for typical DMA. To properly handle that case a SWIOTLB buffer bouncing is used, so no CPU cache corruption occurs. When that happens, there is no point reporting a false-positive DMA-API warning that the buffer is not properly aligned, as this is not a client driver fault. [[email protected]: replace is_swiotlb_allocated() with is_swiotlb_active(), per Catalin] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 370645f ("dma-mapping: force bouncing if the kmalloc() size is not cache-line-aligned") Signed-off-by: Marek Szyprowski <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Inki Dae <[email protected]> Cc: Robin Murohy <[email protected]> Cc: "Isaac J. Manjarres" <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3ce82b1 commit 85d65fb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kernel/dma/debug.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/ctype.h>
2424
#include <linux/list.h>
2525
#include <linux/slab.h>
26+
#include <linux/swiotlb.h>
2627
#include <asm/sections.h>
2728
#include "debug.h"
2829

@@ -594,7 +595,9 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs)
594595
if (rc == -ENOMEM) {
595596
pr_err_once("cacheline tracking ENOMEM, dma-debug disabled\n");
596597
global_disable = true;
597-
} else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) {
598+
} else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) &&
599+
!(IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) &&
600+
is_swiotlb_active(entry->dev))) {
598601
err_printk(entry->dev, entry,
599602
"cacheline tracking EEXIST, overlapping mappings aren't supported\n");
600603
}

0 commit comments

Comments
 (0)