Skip to content

Commit 3aa1a7d

Browse files
Merge patch series "RISC-V: Select ACPI PPTT drivers"
This series adds support for ACPI PPTT via cacheinfo. * b4-shazam-merge: RISC-V: Select ACPI PPTT drivers riscv: cacheinfo: initialize cacheinfo's level and type from ACPI PPTT riscv: cacheinfo: remove the useless input parameter (node) of ci_leaf_init() Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents ec1dc56 + 66381d3 commit 3aa1a7d

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config 32BIT
1313
config RISCV
1414
def_bool y
1515
select ACPI_GENERIC_GSI if ACPI
16+
select ACPI_PPTT if ACPI
1617
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
1718
select ACPI_SPCR_TABLE if ACPI
1819
select ARCH_DMA_DEFAULT_COHERENT

arch/riscv/kernel/cacheinfo.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (C) 2017 SiFive
44
*/
55

6+
#include <linux/acpi.h>
67
#include <linux/cpu.h>
78
#include <linux/of.h>
89
#include <asm/cacheinfo.h>
@@ -64,7 +65,6 @@ uintptr_t get_cache_geometry(u32 level, enum cache_type type)
6465
}
6566

6667
static void ci_leaf_init(struct cacheinfo *this_leaf,
67-
struct device_node *node,
6868
enum cache_type type, unsigned int level)
6969
{
7070
this_leaf->level = level;
@@ -79,12 +79,33 @@ int populate_cache_leaves(unsigned int cpu)
7979
struct device_node *prev = NULL;
8080
int levels = 1, level = 1;
8181

82+
if (!acpi_disabled) {
83+
int ret, fw_levels, split_levels;
84+
85+
ret = acpi_get_cache_info(cpu, &fw_levels, &split_levels);
86+
if (ret)
87+
return ret;
88+
89+
BUG_ON((split_levels > fw_levels) ||
90+
(split_levels + fw_levels > this_cpu_ci->num_leaves));
91+
92+
for (; level <= this_cpu_ci->num_levels; level++) {
93+
if (level <= split_levels) {
94+
ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
95+
ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
96+
} else {
97+
ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level);
98+
}
99+
}
100+
return 0;
101+
}
102+
82103
if (of_property_read_bool(np, "cache-size"))
83-
ci_leaf_init(this_leaf++, np, CACHE_TYPE_UNIFIED, level);
104+
ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level);
84105
if (of_property_read_bool(np, "i-cache-size"))
85-
ci_leaf_init(this_leaf++, np, CACHE_TYPE_INST, level);
106+
ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
86107
if (of_property_read_bool(np, "d-cache-size"))
87-
ci_leaf_init(this_leaf++, np, CACHE_TYPE_DATA, level);
108+
ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
88109

89110
prev = np;
90111
while ((np = of_find_next_cache_node(np))) {
@@ -97,11 +118,11 @@ int populate_cache_leaves(unsigned int cpu)
97118
if (level <= levels)
98119
break;
99120
if (of_property_read_bool(np, "cache-size"))
100-
ci_leaf_init(this_leaf++, np, CACHE_TYPE_UNIFIED, level);
121+
ci_leaf_init(this_leaf++, CACHE_TYPE_UNIFIED, level);
101122
if (of_property_read_bool(np, "i-cache-size"))
102-
ci_leaf_init(this_leaf++, np, CACHE_TYPE_INST, level);
123+
ci_leaf_init(this_leaf++, CACHE_TYPE_INST, level);
103124
if (of_property_read_bool(np, "d-cache-size"))
104-
ci_leaf_init(this_leaf++, np, CACHE_TYPE_DATA, level);
125+
ci_leaf_init(this_leaf++, CACHE_TYPE_DATA, level);
105126
levels = level;
106127
}
107128
of_node_put(np);

0 commit comments

Comments
 (0)