Skip to content

Commit 4b92d4a

Browse files
committed
drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION()
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: 8571890 ("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
1 parent 8596e58 commit 4b92d4a

File tree

5 files changed

+8
-38
lines changed

5 files changed

+8
-38
lines changed

arch/arm64/kernel/cacheinfo.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
4343
this_leaf->type = type;
4444
}
4545

46-
static int __init_cache_level(unsigned int cpu)
46+
int init_cache_level(unsigned int cpu)
4747
{
4848
unsigned int ctype, level, leaves, fw_level;
4949
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -78,7 +78,7 @@ static int __init_cache_level(unsigned int cpu)
7878
return 0;
7979
}
8080

81-
static int __populate_cache_leaves(unsigned int cpu)
81+
int populate_cache_leaves(unsigned int cpu)
8282
{
8383
unsigned int level, idx;
8484
enum cache_type type;
@@ -97,6 +97,3 @@ static int __populate_cache_leaves(unsigned int cpu)
9797
}
9898
return 0;
9999
}
100-
101-
DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
102-
DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)

arch/mips/kernel/cacheinfo.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ do { \
1717
leaf++; \
1818
} while (0)
1919

20-
static int __init_cache_level(unsigned int cpu)
20+
int init_cache_level(unsigned int cpu)
2121
{
2222
struct cpuinfo_mips *c = &current_cpu_data;
2323
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)
7474
cpumask_set_cpu(cpu1, cpu_map);
7575
}
7676

77-
static int __populate_cache_leaves(unsigned int cpu)
77+
int populate_cache_leaves(unsigned int cpu)
7878
{
7979
struct cpuinfo_mips *c = &current_cpu_data;
8080
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -114,6 +114,3 @@ static int __populate_cache_leaves(unsigned int cpu)
114114

115115
return 0;
116116
}
117-
118-
DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
119-
DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)

arch/riscv/kernel/cacheinfo.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void fill_cacheinfo(struct cacheinfo **this_leaf,
113113
}
114114
}
115115

116-
static int __init_cache_level(unsigned int cpu)
116+
int init_cache_level(unsigned int cpu)
117117
{
118118
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
119119
struct device_node *np = of_cpu_device_node_get(cpu);
@@ -155,7 +155,7 @@ static int __init_cache_level(unsigned int cpu)
155155
return 0;
156156
}
157157

158-
static int __populate_cache_leaves(unsigned int cpu)
158+
int populate_cache_leaves(unsigned int cpu)
159159
{
160160
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
161161
struct cacheinfo *this_leaf = this_cpu_ci->info_list;
@@ -187,6 +187,3 @@ static int __populate_cache_leaves(unsigned int cpu)
187187

188188
return 0;
189189
}
190-
191-
DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
192-
DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)

arch/x86/kernel/cpu/cacheinfo.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ static void ci_leaf_init(struct cacheinfo *this_leaf,
985985
this_leaf->priv = base->nb;
986986
}
987987

988-
static int __init_cache_level(unsigned int cpu)
988+
int init_cache_level(unsigned int cpu)
989989
{
990990
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
991991

@@ -1014,7 +1014,7 @@ static void get_cache_id(int cpu, struct _cpuid4_info_regs *id4_regs)
10141014
id4_regs->id = c->apicid >> index_msb;
10151015
}
10161016

1017-
static int __populate_cache_leaves(unsigned int cpu)
1017+
int populate_cache_leaves(unsigned int cpu)
10181018
{
10191019
unsigned int idx, ret;
10201020
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
@@ -1033,6 +1033,3 @@ static int __populate_cache_leaves(unsigned int cpu)
10331033

10341034
return 0;
10351035
}
1036-
1037-
DEFINE_SMP_CALL_CACHE_FUNCTION(init_cache_level)
1038-
DEFINE_SMP_CALL_CACHE_FUNCTION(populate_cache_leaves)

include/linux/cacheinfo.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,6 @@ struct cpu_cacheinfo {
7979
bool cpu_map_populated;
8080
};
8181

82-
/*
83-
* Helpers to make sure "func" is executed on the cpu whose cache
84-
* attributes are being detected
85-
*/
86-
#define DEFINE_SMP_CALL_CACHE_FUNCTION(func) \
87-
static inline void _##func(void *ret) \
88-
{ \
89-
int cpu = smp_processor_id(); \
90-
*(int *)ret = __##func(cpu); \
91-
} \
92-
\
93-
int func(unsigned int cpu) \
94-
{ \
95-
int ret; \
96-
smp_call_function_single(cpu, _##func, &ret, true); \
97-
return ret; \
98-
}
99-
10082
struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu);
10183
int init_cache_level(unsigned int cpu);
10284
int populate_cache_leaves(unsigned int cpu);

0 commit comments

Comments
 (0)