[RFC PATCH 0/1] Add driver for bootstage stash

Francesco Valla <[email protected]> Fri, 23 May 2025 00:42:23 +0200
Newsgroups org.kernel.vger.linux-embedded
Message-ID <[email protected]>
Hello,

after the discussion on the "Unified Boot Log" topic during the latest
Boot Time SIG special meeting [1], I tried to mock up a driver that
reads a bootstage stash saved by the U-Boot bootloader in a given memory
area and exposes the data in a user- and machine- friendly through both
sysfs and debugfs attributes. Details on the interfaces, as well as
example output for the debugfs interfaces, can be found on the
documentation that is part of the patchset.

To use this driver, a memory area shall be reserved inside the Linux
kernel devicetree as follows (possibly changing the address and the size
of the memory area):

    bootstage@a4300000 {
        compatible = "bootstage";
        reg = <0 0xa4300000 0 0x1000>;
        no-map;
    };

At U-Boot side, following configuration shall then be set:

    CONFIG_BOOTSTAGE=y
    CONFIG_BOOTSTAGE_STASH_ADDR=0xa4300000
    CONFIG_BOOTSTAGE_STASH_SIZE=0x1000

Once booted, the bootstage data can will be found at:

    - /sys/devices/platform/a4300000.bootstage/
    - /sys/kernel/debug/bootstage/a4300000.bootstage/

The device name is purposely part of the sysfs and debugfs paths to
support multiple bootstage areas, as this _might_ then be used for
multiple bootstage sources, e.g. bootloaders running on different
cores inside a SoC with different architectures.

Note that this is not really meant to be integrated as-is, not only
because it's a single patch including code, documentation and devicetree
bindings, but also because the bootstage stash format itself may need to
be touched up a bit. In particular, fixed data type should probably be
evaluated for the bootstage record, in order to increase compatibility
with different data sources.


Comments are of course welcome.

Regards,

Francesco

[1] https://lore.kernel.org/linux-embedded/MW5PR13MB5632B8FA3279D77F2F9217BBFD9CA@MW5PR13MB5632.namprd13.prod.outlook.com/

Francesco Valla (1):
  drivers: misc: add driver for bootstage stash

 .../bindings/reserved-memory/bootstage.yaml   |  44 +++
 Documentation/misc-devices/bootstage.rst      |  53 ++++
 Documentation/misc-devices/index.rst          |   1 +
 MAINTAINERS                                   |   7 +
 drivers/misc/Kconfig                          |  10 +
 drivers/misc/Makefile                         |   1 +
 drivers/misc/bootstage.c                      | 292 ++++++++++++++++++
 drivers/of/platform.c                         |   1 +
 8 files changed, 409 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/reserved-memory/bootstage.yaml
 create mode 100644 Documentation/misc-devices/bootstage.rst
 create mode 100644 drivers/misc/bootstage.c

-- 
2.49.0