firmware: Add the support for ZSTD-compressed firmware files

As the growing demand on ZSTD compressions, there have been requests
for the support of ZSTD-compressed firmware files, so here it is:
this patch extends the firmware loader code to allow loading ZSTD
files.  The implementation is fairly straightforward, it just adds a
ZSTD decompression routine for the file expander.  (And the code is
even simpler than XZ thanks to the ZSTD API that gives the original
decompressed size from the header.)

Link: https://lore.kernel.org/all/20210127154939.13288-1-tiwai@suse.de/
Tested-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20220421152908.4718-2-tiwai@suse.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Takashi Iwai
2022-04-21 17:29:04 +02:00
committed by Greg Kroah-Hartman
parent ce522ba9ef
commit 23cfbc6ec4
2 changed files with 91 additions and 9 deletions

View File

@@ -159,21 +159,33 @@ config FW_LOADER_USER_HELPER_FALLBACK
config FW_LOADER_COMPRESS
bool "Enable compressed firmware support"
select FW_LOADER_PAGED_BUF
select XZ_DEC
help
This option enables the support for loading compressed firmware
files. The caller of firmware API receives the decompressed file
content. The compressed file is loaded as a fallback, only after
loading the raw file failed at first.
Currently only XZ-compressed files are supported, and they have to
be compressed with either none or crc32 integrity check type (pass
"-C crc32" option to xz command).
Compressed firmware support does not apply to firmware images
that are built into the kernel image (CONFIG_EXTRA_FIRMWARE).
if FW_LOADER_COMPRESS
config FW_LOADER_COMPRESS_XZ
bool "Enable XZ-compressed firmware support"
select FW_LOADER_PAGED_BUF
select XZ_DEC
help
This option adds the support for XZ-compressed files.
The files have to be compressed with either none or crc32
integrity check type (pass "-C crc32" option to xz command).
config FW_LOADER_COMPRESS_ZSTD
bool "Enable ZSTD-compressed firmware support"
select ZSTD_DECOMPRESS
help
This option adds the support for ZSTD-compressed files.
endif # FW_LOADER_COMPRESS
config FW_CACHE
bool "Enable firmware caching during suspend"
depends on PM_SLEEP