Skip to content

Commit 6a24915

Browse files
Song Shuaipalmer-dabbelt
authored andcommitted
Revert "riscv: Set more data to cacheinfo"
This reverts commit baf7cbd. There are some duplicate cache attributes populations executed in both ci_leaf_init() and later cache_setup_properties(). Revert the commit baf7cbd ("riscv: Set more data to cacheinfo") to setup only the level and type attributes at this early place. Signed-off-by: Song Shuai <suagrfillet@gmail.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230308064734.512457-1-suagrfillet@gmail.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 9c2598d commit 6a24915

1 file changed

Lines changed: 15 additions & 51 deletions

File tree

arch/riscv/kernel/cacheinfo.c

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -64,53 +64,12 @@ uintptr_t get_cache_geometry(u32 level, enum cache_type type)
6464
0;
6565
}
6666

67-
static void ci_leaf_init(struct cacheinfo *this_leaf, enum cache_type type,
68-
unsigned int level, unsigned int size,
69-
unsigned int sets, unsigned int line_size)
67+
static void ci_leaf_init(struct cacheinfo *this_leaf,
68+
struct device_node *node,
69+
enum cache_type type, unsigned int level)
7070
{
7171
this_leaf->level = level;
7272
this_leaf->type = type;
73-
this_leaf->size = size;
74-
this_leaf->number_of_sets = sets;
75-
this_leaf->coherency_line_size = line_size;
76-
77-
/*
78-
* If the cache is fully associative, there is no need to
79-
* check the other properties.
80-
*/
81-
if (sets == 1)
82-
return;
83-
84-
/*
85-
* Set the ways number for n-ways associative, make sure
86-
* all properties are big than zero.
87-
*/
88-
if (sets > 0 && size > 0 && line_size > 0)
89-
this_leaf->ways_of_associativity = (size / sets) / line_size;
90-
}
91-
92-
static void fill_cacheinfo(struct cacheinfo **this_leaf,
93-
struct device_node *node, unsigned int level)
94-
{
95-
unsigned int size, sets, line_size;
96-
97-
if (!of_property_read_u32(node, "cache-size", &size) &&
98-
!of_property_read_u32(node, "cache-block-size", &line_size) &&
99-
!of_property_read_u32(node, "cache-sets", &sets)) {
100-
ci_leaf_init((*this_leaf)++, CACHE_TYPE_UNIFIED, level, size, sets, line_size);
101-
}
102-
103-
if (!of_property_read_u32(node, "i-cache-size", &size) &&
104-
!of_property_read_u32(node, "i-cache-sets", &sets) &&
105-
!of_property_read_u32(node, "i-cache-block-size", &line_size)) {
106-
ci_leaf_init((*this_leaf)++, CACHE_TYPE_INST, level, size, sets, line_size);
107-
}
108-
109-
if (!of_property_read_u32(node, "d-cache-size", &size) &&
110-
!of_property_read_u32(node, "d-cache-sets", &sets) &&
111-
!of_property_read_u32(node, "d-cache-block-size", &line_size)) {
112-
ci_leaf_init((*this_leaf)++, CACHE_TYPE_DATA, level, size, sets, line_size);
113-
}
11473
}
11574

11675
int populate_cache_leaves(unsigned int cpu)
@@ -121,24 +80,29 @@ int populate_cache_leaves(unsigned int cpu)
12180
struct device_node *prev = NULL;
12281
int levels = 1, level = 1;
12382

124-
/* Level 1 caches in cpu node */
125-
fill_cacheinfo(&this_leaf, np, level);
83+
if (of_property_read_bool(np, "cache-size"))
84+
ci_leaf_init(this_leaf++, np, CACHE_TYPE_UNIFIED, level);
85+
if (of_property_read_bool(np, "i-cache-size"))
86+
ci_leaf_init(this_leaf++, np, CACHE_TYPE_INST, level);
87+
if (of_property_read_bool(np, "d-cache-size"))
88+
ci_leaf_init(this_leaf++, np, CACHE_TYPE_DATA, level);
12689

127-
/* Next level caches in cache nodes */
12890
prev = np;
12991
while ((np = of_find_next_cache_node(np))) {
13092
of_node_put(prev);
13193
prev = np;
132-
13394
if (!of_device_is_compatible(np, "cache"))
13495
break;
13596
if (of_property_read_u32(np, "cache-level", &level))
13697
break;
13798
if (level <= levels)
13899
break;
139-
140-
fill_cacheinfo(&this_leaf, np, level);
141-
100+
if (of_property_read_bool(np, "cache-size"))
101+
ci_leaf_init(this_leaf++, np, CACHE_TYPE_UNIFIED, level);
102+
if (of_property_read_bool(np, "i-cache-size"))
103+
ci_leaf_init(this_leaf++, np, CACHE_TYPE_INST, level);
104+
if (of_property_read_bool(np, "d-cache-size"))
105+
ci_leaf_init(this_leaf++, np, CACHE_TYPE_DATA, level);
142106
levels = level;
143107
}
144108
of_node_put(np);

0 commit comments

Comments
 (0)