Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.kernel > #84232

Bug#1080340: initramfs-tools does not use include firmware named in the devicetree

From Bryan O'Donoghue <bryan.odonoghue@nexus-software.ie>
Newsgroups linux.debian.bugs.dist, linux.debian.kernel
Subject Bug#1080340: initramfs-tools does not use include firmware named in the devicetree
Date 2024-10-07 18:10 +0200
Message-ID <JuYt4-hzZ6-7@gated-at.bofh.it> (permalink)
References <JifL4-9smF-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Cross-posted to 2 groups.

Show all headers | View raw


On Mon, 02 Sep 2024 14:47:17 +0100 Daniel Thompson 
<debianbugs@redfelineninja.org.uk> wrote:
> Package: initramfs-tools
> Version: 0.145
> Severity: normal
> Tags: patch
> X-Debbugs-Cc: debianbugs@redfelineninja.org.uk
> 
> Dear Maintainer,
> 
> Currently initramfs-tools relies on modinfo to identify firmware that must
> be included in the initramfs. This is incomplete on systems where the name
> of the firmware to load is provided by the devicetree rather than being
> hardcoded and recorded in the MODULE_FIRMWARE() macro.
> 
> As a concrete example, recent Windows-on-Snapdragon laptops (Thinkpad X13s for
> example) require firmware for the remoteproc drivers. If this firmware is not
> available when the driver comes up then significant functionality (battery
> status, external display, etc) is disabled. The combination of my MODULES=most
> setup (plus encrypted rootfs and a few explicitly named modules) is exactly
> that.
> 
> I disliked the idea that having a richer initramfs (including the remoteproc
> drivers) can kills functionality so rather than try and blocklist things I
> instead added an initramfs hook to scan the current devicetree and include any
> firmware that might be needed.
> 
> ~~~
> #!/bin/sh -e
> 
> # Copyright (C) Linaro Ltd, 2024
> # SPDX-License-Identifier: GPL-2.0-or-later
> 
> # Add firmware whose names are dictated by the devicetree. Such firmware cannot
> # be described in a MODULE_FIRMWARE() meaning modinfo based discovery tools are
> # insufficient to handle these cases.
> 
> # No prereqs
> if [ "$1" = "prereqs" ]; then exit 0; fi
> 
> . /usr/share/initramfs-tools/hook-functions
> 
> # Only run if this system is booted with a devicetree
> if [ ! -d /sys/firmware/devicetree ]; then exit 0; fi
> 
> # Scan for appropriately named devicetree nodes and add any firmware
> # we discover this way to the initramfs. Sadly we cannot tell the difference
> # between boot-critical firmware and any other so we have to be over-zealous.
> # However the impact on initramfs size should be acceptable because we only
> # scan the devicetree of the booted system.
> for node in $(find /sys/firmware/devicetree -name firmware-name); do
>         firmware="$(cat "${node}")"
>         if ! add_firmware "${firmware}"; then
>                 echo "W: Possible missing firmware /lib/firmware/${firmware}
> found in devicetree" >&2
>         fi
> done
> ~~~
> 
> It occurred to me that adding any devicetree specified firmware is a fairly
> sensible default. The above code is harmless on ACPI-based systems and although
> it's slightly over-zealous it shouldn't bloat the initramfs since too much

I tried this fix out on x13s as I tried booting 6.12-rc1 today and found 
various of my devices not coming up.

Worked first time.

Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

Back to linux.debian.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Bug#1080340: initramfs-tools does not use include firmware named in the devicetree Daniel Thompson <debianbugs@redfelineninja.org.uk> - 2024-09-02 16:00 +0200
  Bug#1080340: initramfs-tools does not use include firmware named in the devicetree Bryan O'Donoghue <bryan.odonoghue@nexus-software.ie> - 2024-10-07 18:10 +0200

csiph-web