Skip to content

Commit 087958a

Browse files
yashshah7palmer-dabbelt
authored andcommitted
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 <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 0ff7c3b commit 087958a

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

arch/riscv/include/asm/cacheinfo.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef _ASM_RISCV_CACHEINFO_H
4+
#define _ASM_RISCV_CACHEINFO_H
5+
6+
#include <linux/cacheinfo.h>
7+
8+
struct riscv_cacheinfo_ops {
9+
const struct attribute_group * (*get_priv_group)(struct cacheinfo
10+
*this_leaf);
11+
};
12+
13+
void riscv_set_cacheinfo_ops(struct riscv_cacheinfo_ops *ops);
14+
15+
#endif /* _ASM_RISCV_CACHEINFO_H */

arch/riscv/kernel/cacheinfo.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@
77
#include <linux/cpu.h>
88
#include <linux/of.h>
99
#include <linux/of_device.h>
10+
#include <asm/cacheinfo.h>
11+
12+
static struct riscv_cacheinfo_ops *rv_cache_ops;
13+
14+
void riscv_set_cacheinfo_ops(struct riscv_cacheinfo_ops *ops)
15+
{
16+
rv_cache_ops = ops;
17+
}
18+
EXPORT_SYMBOL_GPL(riscv_set_cacheinfo_ops);
19+
20+
const struct attribute_group *
21+
cache_get_priv_group(struct cacheinfo *this_leaf)
22+
{
23+
if (rv_cache_ops && rv_cache_ops->get_priv_group)
24+
return rv_cache_ops->get_priv_group(this_leaf);
25+
return NULL;
26+
}
1027

1128
static void ci_leaf_init(struct cacheinfo *this_leaf,
1229
struct device_node *node,

0 commit comments

Comments
 (0)