summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Roth <martin.roth@amd.com>2023-01-04 17:26:21 -0700
committerMartin L Roth <gaumless@gmail.com>2023-01-08 01:20:15 +0000
commit40729a58eaef5a349f2cae642020bb8e2caabdec (patch)
tree433a114b0750ad2e326220e5074470cc7945934d
parentc08585674afd75a3b01a0cbada6a15bff0ec503e (diff)
downloadcoreboot-40729a58eaef5a349f2cae642020bb8e2caabdec.tar.gz
coreboot-40729a58eaef5a349f2cae642020bb8e2caabdec.tar.bz2
coreboot-40729a58eaef5a349f2cae642020bb8e2caabdec.zip
Kconfig: Add option to compress ramstage with LZ4
When ramstage is loaded asynchronously, as on the skyrim boards, the faster decompression of LZ4 allows for faster boot times than the tighter compression of LZMA. To make this change, the name of the existing ramstage_compression option needs to be updated. BUG=b:264409477 TEST=Boot skyrim, look at boot speed Signed-off-by: Martin Roth <martin.roth@amd.corp-partner.google.com> Change-Id: I27dd1a8def024e0efd466cef9ffd9ca71717486a Reviewed-on: https://review.coreboot.org/c/coreboot/+/71673 Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--Makefile.inc5
-rw-r--r--src/Kconfig35
-rw-r--r--src/lib/Makefile.inc4
-rw-r--r--src/lib/cbfs.c2
4 files changed, 35 insertions, 11 deletions
diff --git a/Makefile.inc b/Makefile.inc
index 5cd13ba6f4c8..2b5d742a2cb8 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -372,9 +372,12 @@ cbfs-files-handler= \
#######################################################################
# a variety of flags for our build
CBFS_COMPRESS_FLAG:=none
-ifeq ($(CONFIG_COMPRESS_RAMSTAGE),y)
+ifeq ($(CONFIG_COMPRESS_RAMSTAGE_LZMA),y)
CBFS_COMPRESS_FLAG:=LZMA
endif
+ifeq ($(CONFIG_COMPRESS_RAMSTAGE_LZ4),y)
+CBFS_COMPRESS_FLAG:=LZ4
+endif
CBFS_PAYLOAD_COMPRESS_FLAG:=none
ifeq ($(CONFIG_COMPRESSED_PAYLOAD_LZMA),y)
diff --git a/src/Kconfig b/src/Kconfig
index f68553c2a0bb..8246a17a3e2c 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -170,12 +170,36 @@ config STATIC_OPTION_TABLE
every boot. Use this if you want the NVRAM configuration to
never be modified from its default values.
-config COMPRESS_RAMSTAGE
+config MB_COMPRESS_RAMSTAGE_LZ4
+ bool
+ help
+ Select this in a mainboard to use LZ4 compression by default
+
+choice
+ prompt "Ramstage compression"
+ depends on HAVE_RAMSTAGE && !UNCOMPRESSED_RAMSTAGE
+ default COMPRESS_RAMSTAGE_LZ4 if MB_COMPRESS_RAMSTAGE_LZ4
+ default COMPRESS_RAMSTAGE_LZMA
+
+config COMPRESS_RAMSTAGE_LZMA
bool "Compress ramstage with LZMA"
- depends on HAVE_RAMSTAGE
- # Default value set at the end of the file
help
- Compress ramstage to save memory in the flash image.
+ Compress ramstage with LZMA to save memory in the flash image.
+
+config COMPRESS_RAMSTAGE_LZ4
+ bool "Compress ramstage with LZ4"
+ help
+ LZ4 doesn't give as good compression as LZMA, but decompresses much
+ faster. For large binaries such as ramstage, it's typically best to
+ use LZMA, but there can be cases where the faster decompression of
+ LZ4 can lead to a faster boot time. Testing on each individual board
+ is typically going to be needed due to the large number of factors
+ that can influence the decision. Binary size, CPU speed, ROM read
+ speed, cache, and other factors all play a part.
+
+ If you're not sure, stick with LZMA.
+
+endchoice
config COMPRESS_PRERAM_STAGES
bool "Compress romstage and verstage with LZ4"
@@ -1379,9 +1403,6 @@ config MEMLAYOUT_LD_FILE
# Set default values for symbols created before mainboards. This allows the
# option to be displayed in the general menu, but the default to be loaded in
# the mainboard if desired.
-config COMPRESS_RAMSTAGE
- default y if !UNCOMPRESSED_RAMSTAGE
-
config COMPRESS_PRERAM_STAGES
depends on (HAVE_ROMSTAGE || HAVE_VERSTAGE) && NO_XIP_EARLY_STAGES
default y
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index dcba0c61db6b..030959c9c67d 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -95,7 +95,7 @@ $(foreach arch,$(ARCH_SUPPORTED),\
romstage-y += fmap.c
romstage-y += delay.c
romstage-y += cbfs.c
-romstage-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c lzmadecode.c
+romstage-$(CONFIG_COMPRESS_RAMSTAGE_LZMA) += lzma.c lzmadecode.c
romstage-y += libgcc.c
romstage-y += memrange.c
romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c
@@ -294,7 +294,7 @@ postcar-y += fmap.c
postcar-y += gcc.c
postcar-y += halt.c
postcar-y += libgcc.c
-postcar-$(CONFIG_COMPRESS_RAMSTAGE) += lzma.c lzmadecode.c
+postcar-$(CONFIG_COMPRESS_RAMSTAGE_LZMA) += lzma.c lzmadecode.c
postcar-y += memchr.c
postcar-y += memcmp.c
postcar-y += prog_loaders.c
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index d2829d1d3eaf..0b2d66b33ac4 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -142,7 +142,7 @@ static inline bool cbfs_lzma_enabled(void)
return false;
if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE))
return false;
- if ((ENV_ROMSTAGE || ENV_POSTCAR) && !CONFIG(COMPRESS_RAMSTAGE))
+ if ((ENV_ROMSTAGE || ENV_POSTCAR) && !CONFIG(COMPRESS_RAMSTAGE_LZMA))
return false;
if (ENV_SMM)
return false;