UFS devices have a built-in A/B boot mechanism implemented via the "boot
well known logical unit" (boot W-LU). This works by marking two of the
provisioned LUs with a flag in their unit configuration descriptor, and
setting the active boot LU in the whole device's attributes. The device
then exposes a special logical unit 0xb0 (the boot W-LU) which is
internally aliased to the currently active boot LU (if one is set). It
allows reading and writing directly through the 0xb0 LU, but doesn't
expose the LU geometry, so it is not quite a full-fledged block device.

Given that the normal use of this mechanism is for symmetric A/B boot,
real world scenarios will usually have both W-LU-A and W-LU-B provisioned
with identical geometry, so the geometry for the boot W-LU can be inferred
from the active boot LU, while its special 0xb0 LUN can still be used for
reads and writes to have the device itself abstract away the actual
request routing, even when the active boot LU is changed.

This series adds support for loading the U-Boot proper from the boot W-LU,
allowing to use the native A/B boot mechanism without the need to hardcode
the "real" LUN in the SPL configuration.

Two classes of prerequisites are handled by the first half of this series
before the enablement itself:
1. The SCSI core needs to learn to repeat inquiry requests when they
   return with a transitive non-zero status, such as the UNIT ATTENTION
   condition, which the W-LU returns when it's first talked to and which
   is not an error (patches 1-2)
2. The scan itself needs to learn to look beyond the normal LUN range when
   the implementation supports W-LUs, as they are numbered above 0x80, and
   "borrow" the geometry from the physical LU the W-LU is aliased to
   (patches 3-5)

Patches 6-10 are the enablement itself, split by logical parts.

CI passes all green:
https://git.u-boot-project.org/u-boot/contributors/alchark/u-boot/-/pipelines/1307

Signed-off-by: Alexey Charkov <[email protected]>
---
Changes in v2:
- Add a check for null wluns pointer (thanks Neil)
- Slightly reword the commit message on patch 1 (thanks Neil)
- Link to v1: 
https://patch.msgid.link/[email protected]

To: [email protected]
Cc: Tom Rini <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Bhupesh Sharma <[email protected]>
Cc: Neha Malcom Francis <[email protected]>
Cc: Alexey Charkov <[email protected]>
Cc: David Lechner <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Balaji Selvanathan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Aswin Murugan <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Denis Mukhin <[email protected]>
Cc: Casey Connolly <[email protected]>
Cc: Bastien Curutchet <[email protected]>
Cc: Johan Jonker <[email protected]>

---
Alexey Charkov (10):
      ufs: hand sense data to the SCSI layer
      scsi: repeat an INQUIRY that a unit attention interrupted
      scsi: size a well known unit from the unit it stands in for
      scsi: allow a controller to declare well known logical units
      scsi: add a lookup by target and LUN
      part: name the well known logical unit device type
      ufs: define the well known logical unit ids
      ufs: report the logical unit the boot W-LU presents
      ufs: expose the boot logical unit as a block device
      spl: ufs: allow loading U-Boot from the boot logical unit

 common/spl/Kconfig         |  30 +++++++++++++-
 common/spl/spl_ufs.c       |  18 ++++++--
 disk/part.c                |   3 ++
 drivers/scsi/scsi-uclass.c |  32 ++++++++++++++
 drivers/scsi/scsi.c        | 101 +++++++++++++++++++++++++++++++++++++++------
 drivers/ufs/ufs-uclass.c   |  76 +++++++++++++++++++++++++++++++++-
 drivers/ufs/ufs.h          |  28 +++++++++++++
 include/part.h             |   1 +
 include/scsi.h             |  45 ++++++++++++++++++++
 include/ufs.h              |   8 ++++
 10 files changed, 324 insertions(+), 18 deletions(-)
---
base-commit: 37bbe6e3ed205037fbca390f239eff9899639e39
change-id: 20260903-ufs-spl-boot-wlu-10ce2e14bf15

Best regards,
--  
Alexey Charkov <[email protected]>

Reply via email to