All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Heiko Schocher <hs@nabladev.com>,
	Alexey Charkov <alchark@flipper.net>,
	Rasmus Villemoes <ravi@prevas.dk>,
	"Lucien.Jheng" <lucienzx159@gmail.com>,
	"Markus Schneider-Pargmann (TI.com)" <msp@baylibre.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Daniel Golle <daniel@makrotopia.org>,
	Mehmet Fide <mehmet.fide@screeningeagle.com>,
	Casey Connolly <casey.connolly@linaro.org>,
	Michal Simek <michal.simek@amd.com>,
	Aristo Chen <aristo.chen@canonical.com>,
	Quentin Schulz <quentin.schulz@cherry.de>,
	Johan Jonker <jbx6244@gmail.com>, Anshul Dalal <anshuld@ti.com>,
	Marcello Sylvester Bauer <marcello.bauer@9elements.com>,
	Mateus Lima Alves <mateuslima.ti@gmail.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Neha Malcom Francis <n-francis@ti.com>, Yao Zi <me@ziyao.cc>,
	Peng Fan <peng.fan@nxp.com>, Martin Schwan <m.schwan@phytec.de>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	u-boot@lists.u-boot-project.org
Subject: [PATCH v11 0/8] misc: fs_loader: reorg and split to FS and FW loader + FIP loader
Date: Tue, 27 Oct 2026 13:38:55 +0100	[thread overview]
Message-ID: <20261027123905.839-1-ansuelsmth@gmail.com> (raw)

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:

fw_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 = <&fw_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 v11:
- Address request for test patch from v9
- Add additional test and comments
- Validate memory for FS test
- Fix defconfig order
Changes v10:
- Add review tag by Simon
- Use min_t for FIP driver
- Prevent double mount of ubi
Changes v9:
- Drop FIP blob in favor of dynamic generation
- Rename fs_loader to fw_loader
- Add additional patch for offset validation
- More use of lbaint_t
- Handle reading 0 for UBI
- Update MTD/UBI documentation and YAML conditions
- Make generic_fw_loader_get_phandle_desc handling explicit
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 (8):
  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: fs_loader: validate requested offset on reading file
  misc: fw_loader: implement request_firmware_size() OP
  doc: dtbinding: Update documentation for Generic Firmware loader
  misc: fw_loader: introduce FIP loader driver
  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              |   2 +
 configs/sandbox_spl_defconfig                 |   4 +
 configs/sandbox_vpl_defconfig                 |   4 +
 ...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  | 112 ++++
 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           | 558 ++++++++++++++++++
 drivers/misc/fw_loader/fs_loader.c            | 260 ++++++++
 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                           | 254 ++++++++
 test/py/tests/test_ut.py                      |  58 ++
 25 files changed, 1714 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

-- 
2.55.0


             reply	other threads:[~2026-10-27 12:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27 12:38 Christian Marangi [this message]
2026-10-27 12:38 ` [PATCH v11 1/8] misc: fs_loader: fix ubifs not unmounted on dev_get_priv error Christian Marangi
2026-10-27 12:38 ` [PATCH v11 2/8] misc: fs_loader: reorganize and split to FS loader and FW UCLASS Christian Marangi
2026-10-27 12:38 ` [PATCH v11 3/8] misc: fw_loader: implement generic get_fw_loader_from_node() Christian Marangi
2026-10-27 12:38 ` [PATCH v11 4/8] misc: fs_loader: validate requested offset on reading file Christian Marangi
2026-10-27 14:36   ` Simon Glass
2026-10-27 14:41     ` Christian Marangi (Ansuel)
2026-10-27 12:39 ` [PATCH v11 5/8] misc: fw_loader: implement request_firmware_size() OP Christian Marangi
2026-10-27 12:39 ` [PATCH v11 6/8] doc: dtbinding: Update documentation for Generic Firmware loader Christian Marangi
2026-10-27 12:39 ` [PATCH v11 7/8] misc: fw_loader: introduce FIP loader driver Christian Marangi
2026-10-27 12:39 ` [PATCH v11 8/8] test: dm: Add test for FW Loader feature Christian Marangi
2026-10-27 14:36   ` Simon Glass
2026-10-27 14:36 ` [PATCH v11 0/8] misc: fs_loader: reorg and split to FS and FW loader + FIP loader Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261027123905.839-1-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=alchark@flipper.net \
    --cc=anshuld@ti.com \
    --cc=aristo.chen@canonical.com \
    --cc=casey.connolly@linaro.org \
    --cc=daniel@makrotopia.org \
    --cc=hs@nabladev.com \
    --cc=jbx6244@gmail.com \
    --cc=lucienzx159@gmail.com \
    --cc=m.schwan@phytec.de \
    --cc=marcello.bauer@9elements.com \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=mateuslima.ti@gmail.com \
    --cc=me@ziyao.cc \
    --cc=mehmet.fide@screeningeagle.com \
    --cc=michal.simek@amd.com \
    --cc=mkorpershoek@kernel.org \
    --cc=msp@baylibre.com \
    --cc=n-francis@ti.com \
    --cc=neil.armstrong@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=quentin.schulz@cherry.de \
    --cc=ravi@prevas.dk \
    --cc=sjg@chromium.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.