Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 695666

Summary: sys-kernel/linux-firmware add xz USE flag to compress firmware files
Product: Gentoo Linux Reporter: Chí-Thanh Christopher Nguyễn <chithanh>
Component: Current packagesAssignee: Chí-Thanh Christopher Nguyễn <chithanh>
Status: RESOLVED FIXED    
Severity: enhancement CC: alexander, gabriele.svelto, kernel, mpagano, pacho, sam, zerochaos
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: linux-firmware-20191215.ebuild.patch
linux-firmware-20191215.ebuild.patch

Description Chí-Thanh Christopher Nguyễn gentoo-dev 2019-09-26 10:25:18 UTC
Since kernel 5.3 the firmware loader supports xz compressed firmware files.

Compressing the linux-firmware tree would reduce its size considerably, for linux-firmware-20190923 from 470 MB to 145 MB.

What would need to be done:

* call xz on every firmware file
* Introduce check for CONFIG_FW_LOADER_COMPRESS
* Determine whether CONFIG_INITRAMFS_SOURCE works with compressed firmware files, and if not warn users
* Deal with symlinks in the linux-firmware tree
Comment 1 Alexander Tsoy 2020-01-07 04:05:15 UTC
Created attachment 602702 [details]
linux-firmware-20191215.ebuild.patch

My attempt to implement it.

* No check for CONFIG_FW_LOADER_COMPRESS yet.
* Since we are compressing files installed by the package, I thinks using "xz" is not quite appropriate. I've chosen "compress" for now.

(In reply to Chí-Thanh Christopher Nguyễn from comment #0)
> * Determine whether CONFIG_INITRAMFS_SOURCE works with compressed firmware
> files, and if not warn users
I don't understand this part.
Comment 2 Alexander Tsoy 2020-01-07 04:08:50 UTC
"-C none" can be used as well. The default is "crc64" which is not supported by the kernel.
Comment 3 Alexander Tsoy 2020-01-07 04:57:51 UTC
(In reply to Alexander Tsoy from comment #1)
> (In reply to Chí-Thanh Christopher Nguyễn from comment #0)
> > * Determine whether CONFIG_INITRAMFS_SOURCE works with compressed firmware
> > files, and if not warn users
> I don't understand this part.
Ah, got it. CONFIG_INITRAMFS_SOURCE may contain paths to firmware files.
Comment 4 Alexander Tsoy 2020-01-07 17:07:49 UTC
Created attachment 602760 [details]
linux-firmware-20191215.ebuild.patch

* skip compression of the amd-ucode directory. genkernel and dracut cannot read compressed AMD microcode.
Comment 5 Larry the Git Cow gentoo-dev 2022-10-28 17:02:04 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=12113f5d57730f8c36d3df433ec7f1606519e360

commit 12113f5d57730f8c36d3df433ec7f1606519e360
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-10-28 16:56:33 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-10-28 17:01:51 +0000

    sys-kernel/linux-firmware: add USE=compress
    
    This compresses installed firmware with xz. Note that
    FW_LOADER_COMPRESS must be enabled in the kernel.
    
    Closes: https://bugs.gentoo.org/695666
    Thanks-to: Alexander Tsoy <alexander@tsoy.me>
    Signed-off-by: Sam James <sam@gentoo.org>

 .../linux-firmware-20221012-r1.ebuild              | 374 +++++++++++++++++++++
 .../linux-firmware/linux-firmware-99999999.ebuild  |  34 +-
 sys-kernel/linux-firmware/metadata.xml             |   1 +
 3 files changed, 405 insertions(+), 4 deletions(-)