30
30
#include <linux/ftrace.h>
31
31
#include <linux/cpu.h>
32
32
#include <linux/kgdb.h>
33
+ #include <linux/sched/hotplug.h>
33
34
34
35
#include <linux/atomic.h>
35
36
#include <asm/current.h>
@@ -60,8 +61,6 @@ volatile struct task_struct *smp_init_current_idle_task;
60
61
/* track which CPU is booting */
61
62
static volatile int cpu_now_booting ;
62
63
63
- static int parisc_max_cpus = 1 ;
64
-
65
64
static DEFINE_PER_CPU (spinlock_t , ipi_lock ) ;
66
65
67
66
enum ipi_message_type {
@@ -269,7 +268,7 @@ void arch_send_call_function_single_ipi(int cpu)
269
268
/*
270
269
* Called by secondaries to update state and initialize CPU registers.
271
270
*/
272
- static void __init
271
+ static void
273
272
smp_cpu_init (int cpunum )
274
273
{
275
274
extern void init_IRQ (void ); /* arch/parisc/kernel/irq.c */
@@ -309,7 +308,7 @@ smp_cpu_init(int cpunum)
309
308
* Slaves start using C here. Indirectly called from smp_slave_stext.
310
309
* Do what start_kernel() and main() do for boot strap processor (aka monarch)
311
310
*/
312
- void __init smp_callin (unsigned long pdce_proc )
311
+ void smp_callin (unsigned long pdce_proc )
313
312
{
314
313
int slave_id = cpu_now_booting ;
315
314
@@ -334,11 +333,28 @@ void __init smp_callin(unsigned long pdce_proc)
334
333
/*
335
334
* Bring one cpu online.
336
335
*/
337
- int smp_boot_one_cpu (int cpuid , struct task_struct * idle )
336
+ static int smp_boot_one_cpu (int cpuid , struct task_struct * idle )
338
337
{
339
338
const struct cpuinfo_parisc * p = & per_cpu (cpu_data , cpuid );
340
339
long timeout ;
341
340
341
+ #ifdef CONFIG_HOTPLUG_CPU
342
+ int i ;
343
+
344
+ /* reset irq statistics for this CPU */
345
+ memset (& per_cpu (irq_stat , cpuid ), 0 , sizeof (irq_cpustat_t ));
346
+ for (i = 0 ; i < NR_IRQS ; i ++ ) {
347
+ struct irq_desc * desc = irq_to_desc (i );
348
+
349
+ if (desc && desc -> kstat_irqs )
350
+ * per_cpu_ptr (desc -> kstat_irqs , cpuid ) = 0 ;
351
+ }
352
+ #endif
353
+
354
+ /* wait until last booting CPU has started. */
355
+ while (cpu_now_booting )
356
+ ;
357
+
342
358
/* Let _start know what logical CPU we're booting
343
359
** (offset into init_tasks[],cpu_data[])
344
360
*/
@@ -374,7 +390,6 @@ int smp_boot_one_cpu(int cpuid, struct task_struct *idle)
374
390
if (cpu_online (cpuid )) {
375
391
/* Which implies Slave has started up */
376
392
cpu_now_booting = 0 ;
377
- smp_init_current_idle_task = NULL ;
378
393
goto alive ;
379
394
}
380
395
udelay (100 );
@@ -415,25 +430,82 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
415
430
spin_lock_init (& per_cpu (ipi_lock , cpu ));
416
431
417
432
init_cpu_present (cpumask_of (0 ));
418
-
419
- parisc_max_cpus = max_cpus ;
420
- if (!max_cpus )
421
- printk (KERN_INFO "SMP mode deactivated.\n" );
422
433
}
423
434
424
435
425
- void smp_cpus_done (unsigned int cpu_max )
436
+ void __init smp_cpus_done (unsigned int cpu_max )
426
437
{
427
- return ;
428
438
}
429
439
430
440
431
441
int __cpu_up (unsigned int cpu , struct task_struct * tidle )
432
442
{
433
- if (cpu != 0 && cpu < parisc_max_cpus && smp_boot_one_cpu (cpu , tidle ))
434
- return - ENOSYS ;
443
+ if (cpu_online (cpu ))
444
+ return 0 ;
445
+
446
+ if (num_online_cpus () < setup_max_cpus && smp_boot_one_cpu (cpu , tidle ))
447
+ return - EIO ;
448
+
449
+ return cpu_online (cpu ) ? 0 : - EIO ;
450
+ }
451
+
452
+ /*
453
+ * __cpu_disable runs on the processor to be shutdown.
454
+ */
455
+ int __cpu_disable (void )
456
+ {
457
+ #ifdef CONFIG_HOTPLUG_CPU
458
+ unsigned int cpu = smp_processor_id ();
459
+
460
+ remove_cpu_topology (cpu );
461
+
462
+ /*
463
+ * Take this CPU offline. Once we clear this, we can't return,
464
+ * and we must not schedule until we're ready to give up the cpu.
465
+ */
466
+ set_cpu_online (cpu , false);
467
+
468
+ disable_percpu_irq (IPI_IRQ );
469
+
470
+ irq_migrate_all_off_this_cpu ();
471
+
472
+ flush_cache_all_local ();
473
+ flush_tlb_all_local (NULL );
474
+
475
+ /* disable all irqs, including timer irq */
476
+ local_irq_disable ();
477
+
478
+ /* wait for next timer irq ... */
479
+ mdelay (1000 /HZ + 100 );
480
+
481
+ /* ... and then clear all pending external irqs */
482
+ set_eiem (0 );
483
+ mtctl (~0UL , CR_EIRR );
484
+ mfctl (CR_EIRR );
485
+ mtctl (0 , CR_EIRR );
486
+ #endif
487
+ return 0 ;
488
+ }
489
+
490
+ /*
491
+ * called on the thread which is asking for a CPU to be shutdown -
492
+ * waits until shutdown has completed, or it is timed out.
493
+ */
494
+ void __cpu_die (unsigned int cpu )
495
+ {
496
+ pdc_cpu_rendezvous_lock ();
497
+
498
+ if (!cpu_wait_death (cpu , 5 )) {
499
+ pr_crit ("CPU%u: cpu didn't die\n" , cpu );
500
+ return ;
501
+ }
502
+ pr_info ("CPU%u: is shutting down\n" , cpu );
503
+
504
+ /* set task's state to interruptible sleep */
505
+ set_current_state (TASK_INTERRUPTIBLE );
506
+ schedule_timeout ((IS_ENABLED (CONFIG_64BIT ) ? 8 :2 ) * HZ );
435
507
436
- return cpu_online ( cpu ) ? 0 : - ENOSYS ;
508
+ pdc_cpu_rendezvous_unlock () ;
437
509
}
438
510
439
511
#ifdef CONFIG_PROC_FS
0 commit comments