]> Git Repo - J-linux.git/commitdiff
drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION()
authorThomas Gleixner <[email protected]>
Tue, 31 Aug 2021 11:48:34 +0000 (13:48 +0200)
committerThomas Gleixner <[email protected]>
Wed, 1 Sep 2021 08:29:10 +0000 (10:29 +0200)
DEFINE_SMP_CALL_CACHE_FUNCTION() was usefel before the CPU hotplug rework
to ensure that the cache related functions are called on the upcoming CPU
because the notifier itself could run on any online CPU.

The hotplug state machine guarantees that the callbacks are invoked on the
upcoming CPU. So there is no need to have this SMP function call
obfuscation. That indirection was missed when the hotplug notifiers were
converted.

This also solves the problem of ARM64 init_cache_level() invoking ACPI
functions which take a semaphore in that context. That's invalid as SMP
function calls run with interrupts disabled. Running it just from the
callback in context of the CPU hotplug thread solves this.

Fixes: 8571890e1513 ("arm64: Add support for ACPI based firmware tables")
Reported-by: Guenter Roeck <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Guenter Roeck <[email protected]>
Acked-by: Will Deacon <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/871r69ersb.ffs@tglx
arch/arm64/kernel/cacheinfo.c
arch/mips/kernel/cacheinfo.c
arch/riscv/kernel/cacheinfo.c
arch/x86/kernel/cpu/cacheinfo.c
include/linux/cacheinfo.h

index 7fa6828bb488ace623cb826d0b717cbea92210c5..587543c6c51cb0fdbc7a55595be1310d1f6d6221 100644 (file)
@@ -43,7 +43,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
        this_leaf->type = type;
 }
 
-static int __init_cache_level(unsigned int cpu)
+int init_cache_level(unsigned int cpu)
 {
        unsigned int ctype, level, leaves, fw_level;
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -78,7 +78,7 @@ static int __init_cache_level(unsigned int cpu)
        return 0;
 }
 
-static int __populate_cache_leaves(unsigned int cpu)
+int populate_cache_leaves(unsigned int cpu)
 {
        unsigned int level, idx;
        enum cache_type type;
@@ -97,6 +97,3 @@ static int __populate_cache_leaves(unsigned int cpu)
        }
        return 0;
 }
-
-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
index 53d8ea7d36e6d1e336a7899283ea7ea1190657c6..495dd058231d95c026cbf1344523504c37ecd515 100644 (file)
@@ -17,7 +17,7 @@ do {                                                          \
        leaf++;                                                 \
 } while (0)
 
-static int __init_cache_level(unsigned int cpu)
+int init_cache_level(unsigned int cpu)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -74,7 +74,7 @@ static void fill_cpumask_cluster(int cpu, cpumask_t *cpu_map)
                        cpumask_set_cpu(cpu1, cpu_map);
 }
 
-static int __populate_cache_leaves(unsigned int cpu)
+int populate_cache_leaves(unsigned int cpu)
 {
        struct cpuinfo_mips *c = &current_cpu_data;
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -114,6 +114,3 @@ static int __populate_cache_leaves(unsigned int cpu)
 
        return 0;
 }
-
-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
index d8678135704425973c3ba11d058dd56babef2481..90deabfe63eaace7d898a57b9890a0d449b37a13 100644 (file)
@@ -113,7 +113,7 @@ static void fill_cacheinfo(struct cacheinfo **this_leaf,
        }
 }
 
-static int __init_cache_level(unsigned int cpu)
+int init_cache_level(unsigned int cpu)
 {
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
        struct device_node *np = of_cpu_device_node_get(cpu);
@@ -155,7 +155,7 @@ static int __init_cache_level(unsigned int cpu)
        return 0;
 }
 
-static int __populate_cache_leaves(unsigned int cpu)
+int populate_cache_leaves(unsigned int cpu)
 {
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
        struct cacheinfo *this_leaf = this_cpu_ci->info_list;
@@ -187,6 +187,3 @@ static int __populate_cache_leaves(unsigned int cpu)
 
        return 0;
 }
-
-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
index d66af2950e06e7ccfecc8e0c549a572ef8db2b93..b5e36bd0425b571e1d23b65b325f47186826cdfa 100644 (file)
@@ -985,7 +985,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
        this_leaf->priv = base->nb;
 }
 
-static int __init_cache_level(unsigned int cpu)
+int init_cache_level(unsigned int cpu)
 {
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
 
@@ -1014,7 +1014,7 @@ static void get_cache_id(int cpu, struct _cpuid4_info_regs *id4_regs)
        id4_regs->id = c->apicid >> index_msb;
 }
 
-static int __populate_cache_leaves(unsigned int cpu)
+int populate_cache_leaves(unsigned int cpu)
 {
        unsigned int idx, ret;
        struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -1033,6 +1033,3 @@ static int __populate_cache_leaves(unsigned int cpu)
 
        return 0;
 }
-
-DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
-DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)
index 4f72b47973c304e2d90ca3720438efa1c22ea5c9..2f909ed084c63e5e2dc429306eade714b93ba868 100644 (file)
@@ -79,24 +79,6 @@ struct cpu_cacheinfo {
        bool cpu_map_populated;
 };
 
-/*
- * Helpers to make sure "func" is executed on the cpu whose cache
- * attributes are being detected
- */
-#define DEFINE_SMP_CALL_CACHE_FUNCTION(func)                   \
-static inline void _##func(void *ret)                          \
-{                                                              \
-       int cpu = smp_processor_id();                           \
-       *(int *)ret = __##func(cpu);                            \
-}                                                              \
-                                                               \
-int func(unsigned int cpu)                                     \
-{                                                              \
-       int ret;                                                \
-       smp_call_function_single(cpu, _##func, &ret, true);     \
-       return ret;                                             \
-}
-
 struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu);
 int init_cache_level(unsigned int cpu);
 int populate_cache_leaves(unsigned int cpu);
This page took 0.068255 seconds and 4 git commands to generate.