[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250127100407.866238-1-julian@outer-limits.org>
Date: Mon, 27 Jan 2025 11:04:07 +0100
From: Julian Vetter <julian@...er-limits.org>
To: Arnd Bergmann <arnd@...db.de>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
Julian Vetter <julian@...er-limits.org>
Subject: [PATCH] Add io_sync stubs to generic IO memcpy/memset
The recently added IO memcpy and memset functions lack support for
barriers or other sync functions before and/or after the transaction. To
convert more architectures to use the generic IO memcpy and memset
functions, add empty __pre_io_sync and __post_io_sync defines that can
be overwritten by individual architectures if needed.
Signed-off-by: Julian Vetter <julian@...er-limits.org>
---
lib/iomem_copy.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/lib/iomem_copy.c b/lib/iomem_copy.c
index dec7eaea60e0..2e81182dd4d3 100644
--- a/lib/iomem_copy.c
+++ b/lib/iomem_copy.c
@@ -9,6 +9,14 @@
#include <linux/types.h>
#include <linux/unaligned.h>
+#ifndef __pre_io_sync
+#define __pre_io_sync
+#endif
+
+#ifndef __post_io_sync
+#define __post_io_sync
+#endif
+
#ifndef memset_io
/**
* memset_io() - Set a range of I/O memory to a constant value
@@ -24,6 +32,8 @@ void memset_io(volatile void __iomem *addr, int val, size_t count)
qc *= ~0UL / 0xff;
+ __pre_io_sync;
+
while (count && !IS_ALIGNED((long)addr, sizeof(long))) {
__raw_writeb(val, addr);
addr++;
@@ -46,6 +56,8 @@ void memset_io(volatile void __iomem *addr, int val, size_t count)
addr++;
count--;
}
+
+ __post_io_sync;
}
EXPORT_SYMBOL(memset_io);
#endif
@@ -61,6 +73,8 @@ EXPORT_SYMBOL(memset_io);
*/
void memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
{
+ __pre_io_sync;
+
while (count && !IS_ALIGNED((long)src, sizeof(long))) {
*(u8 *)dst = __raw_readb(src);
src++;
@@ -88,6 +102,8 @@ void memcpy_fromio(void *dst, const volatile void __iomem *src, size_t count)
dst++;
count--;
}
+
+ __post_io_sync
}
EXPORT_SYMBOL(memcpy_fromio);
#endif
@@ -103,6 +119,8 @@ EXPORT_SYMBOL(memcpy_fromio);
*/
void memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
{
+ __pre_io_sync;
+
while (count && !IS_ALIGNED((long)dst, sizeof(long))) {
__raw_writeb(*(u8 *)src, dst);
src++;
@@ -129,6 +147,8 @@ void memcpy_toio(volatile void __iomem *dst, const void *src, size_t count)
dst++;
count--;
}
+
+ __post_io_sync;
}
EXPORT_SYMBOL(memcpy_toio);
#endif
--
2.34.1
Powered by blists - more mailing lists