[PATCH 1/4] Revert "dma: debug: detect repeated DMA sync"

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Sep 10 04:48:29 PDT 2024


It turns out this check is too restrictive. The DMA API doesn't require
a 1:1 relation between mapping and sync. It's permissible to map a big
chunk and then managing it as a number of buffers that are synced
individually.

This is currently the case with the Designware MAC driver and having
this check here leads to a copious amount of false positives.

A proper check would involve keeping account of every individual cache
line and assigning it either a device or CPU owned flag in the common
code.

We'll implement this on top of KASAN in the follow-up commit, so let's
revert commit 1ad4b32702ddc3b801e8cd35441d2a9b3a41bb19 first to have
a clean slate.

Fixes: 1ad4b32702dd ("dma: debug: detect repeated DMA sync")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/dma/debug.c | 22 ++--------------------
 1 file changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/dma/debug.c b/drivers/dma/debug.c
index befe837d6cd8..7bf0be1e1ff3 100644
--- a/drivers/dma/debug.c
+++ b/drivers/dma/debug.c
@@ -13,7 +13,6 @@ struct dma_debug_entry {
 	dma_addr_t       dev_addr;
 	size_t           size;
 	int              direction;
-	bool             dev_owned;
 };
 
 static const char *dir2name[] = {
@@ -123,7 +122,6 @@ void debug_dma_map(struct device *dev, void *addr,
 	entry->dev_addr = dev_addr;
 	entry->size = size;
 	entry->direction = direction;
-	entry->dev_owned = true;
 
 	list_add(&entry->list, &dma_mappings);
 
@@ -166,17 +164,9 @@ void debug_dma_sync_single_for_cpu(struct device *dev,
 	struct dma_debug_entry *entry;
 
 	entry = dma_debug_entry_find(dev, dma_handle, size);
-	if (!entry) {
+	if (!entry)
 		dma_dev_warn(dev, "sync for CPU of never-mapped %s buffer 0x%llx+0x%zx!\n",
 			     dir2name[direction], (u64)dma_handle, size);
-		return;
-	}
-
-	if (!entry->dev_owned)
-		dma_dev_warn(dev, "unexpected sync for CPU of already CPU-mapped %s buffer 0x%llx+0x%zx!\n",
-			     dir2name[direction], (u64)dma_handle, size);
-
-	entry->dev_owned = false;
 }
 
 void debug_dma_sync_single_for_device(struct device *dev,
@@ -192,15 +182,7 @@ void debug_dma_sync_single_for_device(struct device *dev,
 	 * corruption
 	 */
 	entry = dma_debug_entry_find(dev, dma_handle, size);
-	if (!entry) {
+	if (!entry)
 		dma_dev_warn(dev, "Syncing for device of never-mapped %s buffer 0x%llx+0x%zx!\n",
 			     dir2name[direction], (u64)dma_handle, size);
-		return;
-	}
-
-	if (entry->dev_owned)
-		dma_dev_warn(dev, "unexpected sync for device of already device-mapped %s buffer 0x%llx+0x%zx!\n",
-			     dir2name[direction], (u64)dma_handle, size);
-
-	entry->dev_owned = true;
 }
-- 
2.39.2




More information about the barebox mailing list