Skip to content

Commit 049696a

Browse files
Merge patch series "Add PMEM support for RISC-V"
Anup Patel <[email protected]> says: The Linux NVDIMM PEM drivers require arch support to map and access the persistent memory device. This series adds RISC-V PMEM support using recently added Svpbmt and Zicbom support. * b4-shazam-merge: RISC-V: Enable PMEM drivers RISC-V: Implement arch specific PMEM APIs RISC-V: Fix MEMREMAP_WB for systems with Svpbmt Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents e1ceb09 + 497bcbe commit 049696a

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ config RISCV
2525
select ARCH_HAS_GIGANTIC_PAGE
2626
select ARCH_HAS_KCOV
2727
select ARCH_HAS_MMIOWB
28+
select ARCH_HAS_PMEM_API
2829
select ARCH_HAS_PTE_SPECIAL
2930
select ARCH_HAS_SET_DIRECT_MAP if MMU
3031
select ARCH_HAS_SET_MEMORY if MMU

arch/riscv/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ CONFIG_VIRTIO_MMIO=y
161161
CONFIG_RPMSG_CHAR=y
162162
CONFIG_RPMSG_CTRL=y
163163
CONFIG_RPMSG_VIRTIO=y
164+
CONFIG_LIBNVDIMM=y
164165
CONFIG_EXT4_FS=y
165166
CONFIG_EXT4_FS_POSIX_ACL=y
166167
CONFIG_EXT4_FS_SECURITY=y

arch/riscv/include/asm/io.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,9 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw())
135135

136136
#include <asm-generic/io.h>
137137

138+
#ifdef CONFIG_MMU
139+
#define arch_memremap_wb(addr, size) \
140+
((__force void *)ioremap_prot((addr), (size), _PAGE_KERNEL))
141+
#endif
142+
138143
#endif /* _ASM_RISCV_IO_H */

arch/riscv/mm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj-$(CONFIG_MMU) += fault.o pageattr.o
1414
obj-y += cacheflush.o
1515
obj-y += context.o
1616
obj-y += pgtable.o
17+
obj-y += pmem.o
1718

1819
ifeq ($(CONFIG_MMU),y)
1920
obj-$(CONFIG_SMP) += tlbflush.o

arch/riscv/mm/pmem.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2022 Ventana Micro Systems Inc.
4+
*/
5+
6+
#include <linux/export.h>
7+
#include <linux/libnvdimm.h>
8+
9+
#include <asm/cacheflush.h>
10+
11+
void arch_wb_cache_pmem(void *addr, size_t size)
12+
{
13+
ALT_CMO_OP(clean, addr, size, riscv_cbom_block_size);
14+
}
15+
EXPORT_SYMBOL_GPL(arch_wb_cache_pmem);
16+
17+
void arch_invalidate_pmem(void *addr, size_t size)
18+
{
19+
ALT_CMO_OP(inval, addr, size, riscv_cbom_block_size);
20+
}
21+
EXPORT_SYMBOL_GPL(arch_invalidate_pmem);

0 commit comments

Comments
 (0)