Skip to content

Commit 582b468

Browse files
jlintonarmctmarinas
authored andcommitted
drivers: base cacheinfo: Add support for ACPI based firmware tables
Call ACPI cache parsing routines from base cacheinfo code if ACPI is enabled. Also stub out cache_setup_acpi and acpi_find_last_cache_level so that individual architectures can enable ACPI topology parsing. Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Vijaya Kumar K <vkilari@codeaurora.org> Tested-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Tested-by: Tomasz Nowicki <Tomasz.Nowicki@cavium.com> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 0ce8223 commit 582b468

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

drivers/base/cacheinfo.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,19 @@ static inline bool cache_leaves_are_shared(struct cacheinfo *this_leaf,
206206
struct cacheinfo *sib_leaf)
207207
{
208208
/*
209-
* For non-DT systems, assume unique level 1 cache, system-wide
209+
* For non-DT/ACPI systems, assume unique level 1 caches, system-wide
210210
* shared caches for all other levels. This will be used only if
211211
* arch specific code has not populated shared_cpu_map
212212
*/
213213
return !(this_leaf->level == 1);
214214
}
215215
#endif
216216

217+
int __weak cache_setup_acpi(unsigned int cpu)
218+
{
219+
return -ENOTSUPP;
220+
}
221+
217222
static int cache_shared_cpu_map_setup(unsigned int cpu)
218223
{
219224
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -227,8 +232,8 @@ static int cache_shared_cpu_map_setup(unsigned int cpu)
227232
if (of_have_populated_dt())
228233
ret = cache_setup_of_node(cpu);
229234
else if (!acpi_disabled)
230-
/* No cache property/hierarchy support yet in ACPI */
231-
ret = -ENOTSUPP;
235+
ret = cache_setup_acpi(cpu);
236+
232237
if (ret)
233238
return ret;
234239

@@ -279,7 +284,8 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
279284
cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map);
280285
cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map);
281286
}
282-
of_node_put(this_leaf->fw_token);
287+
if (of_have_populated_dt())
288+
of_node_put(this_leaf->fw_token);
283289
}
284290
}
285291

include/linux/cacheinfo.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,23 @@ int func(unsigned int cpu) \
9797
struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu);
9898
int init_cache_level(unsigned int cpu);
9999
int populate_cache_leaves(unsigned int cpu);
100+
int cache_setup_acpi(unsigned int cpu);
101+
#ifndef CONFIG_ACPI
102+
/*
103+
* acpi_find_last_cache_level is only called on ACPI enabled
104+
* platforms using the PPTT for topology. This means that if
105+
* the platform supports other firmware configuration methods
106+
* we need to stub out the call when ACPI is disabled.
107+
* ACPI enabled platforms not using PPTT won't be making calls
108+
* to this function so we need not worry about them.
109+
*/
110+
static inline int acpi_find_last_cache_level(unsigned int cpu)
111+
{
112+
return 0;
113+
}
114+
#else
115+
int acpi_find_last_cache_level(unsigned int cpu);
116+
#endif
100117

101118
const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
102119

0 commit comments

Comments
 (0)