xref: /openbmc/linux/arch/riscv/mm/pmem.c (revision 3ddc8b84)
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 #include <asm/dma-noncoherent.h>
11 
12 void arch_wb_cache_pmem(void *addr, size_t size)
13 {
14 #ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS
15 	if (unlikely(noncoherent_cache_ops.wback)) {
16 		noncoherent_cache_ops.wback(virt_to_phys(addr), size);
17 		return;
18 	}
19 #endif
20 	ALT_CMO_OP(clean, addr, size, riscv_cbom_block_size);
21 }
22 EXPORT_SYMBOL_GPL(arch_wb_cache_pmem);
23 
24 void arch_invalidate_pmem(void *addr, size_t size)
25 {
26 #ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS
27 	if (unlikely(noncoherent_cache_ops.inv)) {
28 		noncoherent_cache_ops.inv(virt_to_phys(addr), size);
29 		return;
30 	}
31 #endif
32 	ALT_CMO_OP(inval, addr, size, riscv_cbom_block_size);
33 }
34 EXPORT_SYMBOL_GPL(arch_invalidate_pmem);
35