I'm working on a feature for Arch Linux's initramfs generator,
mkinitcpio, that'll make it more specific about the GPU firmware it
includes for i915, xe, amdgpu, and nouveau (also nvidia-open).
The idea is to detect the GPUs present using lspci ::0300, and include
only firmware required for those cards.
I noticed my coffelake based system (0x3e9b Intel UHD 630) always loads
i915/kbl_dmc_ver1_04.bin
If all kernel versions that support this particular GPU load a file
with this prefix, we could use a glob pattern like
i915/kbl_dmc*
and filter
modinfo -F firmware -k $kver i915
output to be much more precise about the files included in the
initramfs for current and future kernels, shrinking it by several
megabytes without loss of functionality, provided the GPU isn't
swapped.
Another of my systems with a Ryzen 5625U loads firmware with the prefix
amdgpu/green_sardine_
Including only files with that prefix resulted in the initramfs
shrinking by 25M.
And for nouveau, I'm thinking the structure of /lib/firmware/nvidia/,
which contains directories like ga102/ and gp104/ implies you just need
files in gp104/ if you have a GP104 based GPU. The corresponding chip
name for a given Nvidia device ID can be found using hwdata/pci.ids.
I'm hoping for clarity on the stability of these prefixes: can they be
relied upon? If yes, I could build a mapping of PCI device IDs to
firmware prefixes using the MODULE_DEVICE_TABLE entries in the module
sources or just parse dmesg output containing log entries about successful
firmware loads to extract the prefixes without having to hardcode
a table.
Stable prefixes would mean this table can be built once and used
by initramfs generators to shrink initrds which include GPU modules by
tens of megabytes, with little to no maintenance burden. We'd just have
to add entries for new GPUs as they're launched. This could also help
Fedora deal with space pressure on /boot due to the increasing size of
nouveau firmware which had them land an emergency change to double
/boot size to 2G for new installs.
Thanks,
Aditya