hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/powerpc/include/asm/smp.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 * smp.h: PowerPC-specific SMP code.
34 *
....@@ -6,11 +7,6 @@
67 *
78 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
89 * Copyright (C) 1996-2001 Cort Dougan <cort@fsmlabs.com>
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public License
12
- * as published by the Free Software Foundation; either version
13
- * 2 of the License, or (at your option) any later version.
1410 */
1511
1612 #ifndef _ASM_POWERPC_SMP_H
....@@ -32,8 +28,8 @@
3228 extern int boot_cpuid;
3329 extern int spinning_secondaries;
3430 extern u32 *cpu_to_phys_id;
31
+extern bool coregroup_enabled;
3532
36
-extern void cpu_die(void);
3733 extern int cpu_to_chip_id(int cpu);
3834
3935 #ifdef CONFIG_SMP
....@@ -54,6 +50,9 @@
5450 int (*cpu_disable)(void);
5551 void (*cpu_die)(unsigned int nr);
5652 int (*cpu_bootable)(unsigned int nr);
53
+#ifdef CONFIG_HOTPLUG_CPU
54
+ void (*cpu_offline_self)(void);
55
+#endif
5756 };
5857
5958 extern int smp_send_nmi_ipi(int cpu, void (*fn)(struct pt_regs *), u64 delay_us);
....@@ -83,7 +82,22 @@
8382 /* 32-bit */
8483 extern int smp_hw_index[];
8584
86
-#define raw_smp_processor_id() (current_thread_info()->cpu)
85
+/*
86
+ * This is particularly ugly: it appears we can't actually get the definition
87
+ * of task_struct here, but we need access to the CPU this task is running on.
88
+ * Instead of using task_struct we're using _TASK_CPU which is extracted from
89
+ * asm-offsets.h by kbuild to get the current processor ID.
90
+ *
91
+ * This also needs to be safeguarded when building asm-offsets.s because at
92
+ * that time _TASK_CPU is not defined yet. It could have been guarded by
93
+ * _TASK_CPU itself, but we want the build to fail if _TASK_CPU is missing
94
+ * when building something else than asm-offsets.s
95
+ */
96
+#ifdef GENERATING_ASM_OFFSETS
97
+#define raw_smp_processor_id() (0)
98
+#else
99
+#define raw_smp_processor_id() (*(unsigned int *)((void *)current + _TASK_CPU))
100
+#endif
87101 #define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
88102
89103 static inline int get_hard_smp_processor_id(int cpu)
....@@ -100,6 +114,7 @@
100114 DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_map);
101115 DECLARE_PER_CPU(cpumask_var_t, cpu_l2_cache_map);
102116 DECLARE_PER_CPU(cpumask_var_t, cpu_core_map);
117
+DECLARE_PER_CPU(cpumask_var_t, cpu_smallcore_map);
103118
104119 static inline struct cpumask *cpu_sibling_mask(int cpu)
105120 {
....@@ -116,7 +131,25 @@
116131 return per_cpu(cpu_l2_cache_map, cpu);
117132 }
118133
134
+static inline struct cpumask *cpu_smallcore_mask(int cpu)
135
+{
136
+ return per_cpu(cpu_smallcore_map, cpu);
137
+}
138
+
119139 extern int cpu_to_core_id(int cpu);
140
+
141
+extern bool has_big_cores;
142
+
143
+#define cpu_smt_mask cpu_smt_mask
144
+#ifdef CONFIG_SCHED_SMT
145
+static inline const struct cpumask *cpu_smt_mask(int cpu)
146
+{
147
+ if (has_big_cores)
148
+ return per_cpu(cpu_smallcore_map, cpu);
149
+
150
+ return per_cpu(cpu_sibling_map, cpu);
151
+}
152
+#endif /* CONFIG_SCHED_SMT */
120153
121154 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
122155 *
....@@ -162,6 +195,11 @@
162195 static inline void inhibit_secondary_onlining(void) {}
163196 static inline void uninhibit_secondary_onlining(void) {}
164197 static inline const struct cpumask *cpu_sibling_mask(int cpu)
198
+{
199
+ return cpumask_of(cpu);
200
+}
201
+
202
+static inline const struct cpumask *cpu_smallcore_mask(int cpu)
165203 {
166204 return cpumask_of(cpu);
167205 }
....@@ -221,7 +259,6 @@
221259 * 64-bit but defining them all here doesn't harm
222260 */
223261 extern void generic_secondary_smp_init(void);
224
-extern void generic_secondary_thread_init(void);
225262 extern unsigned long __secondary_hold_spinloop;
226263 extern unsigned long __secondary_hold_acknowledge;
227264 extern char __secondary_hold;