All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 0/7] misc: fs_loader: reorg and split to FS and FW loader + FIP loader
@ 2026-10-22 19:40 Christian Marangi
  2026-10-22 19:40 ` [PATCH v8 1/7] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Christian Marangi @ 2026-10-22 19:40 UTC (permalink / raw)
  To: Simon Glass, Tom Rini, Mattijs Korpershoek, Marek Vasut,
	Heiko Schocher, Neil Armstrong, Alexey Charkov, Daniel Golle,
	Aristo Chen, Christian Marangi, Lucien.Jheng, Mehmet Fide,
	Casey Connolly, Michal Simek, Quentin Schulz, Johan Jonker,
	Anshul Dalal, Romain Gantois, Mateus Lima Alves,
	Marcello Sylvester Bauer, Tan Siewert, Peng Fan, Patrice Chotard,
	Yao Zi, Heinrich Schuchardt, Martin Schwan, u-boot

This series mainly rework the FS loader to permit reading firmware from
container that are not exactly a readable filesystem.

Also splitting out the generic firmware loader infra from the
filesystem-specific code will make adding new loader types easier.

One scenario is when a firmware is shipped in a FIP container as
a generic blob with an UUID.

FIP are mostly used on ARM in the context of ATF.
In such context U-Boot is loaded as BL31 and the PHY firmware
can't be stored in the FIT image for the kernel as U-Boot should
not depend on the presence of the kernel to correctly enable PHY
for Ethernet port.

To handle such case the PHY firmware is stored in FIP with a
predictable UUID.

One example is with Airoha 8811H firmware where the FIP can
have a blob with UUID "d39d2cf2-9bd0-3ca7-93e9-e71b4f9250b2".
(generated from command "uuidgen -n @dns --md5 --name en8811h.bin")

With these example DTS entry:

fs_loader0: fip-loader {
	bootph-all;
	compatible = "u-boot,fip-loader";
	phandlepart = <&mmc0 0>;
	partoffset = <0x100>;
};

mdio {
  en8811: ethernet-phy@f {
    reg = <0xf>;
    firmware-name = "d39d2cf2-9bd0-3ca7-93e9-e71b4f9250b2";
    firmware-loader = <&fs_loader0>;
  };
};

And PHY driver using the get_fw_loader_from_node() and the
common request_firmware_into_buf() it's possible to
load the PHY firmware transparently by just declaring
the required entry in the DTS.

get_fw_loader_from_node() is implemented to actual get the
loader from DT. This was something that was already in mind
from when the FS loader was implemented but then it was
never implemented in favor of a single loader per device.

The first patch is a minor fixup for something that probably
won't ever happen.

The second one is a good reworking of the FS and FW loader
moving the internal struct to a dedicated header. (this is
really to enforce what drivers should use and what
driver should not mess with)

Then there is the request_firmware_size() new OP to get only
the size of the firmware. Useful for case where the firmware
size is not always the same and change across different version.
(the patter might be get size -> alloc buffer -> get firmware).

Then the FIP loader as a basic parser of FIP. This only
read the FIP header, loop all the entry and search for a
matching UUID. If nothing is found then no firmware blob.
Very simple implementation.

This is being CI tested on [0]

[0] https://github.com/u-boot/u-boot/pull/884

Changes v8:
- Address all the comments from Simon
- Massively improve test coverage for both FS and FIP
- Enable mmc node when needed for the tests
- Change FIP implementation to follow FS one
  (read up to buf size or end of entry size)
  (complain when offset is bigger than size of entry)
- Update related documentation for fw loader
- Rebase on top of next
Changes v7:
- Add tests
- Rebase on top of next
- Fix compilation for vpl
Changes v6:
- Rework to generic FW loader UCLASS
- Account for firmware offset in FIP loader
- Add UBI example in documentation
- Improve variables order
Changes v5:
- Fix unment dependency for config flag
- Move request_firmware_size before FIP loader
- Add documentation patch
- Improve get_fw_loader_from_node() implementation
- use min() instead of custom MIN()
- Fix handling of some return value
Changes v4:
- Rebase on top of next
Changes v3:
- Add review tag where possible
- Check blk_dread ret
- Generalize mount_ubifs with generic_fw_loader_ubi_select
- Fix some typo
- Drop useless ubifs umount (nothing is mounted in FIP)
Changes v2:
- Better handle header include to fix compilation error
  on some devices
- Fix typo for ubifs fix commit

Christian Marangi (7):
  misc: fs_loader: fix ubifs not unmounted on dev_get_priv error
  misc: fs_loader: reorganize and split to FS loader and FW UCLASS
  misc: fw_loader: implement generic get_fw_loader_from_node()
  misc: fw_loader: implement request_firmware_size() OP
  misc: fw_loader: introduce FIP loader driver
  doc: dtbinding: Update documentation for Generic Firmware loader
  test: dm: Add test for FW Loader feature

 arch/sandbox/dts/test.dts                     |  38 ++
 configs/sandbox64_defconfig                   |   2 +
 configs/sandbox_defconfig                     |   2 +
 configs/sandbox_flattree_defconfig            |   2 +
 configs/sandbox_noinst_defconfig              |   1 +
 configs/sandbox_spl_defconfig                 |   2 +
 configs/sandbox_vpl_defconfig                 |   2 +
 ...irmware_loader.rst => firmware_loader.rst} |   6 +-
 doc/develop/driver-model/index.rst            |   2 +-
 doc/device-tree-bindings/misc/fs_loader.txt   |  48 --
 doc/device-tree-bindings/misc/fw_loader.yaml  | 126 ++++
 drivers/misc/Kconfig                          |  31 +
 drivers/misc/Makefile                         |   2 +-
 drivers/misc/fs_loader.c                      | 326 ----------
 drivers/misc/fw_loader/Makefile               |   5 +
 drivers/misc/fw_loader/fip_loader.c           | 556 ++++++++++++++++++
 drivers/misc/fw_loader/fs_loader.c            | 220 +++++++
 drivers/misc/fw_loader/fw_loader-uclass.c     | 231 ++++++++
 drivers/misc/fw_loader/internal.h             | 100 ++++
 include/dm/uclass-id.h                        |   2 +-
 include/fs_loader.h                           |  47 +-
 include/fw_loader.h                           |  42 ++
 test/dm/Makefile                              |   1 +
 test/dm/fw_loader.c                           | 218 +++++++
 test/py/tests/fip/test.fip                    | Bin 0 -> 101 bytes
 test/py/tests/test_ut.py                      |  26 +
 26 files changed, 1613 insertions(+), 425 deletions(-)
 rename doc/develop/driver-model/{fs_firmware_loader.rst => firmware_loader.rst} (95%)
 delete mode 100644 doc/device-tree-bindings/misc/fs_loader.txt
 create mode 100644 doc/device-tree-bindings/misc/fw_loader.yaml
 delete mode 100644 drivers/misc/fs_loader.c
 create mode 100644 drivers/misc/fw_loader/Makefile
 create mode 100644 drivers/misc/fw_loader/fip_loader.c
 create mode 100644 drivers/misc/fw_loader/fs_loader.c
 create mode 100644 drivers/misc/fw_loader/fw_loader-uclass.c
 create mode 100644 drivers/misc/fw_loader/internal.h
 create mode 100644 test/dm/fw_loader.c
 create mode 100644 test/py/tests/fip/test.fip

-- 
2.55.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-10-23 16:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-22 19:40 [PATCH v8 0/7] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Christian Marangi
2026-10-22 19:40 ` [PATCH v8 1/7] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
2026-10-22 19:40 ` [PATCH v8 2/7] misc: fs_loader: reorganize and split to FS loader and FW UCLASS Christian Marangi
2026-10-23 13:12   ` Simon Glass
2026-10-23 16:22     ` Christian Marangi
2026-10-22 19:40 ` [PATCH v8 3/7] misc: fw_loader: implement generic get_fw_loader_from_node() Christian Marangi
2026-10-22 19:40 ` [PATCH v8 4/7] misc: fw_loader: implement request_firmware_size() OP Christian Marangi
2026-10-22 19:40 ` [PATCH v8 5/7] misc: fw_loader: introduce FIP loader driver Christian Marangi
2026-10-23 13:12   ` Simon Glass
2026-10-23 16:22     ` Christian Marangi
2026-10-22 19:40 ` [PATCH v8 6/7] doc: dtbinding: Update documentation for Generic Firmware loader Christian Marangi
2026-10-23 13:12   ` Simon Glass
2026-10-22 19:40 ` [PATCH v8 7/7] test: dm: Add test for FW Loader feature Christian Marangi
2026-10-23 13:12   ` Simon Glass
2026-10-23 16:27     ` Christian Marangi
2026-10-23 13:12 ` [PATCH v8 0/7] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.