Module Name: src
Committed By: riastradh
Date: Wed Jul 13 00:12:20 UTC 2022
Modified Files:
src/sys/arch/x86/x86: bus_dma.c
Log Message:
x86: Move lfence into _bus_dmamap_sync and comment it.
No functional change intended. This just keeps the bus_dma_* and
_bus_dma_* functions organized more consistently.
To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/x86/x86/bus_dma.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/x86/x86/bus_dma.c
diff -u src/sys/arch/x86/x86/bus_dma.c:1.84 src/sys/arch/x86/x86/bus_dma.c:1.85
--- src/sys/arch/x86/x86/bus_dma.c:1.84 Sat Jan 22 15:10:32 2022
+++ src/sys/arch/x86/x86/bus_dma.c Wed Jul 13 00:12:20 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: bus_dma.c,v 1.84 2022/01/22 15:10:32 skrll Exp $ */
+/* $NetBSD: bus_dma.c,v 1.85 2022/07/13 00:12:20 riastradh Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2007, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.84 2022/01/22 15:10:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus_dma.c,v 1.85 2022/07/13 00:12:20 riastradh Exp $");
/*
* The following is included because _bus_dma_uiomove is derived from
@@ -816,6 +816,16 @@ _bus_dmamap_sync(bus_dma_tag_t t, bus_dm
#endif
/*
+ * The caller has been alerted to DMA completion by reading a
+ * register or DMA descriptor, and is about to read out of the
+ * DMA memory buffer that the device filled. LFENCE ensures
+ * that these happen in order, so that the caller doesn't
+ * proceed to read any stale data from cache or speculation.
+ */
+ if (ops & BUS_DMASYNC_POSTREAD)
+ x86_lfence();
+
+ /*
* If we're not bouncing, just return; nothing to do.
*/
if (len == 0 || cookie == NULL ||
@@ -1340,9 +1350,6 @@ bus_dmamap_sync(bus_dma_tag_t t, bus_dma
return;
}
- if (ops & BUS_DMASYNC_POSTREAD)
- x86_lfence();
-
_bus_dmamap_sync(t, p, o, l, ops);
}