Source: initramfs-tools
Version: 0.142
Severity: wishlist
Tags: patch
Dear Maintainer,
Resubmitting MR 61
https://salsa.debian.org/kernel-team/initramfs-tools/-/merge_requests/61
to debbugs after 4 months.
The patches, in order, do the following:
1. /sys/module/firmware_class/parameters/path, if any, is added before
anything else in the module loading path:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/firmware_loader/main.c?h=v5.17#n406
2. When configured with FW_LOADER_COMPRESS, Linux additionally
searches firmware with an .xz suffix and decompresses it in-kernel:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/firmware_loader/main.c?h=v5.17#n754
3. In 5.19, when configured with FW_LOADER_COMPRESS_ZSTD, Linux will
additionally support ZSTD-compression with a .zst suffix:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=23cfbc6ec44e5e80d5522976ff45ffcdcddfb230
The end-goal of this is that I'd like the firmware for which this is a
gain to be installed compressed in Debian
(firmware-amd-graphics firmware-iwlwifi firmware-linux-free,
a common setup, is 19M of .deb, 159M on-disk,
but just 51M when subjected to
find fw.xz/ -type f -exec xz {} \;
(61M zstd default, 55M zstd -19);
on one machine with that + 283M of xilinx firmware
the gain is 464M -> 87M (116M, 94M)).
Best,
наб
-- System Information:
Debian Release: 11.4
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 5.10.0-17-amd64 (SMP w/24 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_FIRMWARE_WORKAROUND, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
From 5774cc330c144f31a5aec00e016395149e810bb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Tue, 26 Apr 2022 15:41:59 +0200
Subject: [PATCH 1/3] Respect fw_path_para in add_firmware()
X-Mutt-PGP: OS
/sys/module/firmware_class/parameters/path, if any, is added before
anything else in the module loading path:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/firmware_loader/main.c?h=v5.17#n406
---
hook-functions | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/hook-functions b/hook-functions
index 95bd584..e9f09c0 100644
--- a/hook-functions
+++ b/hook-functions
@@ -28,7 +28,7 @@ force_load()
}
# Takes a file containing a list of modules to be added as an
-# argument, figures out dependancies, and adds them.
+# argument, figures out dependencies, and adds them.
#
# Input file syntax:
#
@@ -57,18 +57,23 @@ add_modules_from_file()
# whether a warning should be printed in that case.)
add_firmware()
{
- local firmware fwloc
+ local firmware fwloc fw_path_para path_firmware
firmware="${1}"
- if [ -e "${DESTDIR}/lib/firmware/updates/${version?}/${firmware}" ] \
+ read -r fw_path_para < /sys/module/firmware_class/parameters/path
+
+ if { [ -n "$fw_path_para" ] && [ -e "${DESTDIR}/${fw_path_para}/${firmware}" ]; } \
+ || [ -e "${DESTDIR}/lib/firmware/updates/${version?}/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/updates/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ] \
|| [ -e "${DESTDIR}/lib/firmware/${firmware}" ]; then
return 0
fi
- for fwloc in "/lib/firmware/updates/${version}/${firmware}" \
+ [ -n "$fw_path_para" ] && path_firmware="${fw_path_para}/${firmware}" || path_firmware=
+ for fwloc in "$path_firmware" \
+ "/lib/firmware/updates/${version}/${firmware}" \
"/lib/firmware/updates/${firmware}" \
"/lib/firmware/${version}/${firmware}" \
"/lib/firmware/${firmware}"; do
--
2.30.2
From c9fa06411d3116cf851b68c319669c0f3649fd46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Tue, 26 Apr 2022 15:49:45 +0200
Subject: [PATCH 2/3] Handle compressed firmware in add_firmware()
X-Mutt-PGP: OS
With CONFIG_FW_LOADER_COMPRESS, Linux additionally tries the normal
search path but suffixed with .xz, and decompresses it in-kernel, cf.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/firmware_loader/main.c?h=v5.17#n754
---
hook-functions | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/hook-functions b/hook-functions
index e9f09c0..3790343 100644
--- a/hook-functions
+++ b/hook-functions
@@ -57,32 +57,36 @@ add_modules_from_file()
# whether a warning should be printed in that case.)
add_firmware()
{
- local firmware fwloc fw_path_para path_firmware
+ local firmware suffix fwloc fw_path_para path_firmware
firmware="${1}"
read -r fw_path_para < /sys/module/firmware_class/parameters/path
- if { [ -n "$fw_path_para" ] && [ -e "${DESTDIR}/${fw_path_para}/${firmware}" ]; } \
- || [ -e "${DESTDIR}/lib/firmware/updates/${version?}/${firmware}" ] \
- || [ -e "${DESTDIR}/lib/firmware/updates/${firmware}" ] \
- || [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}" ] \
- || [ -e "${DESTDIR}/lib/firmware/${firmware}" ]; then
- return 0
- fi
-
- [ -n "$fw_path_para" ] && path_firmware="${fw_path_para}/${firmware}" || path_firmware=
- for fwloc in "$path_firmware" \
- "/lib/firmware/updates/${version}/${firmware}" \
- "/lib/firmware/updates/${firmware}" \
- "/lib/firmware/${version}/${firmware}" \
- "/lib/firmware/${firmware}"; do
- if [ -e "$fwloc" ]; then
- copy_file firmware "$fwloc"
+ for suffix in "" ".xz"; do
+ if { [ -n "$fw_path_para" ] && [ -e "${DESTDIR}/${fw_path_para}/${firmware}${suffix}" ]; } \
+ || [ -e "${DESTDIR}/lib/firmware/updates/${version?}/${firmware}${suffix}" ] \
+ || [ -e "${DESTDIR}/lib/firmware/updates/${firmware}${suffix}" ] \
+ || [ -e "${DESTDIR}/lib/firmware/${version}/${firmware}${suffix}" ] \
+ || [ -e "${DESTDIR}/lib/firmware/${firmware}${suffix}" ]; then
return 0
fi
done
+ for suffix in "" ".xz"; do
+ [ -n "$fw_path_para" ] && path_firmware="${fw_path_para}/${firmware}${suffix}" || path_firmware=
+ for fwloc in "$path_firmware" \
+ "/lib/firmware/updates/${version}/${firmware}${suffix}" \
+ "/lib/firmware/updates/${firmware}${suffix}" \
+ "/lib/firmware/${version}/${firmware}${suffix}" \
+ "/lib/firmware/${firmware}${suffix}"; do
+ if [ -e "$fwloc" ]; then
+ copy_file firmware "$fwloc"
+ return 0
+ fi
+ done
+ done
+
# We can't figure out where to get that firmware from.
return 1
}
--
2.30.2
From 1aa61184f923336823028e9565a8e8ff98dec39d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
Date: Tue, 26 Apr 2022 16:13:20 +0200
Subject: [PATCH 3/3] Support ZSTD-compressed firmware in add_firmware()
X-Mutt-PGP: OS
Since 5.19, .zst-suffixed firmware is be supported with precedence over
.xz, cf:
https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git/commit/?h=driver-core-next&id=23cfbc6ec44e5e80d5522976ff45ffcdcddfb230
---
hook-functions | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hook-functions b/hook-functions
index 3790343..6e4bde3 100644
--- a/hook-functions
+++ b/hook-functions
@@ -63,7 +63,7 @@ add_firmware()
read -r fw_path_para < /sys/module/firmware_class/parameters/path
- for suffix in "" ".xz"; do
+ for suffix in "" ".zst" ".xz"; do
if { [ -n "$fw_path_para" ] && [ -e "${DESTDIR}/${fw_path_para}/${firmware}${suffix}" ]; } \
|| [ -e "${DESTDIR}/lib/firmware/updates/${version?}/${firmware}${suffix}" ] \
|| [ -e "${DESTDIR}/lib/firmware/updates/${firmware}${suffix}" ] \
@@ -73,7 +73,7 @@ add_firmware()
fi
done
- for suffix in "" ".xz"; do
+ for suffix in "" ".zst" ".xz"; do
[ -n "$fw_path_para" ] && path_firmware="${fw_path_para}/${firmware}${suffix}" || path_firmware=
for fwloc in "$path_firmware" \
"/lib/firmware/updates/${version}/${firmware}${suffix}" \
--
2.30.2
Attachment:
signature.asc
Description: PGP signature