]> www.infradead.org Git - users/hch/misc.git/commitdiff
riscv: introduce ioremap_wc()
authorYunhui Cui <cuiyunhui@bytedance.com>
Tue, 22 Jul 2025 09:15:04 +0000 (17:15 +0800)
committerPaul Walmsley <pjw@kernel.org>
Tue, 16 Sep 2025 22:24:27 +0000 (16:24 -0600)
Compared with IO attributes, NC attributes can improve performance,
specifically in these aspects: Relaxed Order, Gathering, Supports Read
Speculation, Supports Unaligned Access.

Signed-off-by: Yunhui Cui <cuiyunhui@bytedance.com>
Signed-off-by: Qingfang Deng <qingfang.deng@siflower.com.cn>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20250722091504.45974-2-cuiyunhui@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/include/asm/io.h
arch/riscv/include/asm/pgtable.h

index a0e51840b9db43c8ddf86eebb2b6c00bd54fe878..09bb5f57a9d3460ae0e8798eda692d67bd8acf4e 100644 (file)
 #ifdef CONFIG_MMU
 #define IO_SPACE_LIMIT         (PCI_IO_SIZE - 1)
 #define PCI_IOBASE             ((void __iomem *)PCI_IO_START)
+
+#define ioremap_wc(addr, size) \
+       ioremap_prot((addr), (size), __pgprot(_PAGE_KERNEL_NC))
+
 #endif /* CONFIG_MMU */
 
 /*
index 91697fbf1f9013005800f713797e4b6b1fc8d312..3d17399a06c772f8278b39e2989cb4b761349010 100644 (file)
@@ -203,6 +203,7 @@ extern struct pt_alloc_ops pt_ops __meminitdata;
 
 #define PAGE_TABLE             __pgprot(_PAGE_TABLE)
 
+#define _PAGE_KERNEL_NC ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_NOCACHE)
 #define _PAGE_IOREMAP  ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_IO)
 #define PAGE_KERNEL_IO         __pgprot(_PAGE_IOREMAP)