Skip to content

Commit 6087dd5

Browse files
committed
x86/smp: Split sending INIT IPI out into a helper function
Putting CPUs into INIT is a safer place during kexec() to park CPUs. Split the INIT assert/deassert sequence out so it can be reused. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Ashok Raj <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d789309 commit 6087dd5

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

arch/x86/kernel/smpboot.c

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -853,47 +853,38 @@ wakeup_secondary_cpu_via_nmi(int apicid, unsigned long start_eip)
853853
return (send_status | accept_status);
854854
}
855855

856-
static int
857-
wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
856+
static void send_init_sequence(int phys_apicid)
858857
{
859-
unsigned long send_status = 0, accept_status = 0;
860-
int maxlvt, num_starts, j;
858+
int maxlvt = lapic_get_maxlvt();
861859

862-
maxlvt = lapic_get_maxlvt();
863-
864-
/*
865-
* Be paranoid about clearing APIC errors.
866-
*/
860+
/* Be paranoid about clearing APIC errors. */
867861
if (APIC_INTEGRATED(boot_cpu_apic_version)) {
868-
if (maxlvt > 3) /* Due to the Pentium erratum 3AP. */
862+
/* Due to the Pentium erratum 3AP. */
863+
if (maxlvt > 3)
869864
apic_write(APIC_ESR, 0);
870865
apic_read(APIC_ESR);
871866
}
872867

873-
pr_debug("Asserting INIT\n");
874-
875-
/*
876-
* Turn INIT on target chip
877-
*/
878-
/*
879-
* Send IPI
880-
*/
881-
apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT,
882-
phys_apicid);
883-
884-
pr_debug("Waiting for send to finish...\n");
885-
send_status = safe_apic_wait_icr_idle();
868+
/* Assert INIT on the target CPU */
869+
apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT, phys_apicid);
870+
safe_apic_wait_icr_idle();
886871

887872
udelay(init_udelay);
888873

889-
pr_debug("Deasserting INIT\n");
890-
891-
/* Target chip */
892-
/* Send IPI */
874+
/* Deassert INIT on the target CPU */
893875
apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);
876+
safe_apic_wait_icr_idle();
877+
}
894878

895-
pr_debug("Waiting for send to finish...\n");
896-
send_status = safe_apic_wait_icr_idle();
879+
/*
880+
* Wake up AP by INIT, INIT, STARTUP sequence.
881+
*/
882+
static int wakeup_secondary_cpu_via_init(int phys_apicid, unsigned long start_eip)
883+
{
884+
unsigned long send_status = 0, accept_status = 0;
885+
int num_starts, j, maxlvt = lapic_get_maxlvt();
886+
887+
send_init_sequence(phys_apicid);
897888

898889
mb();
899890

0 commit comments

Comments
 (0)