2022-11-14 02:05:35 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2022 Ventana Micro Systems Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/export.h>
|
|
|
|
#include <linux/libnvdimm.h>
|
|
|
|
|
|
|
|
#include <asm/cacheflush.h>
|
2023-08-18 06:57:20 -07:00
|
|
|
#include <asm/dma-noncoherent.h>
|
2022-11-14 02:05:35 -07:00
|
|
|
|
|
|
|
void arch_wb_cache_pmem(void *addr, size_t size)
|
|
|
|
{
|
2023-08-18 06:57:20 -07:00
|
|
|
#ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS
|
|
|
|
if (unlikely(noncoherent_cache_ops.wback)) {
|
|
|
|
noncoherent_cache_ops.wback(virt_to_phys(addr), size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2023-09-15 08:40:44 -07:00
|
|
|
ALT_CMO_OP(CLEAN, addr, size, riscv_cbom_block_size);
|
2022-11-14 02:05:35 -07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(arch_wb_cache_pmem);
|
|
|
|
|
|
|
|
void arch_invalidate_pmem(void *addr, size_t size)
|
|
|
|
{
|
2023-08-18 06:57:20 -07:00
|
|
|
#ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS
|
|
|
|
if (unlikely(noncoherent_cache_ops.inv)) {
|
|
|
|
noncoherent_cache_ops.inv(virt_to_phys(addr), size);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
2023-09-15 08:40:44 -07:00
|
|
|
ALT_CMO_OP(INVAL, addr, size, riscv_cbom_block_size);
|
2022-11-14 02:05:35 -07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(arch_invalidate_pmem);
|