From fca179775708686d05dc732ad33099963ff4a75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Wed, 10 Feb 2021 20:05:50 +0200 Subject: [PATCH] vc/google/chromeos: Allocate RAMOOPS late MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The allocation is for the OS. Just need to take care in the firmware that ChromeOS GNVS is allocated first. Change-Id: I16db41b31751d7b4a8a70e638602f3f537fe392e Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/50609 Reviewed-by: Angel Pons Reviewed-by: Tim Wawrzynczak Tested-by: build bot (Jenkins) --- src/vendorcode/google/chromeos/chromeos.h | 8 ------- src/vendorcode/google/chromeos/gnvs.c | 2 -- src/vendorcode/google/chromeos/ramoops.c | 29 +++++++++-------------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/vendorcode/google/chromeos/chromeos.h b/src/vendorcode/google/chromeos/chromeos.h index 35e2dde740..233078baea 100644 --- a/src/vendorcode/google/chromeos/chromeos.h +++ b/src/vendorcode/google/chromeos/chromeos.h @@ -27,14 +27,6 @@ static inline void reboot_from_watchdog(void) { return; } */ void mainboard_prepare_cr50_reset(void); -#include "gnvs.h" - -#if CONFIG(CHROMEOS_RAMOOPS) -void chromeos_ram_oops_init(chromeos_acpi_t *chromeos); -#else /* !CONFIG_CHROMEOS_RAMOOPS */ -static inline void chromeos_ram_oops_init(chromeos_acpi_t *chromeos) {} -#endif /* CONFIG_CHROMEOS_RAMOOPS */ - void cbmem_add_vpd_calibration_data(void); void chromeos_set_me_hash(u32*, int); diff --git a/src/vendorcode/google/chromeos/gnvs.c b/src/vendorcode/google/chromeos/gnvs.c index f0e8e5b913..62d19d6d51 100644 --- a/src/vendorcode/google/chromeos/gnvs.c +++ b/src/vendorcode/google/chromeos/gnvs.c @@ -38,8 +38,6 @@ void chromeos_init_chromeos_acpi(chromeos_acpi_t *init) /* Copy saved ME hash into NVS */ memcpy(chromeos_acpi->mehh, me_hash_saved, sizeof(chromeos_acpi->mehh)); - chromeos_ram_oops_init(chromeos_acpi); - vpd_size = chromeos_vpd_region("RO_VPD", &vpd_base); if (vpd_size && vpd_base) { chromeos_acpi->vpd_ro_base = vpd_base; diff --git a/src/vendorcode/google/chromeos/ramoops.c b/src/vendorcode/google/chromeos/ramoops.c index ae72133d11..77e079f2b1 100644 --- a/src/vendorcode/google/chromeos/ramoops.c +++ b/src/vendorcode/google/chromeos/ramoops.c @@ -9,11 +9,11 @@ #include #include #include "chromeos.h" +#include "gnvs.h" -#if CONFIG(HAVE_ACPI_TABLES) - -static void set_ramoops(chromeos_acpi_t *chromeos, void *ram_oops, size_t size) +static void set_ramoops(void *ram_oops, size_t size) { + chromeos_acpi_t *chromeos = chromeos_get_chromeos_acpi(); if (chromeos == NULL) { printk(BIOS_DEBUG, "chromeos gnvs is NULL. ramoops not set.\n"); return; @@ -24,33 +24,26 @@ static void set_ramoops(chromeos_acpi_t *chromeos, void *ram_oops, size_t size) chromeos->ramoops_len = size; } -void chromeos_ram_oops_init(chromeos_acpi_t *chromeos) +static void ramoops_alloc(void *arg) { const size_t size = CONFIG_CHROMEOS_RAMOOPS_RAM_SIZE; void *ram_oops; - ram_oops = cbmem_add(CBMEM_ID_RAM_OOPS, size); - - set_ramoops(chromeos, ram_oops, size); -} - -#else - -static void ramoops_alloc(void *arg) -{ - const size_t size = CONFIG_CHROMEOS_RAMOOPS_RAM_SIZE; - if (size == 0) return; - if (cbmem_add(CBMEM_ID_RAM_OOPS, size) == NULL) + ram_oops = cbmem_add(CBMEM_ID_RAM_OOPS, size); + if (ram_oops == NULL) { printk(BIOS_ERR, "Could not allocate RAMOOPS buffer\n"); + return; + } + + if (CONFIG(HAVE_ACPI_TABLES)) + set_ramoops(ram_oops, size); } BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, ramoops_alloc, NULL); -#endif - void lb_ramoops(struct lb_header *header) { void *buffer = cbmem_find(CBMEM_ID_RAM_OOPS);