From: Chenghai Huang <huangchenghai2@huawei.com>
To: <arnd@arndb.de>, <catalin.marinas@arm.com>, <will@kernel.org>,
<akpm@linux-foundation.org>, <anshuman.khandual@arm.com>,
<ryan.roberts@arm.com>, <andriy.shevchenko@linux.intel.com>,
<herbert@gondor.apana.org.au>, <linux-kernel@vger.kernel.org>,
<linux-arch@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-crypto@vger.kernel.org>, <linux-api@vger.kernel.org>
Cc: <fanghao11@huawei.com>, <shenyang39@huawei.com>,
<liulongfang@huawei.com>, <qianweili@huawei.com>
Subject: [PATCH RFC 2/4] asm-generic/io.h: add io{read,write}128 accessors
Date: Wed, 12 Nov 2025 09:58:44 +0800 [thread overview]
Message-ID: <20251112015846.1842207-3-huangchenghai2@huawei.com> (raw)
In-Reply-To: <20251112015846.1842207-1-huangchenghai2@huawei.com>
From: Weili Qian <qianweili@huawei.com>
Architectures like ARM64 already support 128-bit memory access. Currently,
device drivers implement atomic read and write operations for 128-bit
memory using assembly. This patch adds generic io{read,write}128 access
functions, which will enable device drivers to consistently use
io{read,write}128 for 128-bit access.
Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com>
---
include/asm-generic/io.h | 48 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index ca5a1ce6f0f8..c419021318e6 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -146,6 +146,16 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
#endif
#endif /* CONFIG_64BIT */
+#ifdef CONFIG_ARCH_SUPPORTS_INT128
+#ifndef __raw_read128
+#define __raw_read128 __raw_read128
+static inline u128 __raw_read128(volatile void __iomem *addr)
+{
+ return *(const volatile u128 __force *)addr;
+}
+#endif
+#endif /* CONFIG_ARCH_SUPPORTS_INT128 */
+
#ifndef __raw_writeb
#define __raw_writeb __raw_writeb
static inline void __raw_writeb(u8 value, volatile void __iomem *addr)
@@ -180,6 +190,16 @@ static inline void __raw_writeq(u64 value, volatile void __iomem *addr)
#endif
#endif /* CONFIG_64BIT */
+#ifdef CONFIG_ARCH_SUPPORTS_INT128
+#ifndef __raw_write128
+#define __raw_write128 __raw_write128
+static inline void __raw_write128(u128 value, volatile void __iomem *addr)
+{
+ *(volatile u128 __force *)addr = value;
+}
+#endif
+#endif /* CONFIG_ARCH_SUPPORTS_INT128 */
+
/*
* {read,write}{b,w,l,q}() access little endian memory and return result in
* native endianness.
@@ -917,6 +937,22 @@ static inline u64 ioread64(const volatile void __iomem *addr)
#endif
#endif /* CONFIG_64BIT */
+#ifdef CONFIG_ARCH_SUPPORTS_INT128
+#ifndef ioread128
+#define ioread128 ioread128
+static inline u128 ioread128(const volatile void __iomem *addr)
+{
+ u128 val;
+
+ __io_br();
+ val = __le128_to_cpu((__le128 __force)__raw_read128(addr));
+ __io_ar(val);
+
+ return val;
+}
+#endif
+#endif /* CONFIG_ARCH_SUPPORTS_INT128 */
+
#ifndef iowrite8
#define iowrite8 iowrite8
static inline void iowrite8(u8 value, volatile void __iomem *addr)
@@ -951,6 +987,18 @@ static inline void iowrite64(u64 value, volatile void __iomem *addr)
#endif
#endif /* CONFIG_64BIT */
+#ifdef CONFIG_ARCH_SUPPORTS_INT128
+#ifndef iowrite128
+#define iowrite128 iowrite128
+static inline void iowrite128(u128 value, volatile void __iomem *addr)
+{
+ __io_bw();
+ __raw_write128((u128 __force)__cpu_to_le128(value), addr);
+ __io_aw();
+}
+#endif
+#endif /* CONFIG_ARCH_SUPPORTS_INT128 */
+
#ifndef ioread16be
#define ioread16be ioread16be
static inline u16 ioread16be(const volatile void __iomem *addr)
--
2.33.0
next prev parent reply other threads:[~2025-11-12 1:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-12 1:58 [PATCH RFC 0/4] Introduce 128-bit IO access Chenghai Huang
2025-11-12 1:58 ` [PATCH RFC 1/4] UAPI: Introduce 128-bit types and byteswap operations Chenghai Huang
2025-11-12 1:58 ` Chenghai Huang [this message]
2025-11-12 1:58 ` [PATCH RFC 3/4] io-128-nonatomic: introduce io{read|write}128_{lo_hi|hi_lo} Chenghai Huang
2025-11-12 14:48 ` Ben Dooks
2025-11-13 11:10 ` huangchenghai
2025-11-12 1:58 ` [PATCH RFC 4/4] arm64/io: Add {__raw_read|__raw_write}128 support Chenghai Huang
2025-11-12 12:28 ` Mark Rutland
2025-11-12 14:01 ` David Laight
2025-11-12 14:17 ` Mark Rutland
2025-11-13 14:19 ` huangchenghai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251112015846.1842207-3-huangchenghai2@huawei.com \
--to=huangchenghai2@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=anshuman.khandual@arm.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=fanghao11@huawei.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liulongfang@huawei.com \
--cc=qianweili@huawei.com \
--cc=ryan.roberts@arm.com \
--cc=shenyang39@huawei.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox