mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-18 02:46:06 +00:00
riscv: cacheinfo: Implement cache_get_priv_group with a generic ops structure
Implement cache_get_priv_group() that will make use of a generic ops structure to return a private attribute group for custom cache info. Using riscv_set_cacheinfo_ops() users can hook their own custom function to return the private attribute group for cacheinfo. In future we can add more ops to this generic ops structure for SOC specific cacheinfo. Signed-off-by: Yash Shah <yash.shah@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
This commit is contained in:
parent
0ff7c3b331
commit
087958a176
15
arch/riscv/include/asm/cacheinfo.h
Normal file
15
arch/riscv/include/asm/cacheinfo.h
Normal file
@ -0,0 +1,15 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#ifndef _ASM_RISCV_CACHEINFO_H
|
||||
#define _ASM_RISCV_CACHEINFO_H
|
||||
|
||||
#include <linux/cacheinfo.h>
|
||||
|
||||
struct riscv_cacheinfo_ops {
|
||||
const struct attribute_group * (*get_priv_group)(struct cacheinfo
|
||||
*this_leaf);
|
||||
};
|
||||
|
||||
void riscv_set_cacheinfo_ops(struct riscv_cacheinfo_ops *ops);
|
||||
|
||||
#endif /* _ASM_RISCV_CACHEINFO_H */
|
@ -7,6 +7,23 @@
|
||||
#include <linux/cpu.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <asm/cacheinfo.h>
|
||||
|
||||
static struct riscv_cacheinfo_ops *rv_cache_ops;
|
||||
|
||||
void riscv_set_cacheinfo_ops(struct riscv_cacheinfo_ops *ops)
|
||||
{
|
||||
rv_cache_ops = ops;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(riscv_set_cacheinfo_ops);
|
||||
|
||||
const struct attribute_group *
|
||||
cache_get_priv_group(struct cacheinfo *this_leaf)
|
||||
{
|
||||
if (rv_cache_ops && rv_cache_ops->get_priv_group)
|
||||
return rv_cache_ops->get_priv_group(this_leaf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ci_leaf_init(struct cacheinfo *this_leaf,
|
||||
struct device_node *node,
|
||||
|
Loading…
x
Reference in New Issue
Block a user