Hi all,

This series adds support for the hardware random number generator (RNG) on
the Microchip PolarFire SoC (MPFS) and fixes several related issues
uncovered during integration and testing.

The MPFS hardware RNG is accessed indirectly via the MPFS system
controller using the mailbox interface. Unlike typical memory-mapped RNGs,
the system controller mailbox is shared and non‑reentrant, which
introduces integration challenges in U‑Boot’s synchronous, polled
execution model during early boot.
While integrating the RNG support, testing revealed that mailbox requests
issued during autoboot could fail spuriously due to transient mailbox
BUSY states. Investigation showed that the MPFS mailbox BUSY indication
reflects multiple phases of the underlying IHC handshake, allowing
U-Boot’s polled model to observe intermediate states that Linux’s
interrupt-driven model normally hides.

This series addresses those challenges in various ways.
1. Adds missing infrastructure in the MPFS system controller driver to
explicitly receive mailbox responses.
2. Binds the MPFS RNG as a sub‑device of the system controller, mirroring
Linux behaviour and avoiding the need for a device tree node.
3. Introduces a new MPFS RNG driver implementing UCLASS_RNG.
4. Enables RNG support in the Microchip PolarFire SoC generic defconfig.
5. Replaces unbounded polling loops with regmap_read_poll_timeout().
6. Replaces an immediate -EBUSY return with a bounded wait for BUSY to
clear, before issuing requests, avoiding spurious early-boot mailbox
failures and allowing KASLR seed generation to complete successfully
during autoboot.

The resulting behaviour matches Linux semantics where practical while
remaining appropriate for U-Boot’s single-threaded execution model.
Interactive RNG usage and boot-time KASLR seed generation both work
reliably after the mailbox sequencing fixes.

All changes have been tested on the PolarFire SoC Icicle Kit ES.

Regards,
Jamie.

v1 -> v2:
- Removal of patch 1/8 (cmd: rng: fix error handling for dm_rng_read())
  after correcting the MPFS RNG driver to follow existing UCLASS_RNG
  semantics (0 on success, negative errno on failure).
- Removal of patch 8/8 (boot: fdt: downgrade KASLR RNG failure to warning)
  after the mailbox sequencing fixes resolved the early-boot RNG failure
  along with the correct return value fix above.
- Moved `DM_RNG` selection into the defconfig enablement patch.
- Removed special-casing of `-EBUSY` in the system controller path.
- Removed informational RNG registration logging.
- Added review/ack tags where applicable.

Jamie Gibbons (6):
  misc: mpfs_syscontroller: add mailbox RX helper for service responses
  misc: mpfs_syscontroller: bind RNG sub-device
  rng: add Microchip PolarFire SoC hardware RNG driver
  configs: microchip_mpfs_generic: enable MPFS RNG support
  mailbox: mpfs-mbox: replace unbounded BUSY polling with bounded waits
  mailbox: mpfs: add bounded wait for BUSY to clear before sending
    request

 configs/microchip_mpfs_generic_defconfig |   3 +
 drivers/mailbox/mpfs-mbox.c              |  27 ++++--
 drivers/misc/mpfs_syscontroller.c        |  36 +++++++-
 drivers/rng/Kconfig                      |   7 ++
 drivers/rng/Makefile                     |   1 +
 drivers/rng/mpfs_rng.c                   | 101 +++++++++++++++++++++++
 include/mpfs-mailbox.h                   |   2 +
 7 files changed, 165 insertions(+), 12 deletions(-)
 create mode 100644 drivers/rng/mpfs_rng.c

-- 
2.43.0

Reply via email to