Skip to content

scsi: ensure writes are flushed to disk

Caleb Connolly u-boot 2 versions – In review

Get series with b4
b4 am [email protected] change-id 20250325-scsi-sync-on-write-08b6ca3264bf

Versions newest first

  1. v2 Latest3 patches 4 repliesIn review
  2. v13 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- Only issue the SYNC_CACHE command once for the whole write (thanks
Neil)
- De-duplicate AHCI which also implemented the same logic.
- Link to v1: https://lore.kernel.org/r/[email protected]

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3scsi: fix typo in setup_read_ext()drivers/scsi/scsi.c+1 -11 reply
2/3scsi: sync cache on writedrivers/scsi/scsi.c+23 -01 reply
3/3ata: ahci: implement SCSI_SYNC_CACHEdrivers/ata/ahci.c+3 -111 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchNeil Armstrong
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] scsi: ensure writes are flushed to disk

SCSI devices like UFS may maintain their own cache to speed up writes, however this is lost on board reset (and may be lost on device removal or reset by OS drivers).

Currently this can be worked around by "waiting for a while" after writing data to disk, but of course this is not an acceptable solution.

Ideally U-Boot would have a mechanism to flush caches during board reset, but until that logic is hooked up let's be sure that all writes are actually propagated to the storage device so that we don't lose data on board reset.

The same logic was already implemented just for the AHCI backend, this duplicated logic has been removed and support for the SYNC_CACHE command is added to AHCI.

This is particularly noticeable during capsule updates, since the update file is deleted and the board is reset immediately afterwards which resulted in the same capsule update being applied over and over again.

This specifically fixes Qualcomm SDM845 devices with UFS 2.1, but likely all UFS devices that use a cache.

---
Changes in v2:
- Only issue the SYNC_CACHE command once for the whole write (thanks
Neil)
- De-duplicate AHCI which also implemented the same logic.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Caleb Connolly (3):
scsi: fix typo in setup_read_ext()
scsi: sync cache on write
ata: ahci: implement SCSI_SYNC_CACHE

 drivers/ata/ahci.c  | 14 +++-----------
 drivers/scsi/scsi.c | 25 ++++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 12 deletions(-)

---
base-commit: a383b9bd4d7e430fe7c254297540bae596649dba

Caleb Connolly <[email protected]>