RISC-V: Implement ioremap_wc/wt
PATCH 1/1 RISC-V: Implement ioremap_wc/wt
From: Qingfang Deng <[email protected]>
Currently on RISC-V, ioremap_wc/wt uses the default ioremap implementation, which maps the memory as strongly-ordered non-cacheable IO memory on systems with Svpbmt.
To improve performance, map the memory as weakly-ordered non-cacheable normal memory.
--- arch/riscv/include/asm/io.h | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/riscv/include/asm/io.h +8 -0
@@ -133,6 +133,14 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw())#define outsq (addr, buffer, count) __outsq(PCI_IOBASE + (addr), buffer, count)#endif +#ifdef CONFIG_MMU +#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), \ + (_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_NOCACHE) + +#define ioremap_wt ioremap_wc +#endif +#include <asm-generic/io.h> #ifdef CONFIG_MMU
Signature · 1 line
2.34.1
Hi Qingfang,
Quoted 34 lines · Qingfang Deng
From: Qingfang Deng <[email protected]>
Currently on RISC-V, ioremap_wc/wt uses the default ioremap implementation, which maps the memory as strongly-ordered non-cacheable IO memory on systems with Svpbmt.
To improve performance, map the memory as weakly-ordered non-cacheable normal memory.
Signed-off-by Qingfang Deng <[email protected]>--- arch/riscv/include/asm/io.h | 8 ++++++++ 1 file changed, 8 insertions(+)arch/riscv/include/asm/io.h +8
-0@@ -133,6 +133,14 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw())#define outsq (addr, buffer, count) __outsq(PCI_IOBASE + (addr), buffer, count)#endif +#ifdef CONFIG_MMU +#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), \ + (_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_NOCACHE) + +#define ioremap_wt ioremap_wc +#endif +#include <asm-generic/io.h>
Quoted 5 lines
#ifdef
CONFIG_MMU
--
2.34.1
Can you provide specific test data for performance improvement?
Thanks,
Yunhui
Hi Qingfang,
Quoted 28 lines · yunhui cui
Hi Qingfang,
Quoted 23 lines · Qingfang Deng
From: Qingfang Deng <[email protected]>
Currently on RISC-V, ioremap_wc/wt uses the default ioremap implementation, which maps the memory as strongly-ordered non-cacheable IO memory on systems with Svpbmt.
To improve performance, map the memory as weakly-ordered non-cacheable normal memory.
Signed-off-by Qingfang Deng <[email protected]>--- arch/riscv/include/asm/io.h | 8 ++++++++ 1 file changed, 8 insertions(+)arch/riscv/include/asm/io.h +0
-0@@ -133,6 +133,14 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw())#define outsq (addr, buffer, count) __outsq(PCI_IOBASE + (addr), buffer, count)#endif
Quoted 4 lines
arch/riscv/include/asm/io.h __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw()) · line 139
Quoted 4 lines
arch/riscv/include/asm/io.h +4
-0+#ifdef CONFIG_MMU +#define ioremap_wc (addr, size) \ + ioremap_prot((addr), (size), \ + (_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_NOCACHE)
Compared with IO attributes, NC attributes can improve performance, specifically in these aspects: Relaxed Order, Gathering, Supports Read Speculation, Supports Unaligned Access. Therefore, it is necessary to implement ioremap_wc().
Quoted 2 lines
arch/riscv/include/asm/io.h __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw()) · line 141
Quoted 2 lines
arch/riscv/include/asm/io.h +2
-0+ +#define ioremap_wt ioremap_wc
From the perspective of arm64, ioremap_wt should have IO attributes rather than NC attributes, so this line should be removed.
Quoted 12 lines
Quoted 9 lines
arch/riscv/include/asm/io.h +2
-1+#endif +#include <asm-generic/io.h> #ifdef CONFIG_MMU --2.34.1
Can you provide specific test data for performance improvement?
Quoted 2 lines
Thanks,
Yunhui
Thanks,
Yunhui