Skip to content

Commit a49ab90

Browse files
avpatelpalmer-dabbelt
authored andcommitted
RISC-V: Implement arch specific PMEM APIs
The NVDIMM PMEM driver expects arch specific APIs for cache maintenance and if arch does not provide these APIs then NVDIMM PMEM driver will always use MEMREMAP_WT to map persistent memory which in-turn maps as UC memory type defined by the RISC-V Svpbmt specification. Now that the Svpbmt and Zicbom support is available in RISC-V kernel, we implement PMEM APIs using ALT_CMO_OP() macros so that the NVDIMM PMEM driver can use MEMREMAP_WB to map persistent memory. Co-developed-by: Mayuresh Chitale <[email protected]> Signed-off-by: Mayuresh Chitale <[email protected]> Signed-off-by: Anup Patel <[email protected]> Acked-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent b91676f commit a49ab90

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-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/mm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ obj-y += extable.o
1313
obj-$(CONFIG_MMU) += fault.o pageattr.o
1414
obj-y += cacheflush.o
1515
obj-y += context.o
16+
obj-y += pmem.o
1617

1718
ifeq ($(CONFIG_MMU),y)
1819
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)