Message ID | 20250503191515.24041-3-ricardo.neri-calderon@linux.intel.com |
---|---|
State | New |
Headers | show |
Series | x86/hyperv/hv_vtl: Use a wakeup mailbox to boot secondary CPUs | expand |
On Sat, May 3, 2025 at 9:10 PM Ricardo Neri <ricardo.neri-calderon@linux.intel.com> wrote: > > In preparation to move the functionality to wake secondary CPUs up out > of the ACPI code, add a helper function to get a pointer to the mailbox. > > Use this helper function only in the portions of the code for which the > variable acpi_mp_wake_mailbox will be out of scope once it is relocated > out of the ACPI directory. > > The wakeup mailbox is only supported for CONFIG_X86_64 and needed only > with CONFIG_SMP. > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> > --- > Changes since v2: > - Introduced this patch. Have you considered merging it with the previous patch? They both do analogous things. > Changes since v1: > - N/A > --- > arch/x86/include/asm/smp.h | 1 + > arch/x86/kernel/acpi/madt_wakeup.c | 12 +++++++++--- > 2 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h > index 3622951d2ee0..97bfbd0d24d4 100644 > --- a/arch/x86/include/asm/smp.h > +++ b/arch/x86/include/asm/smp.h > @@ -148,6 +148,7 @@ static inline struct cpumask *cpu_l2c_shared_mask(int cpu) > > #ifdef CONFIG_X86_64 > void setup_mp_wakeup_mailbox(u64 addr); > +struct acpi_madt_multiproc_wakeup_mailbox *get_mp_wakeup_mailbox(void); > #endif > > #else /* !CONFIG_SMP */ > diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt_wakeup.c > index 04de3db307de..6b9e41a24574 100644 > --- a/arch/x86/kernel/acpi/madt_wakeup.c > +++ b/arch/x86/kernel/acpi/madt_wakeup.c > @@ -37,6 +37,7 @@ static void acpi_mp_play_dead(void) > > static void acpi_mp_cpu_die(unsigned int cpu) > { > + struct acpi_madt_multiproc_wakeup_mailbox *mailbox = get_mp_wakeup_mailbox(); I'd prefer acpi_get_mp_wakeup_mailbox(). > u32 apicid = per_cpu(x86_cpu_to_apicid, cpu); > unsigned long timeout; > > @@ -46,13 +47,13 @@ static void acpi_mp_cpu_die(unsigned int cpu) > * > * BIOS has to clear 'command' field of the mailbox. > */ > - acpi_mp_wake_mailbox->apic_id = apicid; > - smp_store_release(&acpi_mp_wake_mailbox->command, > + mailbox->apic_id = apicid; > + smp_store_release(&mailbox->command, > ACPI_MP_WAKE_COMMAND_TEST); > > /* Don't wait longer than a second. */ > timeout = USEC_PER_SEC; > - while (READ_ONCE(acpi_mp_wake_mailbox->command) && --timeout) > + while (READ_ONCE(mailbox->command) && --timeout) > udelay(1); > > if (!timeout) > @@ -251,3 +252,8 @@ void __init setup_mp_wakeup_mailbox(u64 mailbox_paddr) > acpi_mp_wake_mailbox_paddr = mailbox_paddr; > apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); > } > + > +struct acpi_madt_multiproc_wakeup_mailbox *get_mp_wakeup_mailbox(void) > +{ > + return acpi_mp_wake_mailbox; > +} > --
On Mon, May 05, 2025 at 11:55:03AM +0200, Rafael J. Wysocki wrote: > On Sat, May 3, 2025 at 9:10 PM Ricardo Neri > <ricardo.neri-calderon@linux.intel.com> wrote: > > > > In preparation to move the functionality to wake secondary CPUs up out > > of the ACPI code, add a helper function to get a pointer to the mailbox. > > > > Use this helper function only in the portions of the code for which the > > variable acpi_mp_wake_mailbox will be out of scope once it is relocated > > out of the ACPI directory. > > > > The wakeup mailbox is only supported for CONFIG_X86_64 and needed only > > with CONFIG_SMP. > > > > Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> > > --- > > Changes since v2: > > - Introduced this patch. > > Have you considered merging it with the previous patch? They both do > analogous things. Indeed, I can merge these two patches. Thanks and BR, Ricardo
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 3622951d2ee0..97bfbd0d24d4 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -148,6 +148,7 @@ static inline struct cpumask *cpu_l2c_shared_mask(int cpu) #ifdef CONFIG_X86_64 void setup_mp_wakeup_mailbox(u64 addr); +struct acpi_madt_multiproc_wakeup_mailbox *get_mp_wakeup_mailbox(void); #endif #else /* !CONFIG_SMP */ diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt_wakeup.c index 04de3db307de..6b9e41a24574 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -37,6 +37,7 @@ static void acpi_mp_play_dead(void) static void acpi_mp_cpu_die(unsigned int cpu) { + struct acpi_madt_multiproc_wakeup_mailbox *mailbox = get_mp_wakeup_mailbox(); u32 apicid = per_cpu(x86_cpu_to_apicid, cpu); unsigned long timeout; @@ -46,13 +47,13 @@ static void acpi_mp_cpu_die(unsigned int cpu) * * BIOS has to clear 'command' field of the mailbox. */ - acpi_mp_wake_mailbox->apic_id = apicid; - smp_store_release(&acpi_mp_wake_mailbox->command, + mailbox->apic_id = apicid; + smp_store_release(&mailbox->command, ACPI_MP_WAKE_COMMAND_TEST); /* Don't wait longer than a second. */ timeout = USEC_PER_SEC; - while (READ_ONCE(acpi_mp_wake_mailbox->command) && --timeout) + while (READ_ONCE(mailbox->command) && --timeout) udelay(1); if (!timeout) @@ -251,3 +252,8 @@ void __init setup_mp_wakeup_mailbox(u64 mailbox_paddr) acpi_mp_wake_mailbox_paddr = mailbox_paddr; apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); } + +struct acpi_madt_multiproc_wakeup_mailbox *get_mp_wakeup_mailbox(void) +{ + return acpi_mp_wake_mailbox; +}
In preparation to move the functionality to wake secondary CPUs up out of the ACPI code, add a helper function to get a pointer to the mailbox. Use this helper function only in the portions of the code for which the variable acpi_mp_wake_mailbox will be out of scope once it is relocated out of the ACPI directory. The wakeup mailbox is only supported for CONFIG_X86_64 and needed only with CONFIG_SMP. Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> --- Changes since v2: - Introduced this patch. Changes since v1: - N/A --- arch/x86/include/asm/smp.h | 1 + arch/x86/kernel/acpi/madt_wakeup.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-)