Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cacheinfo: Add use_arch[|_cache]_info field/function

The cache information can be extracted from either a Device
Tree (DT), the PPTT ACPI table, or arch registers (clidr_el1
for arm64).

The clidr_el1 register is used only if DT/ACPI information is not
available. It does not states how caches are shared among CPUs.

Add a use_arch_cache_info field/function to identify when the
DT/ACPI doesn't provide cache information. Use this information
to assume L1 caches are privates and L2 and higher are shared among
all CPUs.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Link: https://lore.kernel.org/r/20230414081453.244787-5-pierre.gondois@arm.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

authored by

Pierre Gondois and committed by
Sudeep Holla
ef9f643a 35223401

+16 -2
+10 -2
drivers/base/cacheinfo.c
··· 28 28 #define per_cpu_cacheinfo_idx(cpu, idx) \ 29 29 (per_cpu_cacheinfo(cpu) + (idx)) 30 30 31 + /* Set if no cache information is found in DT/ACPI. */ 32 + static bool use_arch_info; 33 + 31 34 struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu) 32 35 { 33 36 return ci_cacheinfo(cpu); ··· 43 40 * For non DT/ACPI systems, assume unique level 1 caches, 44 41 * system-wide shared caches for all other levels. 45 42 */ 46 - if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI))) 43 + if (!(IS_ENABLED(CONFIG_OF) || IS_ENABLED(CONFIG_ACPI)) || 44 + use_arch_info) 47 45 return (this_leaf->level != 1) && (sib_leaf->level != 1); 48 46 49 47 if ((sib_leaf->attributes & CACHE_ID) && ··· 347 343 else if (!acpi_disabled) 348 344 ret = cache_setup_acpi(cpu); 349 345 346 + // Assume there is no cache information available in DT/ACPI from now. 347 + if (ret && use_arch_cache_info()) 348 + use_arch_info = true; 349 + 350 350 return ret; 351 351 } 352 352 ··· 369 361 * to update the shared cpu_map if the cache attributes were 370 362 * populated early before all the cpus are brought online 371 363 */ 372 - if (!last_level_cache_is_valid(cpu)) { 364 + if (!last_level_cache_is_valid(cpu) && !use_arch_info) { 373 365 ret = cache_setup_properties(cpu); 374 366 if (ret) 375 367 return ret;
+6
include/linux/cacheinfo.h
··· 131 131 return -1; 132 132 } 133 133 134 + #ifdef CONFIG_ARM64 135 + #define use_arch_cache_info() (true) 136 + #else 137 + #define use_arch_cache_info() (false) 138 + #endif 139 + 134 140 #endif /* _LINUX_CACHEINFO_H */