@@ -43,6 +43,30 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
this_leaf->type = type;
}
+static const struct midr_range allow_list[] = {
+ MIDR_ALL_VERSIONS(MIDR_FUJITSU_A64FX),
+};
+
+/*
+ * This function works only for FUJITSU A64FX processor.
+ * If CONFIG_ALLOW_INCOMPLETE_CACHE_SYSFS is not defined, do nothing.
+ *
+ * Hardware prefetch functions need cache sysfs directory and cache
+ * level/type information. In ARM processor, these information can be
+ * obtained from registers even without PPTT. Therefore, we set the
+ * cpu_map_populated to true to create cache sysfs directory, if the
+ * machine doesn't have PPTT.
+ */
+static void allow_incomplete_cache_sysfs(struct cpu_cacheinfo *cpu_ci)
+{
+ if (!is_midr_in_range_list(read_cpuid_id(), allow_list))
+ return;
+
+ if (!acpi_disabled)
+ if (!acpi_has_pptt())
+ enable_cpu_map_populated(cpu_ci);
+}
+
int init_cache_level(unsigned int cpu)
{
unsigned int ctype, level, leaves, fw_level;
@@ -95,5 +119,8 @@ int populate_cache_leaves(unsigned int cpu)
ci_leaf_init(this_leaf++, type, level);
}
}
+
+ allow_incomplete_cache_sysfs(this_cpu_ci);
+
return 0;
}
@@ -838,3 +838,21 @@ int find_acpi_cpu_topology_hetero_id(unsigned int cpu)
return find_acpi_cpu_topology_tag(cpu, PPTT_ABORT_PACKAGE,
ACPI_PPTT_ACPI_IDENTICAL);
}
+
+/**
+ * acpi_has_pptt() - Determine if ACPI has PPTT table or not
+ *
+ * Return: true if ACPI has PPTT, false if ACPI doesn't have PPTT.
+ */
+bool acpi_has_pptt(void)
+{
+ struct acpi_table_header *table;
+ acpi_status status;
+
+ status = acpi_get_table(ACPI_SIG_PPTT, 0, &table);
+ if (ACPI_FAILURE(status))
+ return false;
+
+ acpi_put_table(table);
+ return true;
+}
@@ -1391,6 +1391,7 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu);
int find_acpi_cpu_topology_package(unsigned int cpu);
int find_acpi_cpu_topology_hetero_id(unsigned int cpu);
int find_acpi_cpu_cache_topology(unsigned int cpu, int level);
+bool acpi_has_pptt(void);
#else
static inline int acpi_pptt_cpu_is_thread(unsigned int cpu)
{
@@ -1416,6 +1417,10 @@ static inline int find_acpi_cpu_cache_topology(unsigned int cpu, int level)
{
return -EINVAL;
}
+static inline bool acpi_has_pptt(void)
+{
+ return false;
+}
#endif
#ifdef CONFIG_ACPI_PCC
@@ -99,6 +99,16 @@ static inline int acpi_find_last_cache_level(unsigned int cpu)
int acpi_find_last_cache_level(unsigned int cpu);
#endif
+#ifndef CONFIG_ALLOW_INCOMPLETE_CACHE_SYSFS
+#define enable_cpu_map_populated(cpu_ci)
+#else
+static inline void enable_cpu_map_populated(struct cpu_cacheinfo *cpu_ci)
+{
+ cpu_ci->cpu_map_populated = true;
+}
+#endif
+
+
const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf);
/*
Create a cache sysfs directory without ACPI PPTT if the CPU model is A64FX and CONFIG_ALLOW_INCOMPLETE_CACHE_SYSFS is true. Currentry, CONFIG_ALLOW_INCOMPLETE_CACHE_SYSFS is set only when CONFIG_A64FX_HWPF_CONTROL is enabled. Hardware prefetch control driver need cache sysfs directory and cache level/type information. In ARM processor, these information can be obtained from the register even without PPTT. This patch set the cpu_map_populated to true if the machine doesn't have PPTT. It use only the level/type information obtained from CLIDR_EL1, and don't use CCSIDR information. Signed-off-by: Kohei Tarumizu <tarumizu.kohei@fujitsu.com> --- arch/arm64/kernel/cacheinfo.c | 27 +++++++++++++++++++++++++++ drivers/acpi/pptt.c | 18 ++++++++++++++++++ include/linux/acpi.h | 5 +++++ include/linux/cacheinfo.h | 10 ++++++++++ 4 files changed, 60 insertions(+)