* [PATCH] dma-debug: don't report false positives with DMA_BOUNCE_UNALIGNED_KMALLOC [not found] <CGME20251009141522eucas1p2c89eadd93fb571c557d3d70975d8ae4f@eucas1p2.samsung.com> @ 2025-10-09 14:15 ` Marek Szyprowski 2025-10-10 10:40 ` Catalin Marinas 0 siblings, 1 reply; 3+ messages in thread From: Marek Szyprowski @ 2025-10-09 14:15 UTC (permalink / raw) To: iommu, linux-kernel Cc: Marek Szyprowski, Robin Murphy, Christoph Hellwig, Andrew Morton, Catalin Marinas Commit 370645f41e6e ("dma-mapping: force bouncing if the kmalloc() size is not cache-line-aligned") introduced DMA_BOUNCE_UNALIGNED_KMALLOC feature and lets architecture specific code to 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. Fixes: 370645f41e6e ("dma-mapping: force bouncing if the kmalloc() size is not cache-line-aligned") Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> --- kernel/dma/debug.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index b82399437db0..266598d837c5 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -23,6 +23,7 @@ #include <linux/ctype.h> #include <linux/list.h> #include <linux/slab.h> +#include <linux/swiotlb.h> #include <asm/sections.h> #include "debug.h" @@ -594,7 +595,9 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs) if (rc == -ENOMEM) { pr_err_once("cacheline tracking ENOMEM, dma-debug disabled\n"); global_disable = true; - } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) { + } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && + !(IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && + is_swiotlb_allocated())) { err_printk(entry->dev, entry, "cacheline tracking EEXIST, overlapping mappings aren't supported\n"); } -- 2.34.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dma-debug: don't report false positives with DMA_BOUNCE_UNALIGNED_KMALLOC 2025-10-09 14:15 ` [PATCH] dma-debug: don't report false positives with DMA_BOUNCE_UNALIGNED_KMALLOC Marek Szyprowski @ 2025-10-10 10:40 ` Catalin Marinas 2025-10-10 17:24 ` Marek Szyprowski 0 siblings, 1 reply; 3+ messages in thread From: Catalin Marinas @ 2025-10-10 10:40 UTC (permalink / raw) To: Marek Szyprowski Cc: iommu, linux-kernel, Robin Murphy, Christoph Hellwig, Andrew Morton On Thu, Oct 09, 2025 at 04:15:08PM +0200, Marek Szyprowski wrote: > @@ -594,7 +595,9 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs) > if (rc == -ENOMEM) { > pr_err_once("cacheline tracking ENOMEM, dma-debug disabled\n"); > global_disable = true; > - } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) { > + } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && > + !(IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && > + is_swiotlb_allocated())) { Maybe use is_swiotlb_active(entry->dev) instead for completeness. Either way: Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dma-debug: don't report false positives with DMA_BOUNCE_UNALIGNED_KMALLOC 2025-10-10 10:40 ` Catalin Marinas @ 2025-10-10 17:24 ` Marek Szyprowski 0 siblings, 0 replies; 3+ messages in thread From: Marek Szyprowski @ 2025-10-10 17:24 UTC (permalink / raw) To: Catalin Marinas Cc: iommu, linux-kernel, Robin Murphy, Christoph Hellwig, Andrew Morton On 10.10.2025 12:40, Catalin Marinas wrote: > On Thu, Oct 09, 2025 at 04:15:08PM +0200, Marek Szyprowski wrote: >> @@ -594,7 +595,9 @@ static void add_dma_entry(struct dma_debug_entry *entry, unsigned long attrs) >> if (rc == -ENOMEM) { >> pr_err_once("cacheline tracking ENOMEM, dma-debug disabled\n"); >> global_disable = true; >> - } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC)) { >> + } else if (rc == -EEXIST && !(attrs & DMA_ATTR_SKIP_CPU_SYNC) && >> + !(IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && >> + is_swiotlb_allocated())) { > Maybe use is_swiotlb_active(entry->dev) instead for completeness. Either > way: > > Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Thanks for suggestion. is_swiotlb_active() looks a bit more appropriate in this context. Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-10 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20251009141522eucas1p2c89eadd93fb571c557d3d70975d8ae4f@eucas1p2.samsung.com>
2025-10-09 14:15 ` [PATCH] dma-debug: don't report false positives with DMA_BOUNCE_UNALIGNED_KMALLOC Marek Szyprowski
2025-10-10 10:40 ` Catalin Marinas
2025-10-10 17:24 ` Marek Szyprowski
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.