Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36674 )
Change subject: arch/x86: Add option to compress postcar stage
......................................................................
arch/x86: Add option to compress postcar stage
The LZ4 decompressor was already linked in romstage.
Change-Id: I89fdc6066027447bf72968c66e6f5eb5fbb630c7
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/Kconfig
M src/arch/x86/Makefile.inc
2 files changed, 19 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/36674/1
diff --git a/src/Kconfig b/src/Kconfig
index 0d56291..17bf545 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -158,6 +158,16 @@
that decompression might slow down booting if the boot flash
is connected through a slow link (i.e. SPI).
+config COMPRESS_POSTCAR
+ bool "Compress postcar with LZ4"
+ depends on POSTCAR_STAGE
+ # Default value set at the end of the file
+ help
+ Compress postcar with LZ4 to save flash space and speed up boot,
+ since the time for reading the image from SPI (and in the vboot
+ case verifying it) is usually much greater than the time spent
+ decompressing.
+
config COMPRESS_PRERAM_STAGES
bool "Compress romstage and verstage with LZ4"
depends on !ARCH_X86 && (HAVE_ROMSTAGE || HAVE_VERSTAGE)
@@ -1203,6 +1213,9 @@
config COMPRESS_RAMSTAGE
default y if !UNCOMPRESSED_RAMSTAGE
+config COMPRESS_POSTCAR
+ default y
+
config COMPRESS_PRERAM_STAGES
depends on !ARCH_X86
default y
diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index 447fd57..8c35176 100644
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -278,11 +278,16 @@
$(objcbfs)/postcar.elf: $(objcbfs)/postcar.debug.rmod
cp $< $@
+CBFS_POSTCAR_COMPRESS_FLAG := none
+ifeq ($(CONFIG_COMPRESS_POSTCAR),y)
+CBFS_POSTCAR_COMPRESS_FLAG := lz4
+endif
+
# Add postcar to CBFS
cbfs-files-$(CONFIG_POSTCAR_STAGE) += $(CONFIG_CBFS_PREFIX)/postcar
$(CONFIG_CBFS_PREFIX)/postcar-file := $(objcbfs)/postcar.elf
$(CONFIG_CBFS_PREFIX)/postcar-type := stage
-$(CONFIG_CBFS_PREFIX)/postcar-compression := none
+$(CONFIG_CBFS_PREFIX)/postcar-compression := $(CBFS_POSTCAR_COMPRESS_FLAG)
###############################################################################
# ramstage
--
To view, visit https://review.coreboot.org/c/coreboot/+/36674
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I89fdc6066027447bf72968c66e6f5eb5fbb630c7
Gerrit-Change-Number: 36674
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-MessageType: newchange
Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37196 )
Change subject: [WIP]cpu/x86/cache: CLFLUSH programs to memory before running
......................................................................
[WIP]cpu/x86/cache: CLFLUSH programs to memory before running
When cbmem is initialized in romstage and postcar placed in
the stage cache + cbmem where it is run, the assumption is made
that this are all in UC memory such that calling invd in
postcar is ok.
For performance reasons (e.g. postcar decompression) it is desirable
to cache cbmem and the stage cache during romstage. Another reason
is that AGESA sets up MTRR during romstage to cache all dram, which
is currently worked around by using additional MTRR to make that UC.
TODO be nice to reviewers and spit some parts off.
UNTESTED
Change-Id: I7ff2a57aee620908b71829457ea0f5a0c410ec5b
Signed-off-by: Arthur Heymans <arthur(a)aheymans.xyz>
---
M src/arch/x86/postcar_loader.c
M src/cpu/x86/cache/Makefile.inc
M src/cpu/x86/cache/cache.c
M src/include/cpu/x86/cache.h
4 files changed, 68 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/37196/1
diff --git a/src/arch/x86/postcar_loader.c b/src/arch/x86/postcar_loader.c
index b53cbf8..53ab4f9 100644
--- a/src/arch/x86/postcar_loader.c
+++ b/src/arch/x86/postcar_loader.c
@@ -208,6 +208,21 @@
MTRR_TYPE_WRBACK);
}
+/*
+ * POSTCAR will call invd so don't make assumptions on cbmem
+ * and external stage cache being UC.
+ */
+static void postcar_flush_cache(void)
+{
+ uintptr_t stage_cache_base;
+ size_t stage_cache_size;
+ prog_segment_loaded((uintptr_t)cbmem_top(), cbmem_overhead_size(), SEG_FINAL);
+ if (CONFIG(TSEG_STAGE_CACHE)) {
+ stage_cache_external_region((void **)&stage_cache_base, &stage_cache_size);
+ prog_segment_loaded(stage_cache_base, stage_cache_size, SEG_FINAL);
+ }
+}
+
void run_postcar_phase(struct postcar_frame *pcf)
{
struct prog prog =
@@ -222,8 +237,10 @@
parameters between S3 resume and normal boot. On the
platforms where the values are the same it's a nop. */
finalize_load(prog.arg, pcf->stack);
- } else
+ } else {
load_postcar_cbfs(&prog, pcf);
+ postcar_flush_cache();
+ }
/* As postcar exist, it's end of romstage here */
timestamp_add_now(TS_END_ROMSTAGE);
diff --git a/src/cpu/x86/cache/Makefile.inc b/src/cpu/x86/cache/Makefile.inc
index b33b9ee..759488e 100644
--- a/src/cpu/x86/cache/Makefile.inc
+++ b/src/cpu/x86/cache/Makefile.inc
@@ -1 +1,2 @@
+romstage-y += cache.c
ramstage-y += cache.c
diff --git a/src/cpu/x86/cache/cache.c b/src/cpu/x86/cache/cache.c
index 2313c4d..ac2c45b 100644
--- a/src/cpu/x86/cache/cache.c
+++ b/src/cpu/x86/cache/cache.c
@@ -11,8 +11,11 @@
* GNU General Public License for more details.
*/
+#include <cbmem.h>
+#include <program_loading.h>
#include <console/console.h>
#include <cpu/x86/cache.h>
+#include <arch/cpu.h>
void x86_enable_cache(void)
{
@@ -20,3 +23,47 @@
printk(BIOS_INFO, "Enabling cache\n");
enable_cache();
}
+
+int clflush_supported(void)
+{
+ return (cpuid_edx(1) >> 19) & 1;
+}
+
+static void clflush_region(uintptr_t start, size_t size)
+{
+ uintptr_t addr;
+ size_t cl_size = (cpuid_ebx(1) >> 8) & 0xff;
+ if (!clflush_supported())
+ return;
+ for (addr = (start / cl_size) * cl_size; addr < start + size; addr += cl_size)
+ clflush((void *)addr);
+}
+
+static int dram_ready;
+
+/*
+ * For each segment of a program loaded this function is called
+ * to invalidate caches for the addresses of the loaded segment
+ */
+void arch_segment_loaded(uintptr_t start, size_t size, int flags)
+{
+ /* INVD is only called in postcar stage so we only need
+ to make sure that our things hit dram during romstage. */
+ if (!ENV_ROMSTAGE)
+ return;
+ if (flags != SEG_FINAL)
+ return;
+ if (!dram_ready)
+ return;
+
+ if (!clflush_supported())
+ printk(BIOS_DEBUG, "Not flushing cache to ram, CLFLUSH not supported\n");
+ clflush_region(start, size);
+}
+
+static void set_dram_ready(int unused)
+{
+ dram_ready = 1;
+}
+
+ROMSTAGE_CBMEM_INIT_HOOK(set_dram_ready);
diff --git a/src/include/cpu/x86/cache.h b/src/include/cpu/x86/cache.h
index 713ca32..2d2727f 100644
--- a/src/include/cpu/x86/cache.h
+++ b/src/include/cpu/x86/cache.h
@@ -55,6 +55,8 @@
asm volatile ("clflush (%0)"::"r" (addr));
}
+int clflush_supported(void);
+
/* The following functions require the __always_inline due to AMD
* function STOP_CAR_AND_CPU that disables cache as
* RAM, the cache as RAM stack can no longer be used. Called
--
To view, visit https://review.coreboot.org/c/coreboot/+/37196
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7ff2a57aee620908b71829457ea0f5a0c410ec5b
Gerrit-Change-Number: 37196
Gerrit-PatchSet: 1
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-MessageType: newchange
nsekar(a)codeaurora.org has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32063
Change subject: Mistral: Enable USB in romstage
......................................................................
Mistral: Enable USB in romstage
Enable USB support for mistral in romstage.
TEST=build & run
Change-Id: I5c2bbe16aa3601e014a2b77d192565402ed23794
Signed-off-by: Nitheesh Sekar <nsekar(a)codeaurora.org>
---
M src/mainboard/google/mistral/Makefile.inc
M src/mainboard/google/mistral/mainboard.c
A src/mainboard/google/mistral/romstage.c
3 files changed, 48 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/63/32063/1
diff --git a/src/mainboard/google/mistral/Makefile.inc b/src/mainboard/google/mistral/Makefile.inc
index dfb0bbc..2cb9631 100644
--- a/src/mainboard/google/mistral/Makefile.inc
+++ b/src/mainboard/google/mistral/Makefile.inc
@@ -11,6 +11,7 @@
romstage-y += memlayout.ld
romstage-y += chromeos.c
romstage-y += reset.c
+romstage-y += romstage.c
ramstage-y += memlayout.ld
ramstage-y += chromeos.c
diff --git a/src/mainboard/google/mistral/mainboard.c b/src/mainboard/google/mistral/mainboard.c
index b45657f..1d62adb 100644
--- a/src/mainboard/google/mistral/mainboard.c
+++ b/src/mainboard/google/mistral/mainboard.c
@@ -17,6 +17,20 @@
#include <bootblock_common.h>
#include <timestamp.h>
#include <vendorcode/google/chromeos/chromeos.h>
+#include <soc/usb.h>
+
+static struct usb_board_data usb1_board_data = {
+ .parameter_override_x0 = 0x63,
+ .parameter_override_x1 = 0x03,
+ .parameter_override_x0 = 0x1d,
+ .parameter_override_x1 = 0x03,
+};
+
+static void setup_usb(void)
+{
+ /* Setting Secondary usb controller */
+ setup_usb_host(HSUSB_HS_PORT_1, &usb1_board_data);
+}
static void mainboard_init(struct device *dev)
{
@@ -24,6 +38,8 @@
/* Copy WIFI calibration data into CBMEM. */
cbmem_add_vpd_calibration_data();
}
+
+ setup_usb();
}
static void mainboard_enable(struct device *dev)
diff --git a/src/mainboard/google/mistral/romstage.c b/src/mainboard/google/mistral/romstage.c
new file mode 100644
index 0000000..41ee4ed
--- /dev/null
+++ b/src/mainboard/google/mistral/romstage.c
@@ -0,0 +1,31 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2018, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/stages.h>
+#include <soc/usb.h>
+
+static void prepare_usb(void)
+{
+ /*
+ * Do DWC3 core and phy reset. Kick these resets off early
+ * so they get atleast 1msec to settle.
+ */
+ reset_usb(HSUSB_HS_PORT_1);
+}
+
+void platform_romstage_main(void)
+{
+ prepare_usb();
+}
--
To view, visit https://review.coreboot.org/c/coreboot/+/32063
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I5c2bbe16aa3601e014a2b77d192565402ed23794
Gerrit-Change-Number: 32063
Gerrit-PatchSet: 1
Gerrit-Owner: nsekar(a)codeaurora.org
Gerrit-MessageType: newchange