From a16cd9cddaf254d3141cb098ab9d1d4b365799d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Thu, 16 Jun 2016 00:40:16 +0300 Subject: [PATCH] ACPI S3: Move SMP trampoline recovery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No need to make low memory backup unless we are on S3 resume path. Hide those details from ACPI. Change-Id: Ic08b6d70c7895b094afdb3c77e020ff37ad632a1 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/15241 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- src/arch/x86/acpi.c | 15 ------------ src/cpu/x86/lapic/lapic_cpu_init.c | 38 +++++++++++++++++++----------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c index cc6d2ad55e..d75f969619 100644 --- a/src/arch/x86/acpi.c +++ b/src/arch/x86/acpi.c @@ -1127,12 +1127,6 @@ void *acpi_find_wakeup_vector(void) return wake_vec; } -#if CONFIG_SMP -extern char *lowmem_backup; -extern char *lowmem_backup_ptr; -extern int lowmem_backup_size; -#endif - #define WAKEUP_BASE 0x600 void (*acpi_do_wakeup)(uintptr_t vector, u32 backup_source, u32 backup_target, @@ -1155,15 +1149,6 @@ void acpi_jump_to_wakeup(void *vector) } } -#if CONFIG_SMP - // FIXME: This should go into the ACPI backup memory, too. No pork sausages. - /* - * Just restore the SMP trampoline and continue with wakeup on - * assembly level. - */ - memcpy(lowmem_backup_ptr, lowmem_backup, lowmem_backup_size); -#endif - /* Copy wakeup trampoline in place. */ memcpy((void *)WAKEUP_BASE, &__wakeup, __wakeup_size); diff --git a/src/cpu/x86/lapic/lapic_cpu_init.c b/src/cpu/x86/lapic/lapic_cpu_init.c index bf63517384..77e5ba8e52 100644 --- a/src/cpu/x86/lapic/lapic_cpu_init.c +++ b/src/cpu/x86/lapic/lapic_cpu_init.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -46,11 +47,9 @@ /* Start-UP IPI vector must be 4kB aligned and below 1MB. */ #define AP_SIPI_VECTOR 0x1000 -#if CONFIG_HAVE_ACPI_RESUME -char *lowmem_backup; -char *lowmem_backup_ptr; -int lowmem_backup_size; -#endif +static char *lowmem_backup; +static char *lowmem_backup_ptr; +static int lowmem_backup_size; static inline void setup_secondary_gdt(void) { @@ -77,17 +76,18 @@ static void copy_secondary_start_to_lowest_1M(void) code_size = (unsigned long)_secondary_start_end - (unsigned long)_secondary_start; -#if CONFIG_HAVE_ACPI_RESUME - /* need to save it for RAM resume */ - lowmem_backup_size = code_size; - lowmem_backup = malloc(code_size); - lowmem_backup_ptr = (char *)AP_SIPI_VECTOR; + if (acpi_is_wakeup_s3()) { + /* need to save it for RAM resume */ + lowmem_backup_size = code_size; + lowmem_backup = malloc(code_size); + lowmem_backup_ptr = (char *)AP_SIPI_VECTOR; - if (lowmem_backup == NULL) - die("Out of backup memory\n"); + if (lowmem_backup == NULL) + die("Out of backup memory\n"); + + memcpy(lowmem_backup, lowmem_backup_ptr, lowmem_backup_size); + } - memcpy(lowmem_backup, lowmem_backup_ptr, lowmem_backup_size); -#endif /* copy the _secondary_start to the ram below 1M*/ memcpy((unsigned char *)AP_SIPI_VECTOR, (unsigned char *)_secondary_start, code_size); @@ -95,6 +95,12 @@ static void copy_secondary_start_to_lowest_1M(void) (long unsigned int)AP_SIPI_VECTOR, code_size); } +static void recover_lowest_1M(void) +{ + if (acpi_is_wakeup_s3()) + memcpy(lowmem_backup_ptr, lowmem_backup, lowmem_backup_size); +} + static int lapic_start_cpu(unsigned long apicid) { int timeout; @@ -592,4 +598,8 @@ void initialize_cpus(struct bus *cpu_bus) smm_other_cpus(cpu_bus, info->cpu); #endif } + +#if CONFIG_SMP && CONFIG_MAX_CPUS > 1 + recover_lowest_1M(); +#endif }