Skip to content

Commit 9a80243

Browse files
sudeep-hollawildea01
authored andcommitted
arm64: cacheinfo: add support to override cache levels via device tree
The cache hierarchy can be identified through Cache Level ID(CLIDR) architected system register. However in some cases it will provide only the number of cache levels that are integrated into the processor itself. In other words, it can't provide any information about the caches that are external and/or transparent. Some platforms require to export the information about all such external caches to the userspace applications via the sysfs interface. This patch adds support to override the cache levels using device tree to take such external non-architected caches into account. Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Tested-by: Tan Xiaojun <tanxiaojun@huawei.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 5fa2353 commit 9a80243

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

arch/arm64/kernel/cacheinfo.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
8484

8585
static int __init_cache_level(unsigned int cpu)
8686
{
87-
unsigned int ctype, level, leaves;
87+
unsigned int ctype, level, leaves, of_level;
8888
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
8989

9090
for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) {
@@ -97,6 +97,17 @@ static int __init_cache_level(unsigned int cpu)
9797
leaves += (ctype == CACHE_TYPE_SEPARATE) ? 2 : 1;
9898
}
9999

100+
of_level = of_find_last_cache_level(cpu);
101+
if (level < of_level) {
102+
/*
103+
* some external caches not specified in CLIDR_EL1
104+
* the information may be available in the device tree
105+
* only unified external caches are considered here
106+
*/
107+
leaves += (of_level - level);
108+
level = of_level;
109+
}
110+
100111
this_cpu_ci->num_levels = level;
101112
this_cpu_ci->num_leaves = leaves;
102113
return 0;

0 commit comments

Comments
 (0)