@@ -216,9 +216,6 @@ static void ap_calibrate_delay(void)
216
216
cpu_data (smp_processor_id ()).loops_per_jiffy = loops_per_jiffy ;
217
217
}
218
218
219
- static int cpu0_logical_apicid ;
220
- static int enable_start_cpu0 ;
221
-
222
219
/*
223
220
* Activate a secondary processor.
224
221
*/
@@ -241,8 +238,6 @@ static void notrace start_secondary(void *unused)
241
238
x86_cpuinit .early_percpu_clock_init ();
242
239
smp_callin ();
243
240
244
- enable_start_cpu0 = 0 ;
245
-
246
241
/* otherwise gcc will move up smp_processor_id before the cpu_init */
247
242
barrier ();
248
243
/* Check TSC synchronization with the control CPU: */
@@ -410,7 +405,7 @@ void smp_store_cpu_info(int id)
410
405
c -> cpu_index = id ;
411
406
/*
412
407
* During boot time, CPU0 has this setup already. Save the info when
413
- * bringing up AP or offlined CPU0 .
408
+ * bringing up an AP .
414
409
*/
415
410
identify_secondary_cpu (c );
416
411
c -> initialized = true;
@@ -807,51 +802,14 @@ static void __init smp_quirk_init_udelay(void)
807
802
}
808
803
809
804
/*
810
- * Poke the other CPU in the eye via NMI to wake it up. Remember that the normal
811
- * INIT, INIT, STARTUP sequence will reset the chip hard for us, and this
812
- * won't ... remember to clear down the APIC, etc later.
805
+ * Wake up AP by INIT, INIT, STARTUP sequence.
813
806
*/
814
- int
815
- wakeup_secondary_cpu_via_nmi (int apicid , unsigned long start_eip )
816
- {
817
- u32 dm = apic -> dest_mode_logical ? APIC_DEST_LOGICAL : APIC_DEST_PHYSICAL ;
818
- unsigned long send_status , accept_status = 0 ;
819
- int maxlvt ;
820
-
821
- /* Target chip */
822
- /* Boot on the stack */
823
- /* Kick the second */
824
- apic_icr_write (APIC_DM_NMI | dm , apicid );
825
-
826
- pr_debug ("Waiting for send to finish...\n" );
827
- send_status = safe_apic_wait_icr_idle ();
828
-
829
- /*
830
- * Give the other CPU some time to accept the IPI.
831
- */
832
- udelay (200 );
833
- if (APIC_INTEGRATED (boot_cpu_apic_version )) {
834
- maxlvt = lapic_get_maxlvt ();
835
- if (maxlvt > 3 ) /* Due to the Pentium erratum 3AP. */
836
- apic_write (APIC_ESR , 0 );
837
- accept_status = (apic_read (APIC_ESR ) & 0xEF );
838
- }
839
- pr_debug ("NMI sent\n" );
840
-
841
- if (send_status )
842
- pr_err ("APIC never delivered???\n" );
843
- if (accept_status )
844
- pr_err ("APIC delivery error (%lx)\n" , accept_status );
845
-
846
- return (send_status | accept_status );
847
- }
848
-
849
- static int
850
- wakeup_secondary_cpu_via_init (int phys_apicid , unsigned long start_eip )
807
+ static int wakeup_secondary_cpu_via_init (int phys_apicid , unsigned long start_eip )
851
808
{
852
809
unsigned long send_status = 0 , accept_status = 0 ;
853
810
int maxlvt , num_starts , j ;
854
811
812
+ preempt_disable ();
855
813
maxlvt = lapic_get_maxlvt ();
856
814
857
815
/*
@@ -957,6 +915,7 @@ wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
957
915
if (accept_status )
958
916
pr_err ("APIC delivery error (%lx)\n" , accept_status );
959
917
918
+ preempt_enable ();
960
919
return (send_status | accept_status );
961
920
}
962
921
@@ -997,67 +956,6 @@ static void announce_cpu(int cpu, int apicid)
997
956
node , cpu , apicid );
998
957
}
999
958
1000
- static int wakeup_cpu0_nmi (unsigned int cmd , struct pt_regs * regs )
1001
- {
1002
- int cpu ;
1003
-
1004
- cpu = smp_processor_id ();
1005
- if (cpu == 0 && !cpu_online (cpu ) && enable_start_cpu0 )
1006
- return NMI_HANDLED ;
1007
-
1008
- return NMI_DONE ;
1009
- }
1010
-
1011
- /*
1012
- * Wake up AP by INIT, INIT, STARTUP sequence.
1013
- *
1014
- * Instead of waiting for STARTUP after INITs, BSP will execute the BIOS
1015
- * boot-strap code which is not a desired behavior for waking up BSP. To
1016
- * void the boot-strap code, wake up CPU0 by NMI instead.
1017
- *
1018
- * This works to wake up soft offlined CPU0 only. If CPU0 is hard offlined
1019
- * (i.e. physically hot removed and then hot added), NMI won't wake it up.
1020
- * We'll change this code in the future to wake up hard offlined CPU0 if
1021
- * real platform and request are available.
1022
- */
1023
- static int
1024
- wakeup_cpu_via_init_nmi (int cpu , unsigned long start_ip , int apicid ,
1025
- int * cpu0_nmi_registered )
1026
- {
1027
- int id ;
1028
- int boot_error ;
1029
-
1030
- preempt_disable ();
1031
-
1032
- /*
1033
- * Wake up AP by INIT, INIT, STARTUP sequence.
1034
- */
1035
- if (cpu ) {
1036
- boot_error = wakeup_secondary_cpu_via_init (apicid , start_ip );
1037
- goto out ;
1038
- }
1039
-
1040
- /*
1041
- * Wake up BSP by nmi.
1042
- *
1043
- * Register a NMI handler to help wake up CPU0.
1044
- */
1045
- boot_error = register_nmi_handler (NMI_LOCAL ,
1046
- wakeup_cpu0_nmi , 0 , "wake_cpu0" );
1047
-
1048
- if (!boot_error ) {
1049
- enable_start_cpu0 = 1 ;
1050
- * cpu0_nmi_registered = 1 ;
1051
- id = apic -> dest_mode_logical ? cpu0_logical_apicid : apicid ;
1052
- boot_error = wakeup_secondary_cpu_via_nmi (id , start_ip );
1053
- }
1054
-
1055
- out :
1056
- preempt_enable ();
1057
-
1058
- return boot_error ;
1059
- }
1060
-
1061
959
int common_cpu_up (unsigned int cpu , struct task_struct * idle )
1062
960
{
1063
961
int ret ;
@@ -1086,8 +984,7 @@ int common_cpu_up(unsigned int cpu, struct task_struct *idle)
1086
984
* Returns zero if CPU booted OK, else error code from
1087
985
* ->wakeup_secondary_cpu.
1088
986
*/
1089
- static int do_boot_cpu (int apicid , int cpu , struct task_struct * idle ,
1090
- int * cpu0_nmi_registered )
987
+ static int do_boot_cpu (int apicid , int cpu , struct task_struct * idle )
1091
988
{
1092
989
/* start_ip had better be page-aligned! */
1093
990
unsigned long start_ip = real_mode_header -> trampoline_start ;
@@ -1120,7 +1017,6 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
1120
1017
* This grunge runs the startup process for
1121
1018
* the targeted processor.
1122
1019
*/
1123
-
1124
1020
if (x86_platform .legacy .warm_reset ) {
1125
1021
1126
1022
pr_debug ("Setting warm reset code and vector.\n" );
@@ -1149,15 +1045,14 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
1149
1045
* - Use a method from the APIC driver if one defined, with wakeup
1150
1046
* straight to 64-bit mode preferred over wakeup to RM.
1151
1047
* Otherwise,
1152
- * - Use an INIT boot APIC message for APs or NMI for BSP.
1048
+ * - Use an INIT boot APIC message
1153
1049
*/
1154
1050
if (apic -> wakeup_secondary_cpu_64 )
1155
1051
boot_error = apic -> wakeup_secondary_cpu_64 (apicid , start_ip );
1156
1052
else if (apic -> wakeup_secondary_cpu )
1157
1053
boot_error = apic -> wakeup_secondary_cpu (apicid , start_ip );
1158
1054
else
1159
- boot_error = wakeup_cpu_via_init_nmi (cpu , start_ip , apicid ,
1160
- cpu0_nmi_registered );
1055
+ boot_error = wakeup_secondary_cpu_via_init (apicid , start_ip );
1161
1056
1162
1057
if (!boot_error ) {
1163
1058
/*
@@ -1206,9 +1101,8 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle,
1206
1101
int native_cpu_up (unsigned int cpu , struct task_struct * tidle )
1207
1102
{
1208
1103
int apicid = apic -> cpu_present_to_apicid (cpu );
1209
- int cpu0_nmi_registered = 0 ;
1210
1104
unsigned long flags ;
1211
- int err , ret = 0 ;
1105
+ int err ;
1212
1106
1213
1107
lockdep_assert_irqs_enabled ();
1214
1108
@@ -1247,11 +1141,10 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
1247
1141
if (err )
1248
1142
return err ;
1249
1143
1250
- err = do_boot_cpu (apicid , cpu , tidle , & cpu0_nmi_registered );
1144
+ err = do_boot_cpu (apicid , cpu , tidle );
1251
1145
if (err ) {
1252
1146
pr_err ("do_boot_cpu failed(%d) to wakeup CPU#%u\n" , err , cpu );
1253
- ret = - EIO ;
1254
- goto unreg_nmi ;
1147
+ return err ;
1255
1148
}
1256
1149
1257
1150
/*
@@ -1267,15 +1160,7 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
1267
1160
touch_nmi_watchdog ();
1268
1161
}
1269
1162
1270
- unreg_nmi :
1271
- /*
1272
- * Clean up the nmi handler. Do this after the callin and callout sync
1273
- * to avoid impact of possible long unregister time.
1274
- */
1275
- if (cpu0_nmi_registered )
1276
- unregister_nmi_handler (NMI_LOCAL , "wake_cpu0" );
1277
-
1278
- return ret ;
1163
+ return 0 ;
1279
1164
}
1280
1165
1281
1166
/**
@@ -1373,14 +1258,6 @@ static void __init smp_cpu_index_default(void)
1373
1258
}
1374
1259
}
1375
1260
1376
- static void __init smp_get_logical_apicid (void )
1377
- {
1378
- if (x2apic_mode )
1379
- cpu0_logical_apicid = apic_read (APIC_LDR );
1380
- else
1381
- cpu0_logical_apicid = GET_APIC_LOGICAL_ID (apic_read (APIC_LDR ));
1382
- }
1383
-
1384
1261
void __init smp_prepare_cpus_common (void )
1385
1262
{
1386
1263
unsigned int i ;
@@ -1443,8 +1320,6 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1443
1320
/* Setup local timer */
1444
1321
x86_init .timers .setup_percpu_clockev ();
1445
1322
1446
- smp_get_logical_apicid ();
1447
-
1448
1323
pr_info ("CPU0: " );
1449
1324
print_cpu_info (& cpu_data (0 ));
1450
1325
@@ -1752,18 +1627,6 @@ void play_dead_common(void)
1752
1627
local_irq_disable ();
1753
1628
}
1754
1629
1755
- /**
1756
- * cond_wakeup_cpu0 - Wake up CPU0 if needed.
1757
- *
1758
- * If NMI wants to wake up CPU0, start CPU0.
1759
- */
1760
- void cond_wakeup_cpu0 (void )
1761
- {
1762
- if (smp_processor_id () == 0 && enable_start_cpu0 )
1763
- start_cpu0 ();
1764
- }
1765
- EXPORT_SYMBOL_GPL (cond_wakeup_cpu0 );
1766
-
1767
1630
/*
1768
1631
* We need to flush the caches before going to sleep, lest we have
1769
1632
* dirty data in our caches when we come back up.
@@ -1831,8 +1694,6 @@ static inline void mwait_play_dead(void)
1831
1694
__monitor (mwait_ptr , 0 , 0 );
1832
1695
mb ();
1833
1696
__mwait (eax , 0 );
1834
-
1835
- cond_wakeup_cpu0 ();
1836
1697
}
1837
1698
}
1838
1699
@@ -1841,11 +1702,8 @@ void __noreturn hlt_play_dead(void)
1841
1702
if (__this_cpu_read (cpu_info .x86 ) >= 4 )
1842
1703
wbinvd ();
1843
1704
1844
- while (1 ) {
1705
+ while (1 )
1845
1706
native_halt ();
1846
-
1847
- cond_wakeup_cpu0 ();
1848
- }
1849
1707
}
1850
1708
1851
1709
void native_play_dead (void )
0 commit comments