@@ -93,8 +93,10 @@ static inline int op_cpu_kill(unsigned int cpu)
93
93
*/
94
94
static int boot_secondary (unsigned int cpu , struct task_struct * idle )
95
95
{
96
- if (cpu_ops [cpu ]-> cpu_boot )
97
- return cpu_ops [cpu ]-> cpu_boot (cpu );
96
+ const struct cpu_operations * ops = get_cpu_ops (cpu );
97
+
98
+ if (ops -> cpu_boot )
99
+ return ops -> cpu_boot (cpu );
98
100
99
101
return - EOPNOTSUPP ;
100
102
}
@@ -196,6 +198,7 @@ asmlinkage notrace void secondary_start_kernel(void)
196
198
{
197
199
u64 mpidr = read_cpuid_mpidr () & MPIDR_HWID_BITMASK ;
198
200
struct mm_struct * mm = & init_mm ;
201
+ const struct cpu_operations * ops ;
199
202
unsigned int cpu ;
200
203
201
204
cpu = task_cpu (current );
@@ -227,8 +230,9 @@ asmlinkage notrace void secondary_start_kernel(void)
227
230
*/
228
231
check_local_cpu_capabilities ();
229
232
230
- if (cpu_ops [cpu ]-> cpu_postboot )
231
- cpu_ops [cpu ]-> cpu_postboot ();
233
+ ops = get_cpu_ops (cpu );
234
+ if (ops -> cpu_postboot )
235
+ ops -> cpu_postboot ();
232
236
233
237
/*
234
238
* Log the CPU info before it is marked online and might get read.
@@ -266,19 +270,21 @@ asmlinkage notrace void secondary_start_kernel(void)
266
270
#ifdef CONFIG_HOTPLUG_CPU
267
271
static int op_cpu_disable (unsigned int cpu )
268
272
{
273
+ const struct cpu_operations * ops = get_cpu_ops (cpu );
274
+
269
275
/*
270
276
* If we don't have a cpu_die method, abort before we reach the point
271
277
* of no return. CPU0 may not have an cpu_ops, so test for it.
272
278
*/
273
- if (!cpu_ops [ cpu ] || !cpu_ops [ cpu ] -> cpu_die )
279
+ if (!ops || !ops -> cpu_die )
274
280
return - EOPNOTSUPP ;
275
281
276
282
/*
277
283
* We may need to abort a hot unplug for some other mechanism-specific
278
284
* reason.
279
285
*/
280
- if (cpu_ops [ cpu ] -> cpu_disable )
281
- return cpu_ops [ cpu ] -> cpu_disable (cpu );
286
+ if (ops -> cpu_disable )
287
+ return ops -> cpu_disable (cpu );
282
288
283
289
return 0 ;
284
290
}
@@ -314,15 +320,17 @@ int __cpu_disable(void)
314
320
315
321
static int op_cpu_kill (unsigned int cpu )
316
322
{
323
+ const struct cpu_operations * ops = get_cpu_ops (cpu );
324
+
317
325
/*
318
326
* If we have no means of synchronising with the dying CPU, then assume
319
327
* that it is really dead. We can only wait for an arbitrary length of
320
328
* time and hope that it's dead, so let's skip the wait and just hope.
321
329
*/
322
- if (!cpu_ops [ cpu ] -> cpu_kill )
330
+ if (!ops -> cpu_kill )
323
331
return 0 ;
324
332
325
- return cpu_ops [ cpu ] -> cpu_kill (cpu );
333
+ return ops -> cpu_kill (cpu );
326
334
}
327
335
328
336
/*
@@ -357,6 +365,7 @@ void __cpu_die(unsigned int cpu)
357
365
void cpu_die (void )
358
366
{
359
367
unsigned int cpu = smp_processor_id ();
368
+ const struct cpu_operations * ops = get_cpu_ops (cpu );
360
369
361
370
idle_task_exit ();
362
371
@@ -370,12 +379,22 @@ void cpu_die(void)
370
379
* mechanism must perform all required cache maintenance to ensure that
371
380
* no dirty lines are lost in the process of shutting down the CPU.
372
381
*/
373
- cpu_ops [ cpu ] -> cpu_die (cpu );
382
+ ops -> cpu_die (cpu );
374
383
375
384
BUG ();
376
385
}
377
386
#endif
378
387
388
+ static void __cpu_try_die (int cpu )
389
+ {
390
+ #ifdef CONFIG_HOTPLUG_CPU
391
+ const struct cpu_operations * ops = get_cpu_ops (cpu );
392
+
393
+ if (ops && ops -> cpu_die )
394
+ ops -> cpu_die (cpu );
395
+ #endif
396
+ }
397
+
379
398
/*
380
399
* Kill the calling secondary CPU, early in bringup before it is turned
381
400
* online.
@@ -389,12 +408,11 @@ void cpu_die_early(void)
389
408
/* Mark this CPU absent */
390
409
set_cpu_present (cpu , 0 );
391
410
392
- #ifdef CONFIG_HOTPLUG_CPU
393
- update_cpu_boot_status (CPU_KILL_ME );
394
- /* Check if we can park ourselves */
395
- if (cpu_ops [cpu ] && cpu_ops [cpu ]-> cpu_die )
396
- cpu_ops [cpu ]-> cpu_die (cpu );
397
- #endif
411
+ if (IS_ENABLED (CONFIG_HOTPLUG_CPU )) {
412
+ update_cpu_boot_status (CPU_KILL_ME );
413
+ __cpu_try_die (cpu );
414
+ }
415
+
398
416
update_cpu_boot_status (CPU_STUCK_IN_KERNEL );
399
417
400
418
cpu_park_loop ();
@@ -488,10 +506,13 @@ static bool __init is_mpidr_duplicate(unsigned int cpu, u64 hwid)
488
506
*/
489
507
static int __init smp_cpu_setup (int cpu )
490
508
{
509
+ const struct cpu_operations * ops ;
510
+
491
511
if (init_cpu_ops (cpu ))
492
512
return - ENODEV ;
493
513
494
- if (cpu_ops [cpu ]-> cpu_init (cpu ))
514
+ ops = get_cpu_ops (cpu );
515
+ if (ops -> cpu_init (cpu ))
495
516
return - ENODEV ;
496
517
497
518
set_cpu_possible (cpu , true);
@@ -714,6 +735,7 @@ void __init smp_init_cpus(void)
714
735
715
736
void __init smp_prepare_cpus (unsigned int max_cpus )
716
737
{
738
+ const struct cpu_operations * ops ;
717
739
int err ;
718
740
unsigned int cpu ;
719
741
unsigned int this_cpu ;
@@ -744,10 +766,11 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
744
766
if (cpu == smp_processor_id ())
745
767
continue ;
746
768
747
- if (!cpu_ops [cpu ])
769
+ ops = get_cpu_ops (cpu );
770
+ if (!ops )
748
771
continue ;
749
772
750
- err = cpu_ops [ cpu ] -> cpu_prepare (cpu );
773
+ err = ops -> cpu_prepare (cpu );
751
774
if (err )
752
775
continue ;
753
776
@@ -863,10 +886,8 @@ static void ipi_cpu_crash_stop(unsigned int cpu, struct pt_regs *regs)
863
886
local_irq_disable ();
864
887
sdei_mask_local_cpu ();
865
888
866
- #ifdef CONFIG_HOTPLUG_CPU
867
- if (cpu_ops [cpu ]-> cpu_die )
868
- cpu_ops [cpu ]-> cpu_die (cpu );
869
- #endif
889
+ if (IS_ENABLED (CONFIG_HOTPLUG_CPU ))
890
+ __cpu_try_die (cpu );
870
891
871
892
/* just in case */
872
893
cpu_park_loop ();
@@ -1044,8 +1065,9 @@ static bool have_cpu_die(void)
1044
1065
{
1045
1066
#ifdef CONFIG_HOTPLUG_CPU
1046
1067
int any_cpu = raw_smp_processor_id ();
1068
+ const struct cpu_operations * ops = get_cpu_ops (any_cpu );
1047
1069
1048
- if (cpu_ops [ any_cpu ] && cpu_ops [ any_cpu ] -> cpu_die )
1070
+ if (ops && ops -> cpu_die )
1049
1071
return true;
1050
1072
#endif
1051
1073
return false;
0 commit comments