rockbox/firmware/usbstack
Marcin Bukat 9bcdd30293 usb_storage: flush storage when the host stops or ejects the unit
A host that is done with a mass-storage device - "safely remove", eject,
udisksctl power-off - sends START STOP UNIT with the start bit clear, and
may cut power right after. usb_storage only marked the LUN ejected.

Storage drivers can still hold data in RAM at that point: a flash
translation layer keeps part-written pages until a later write completes
them, and HAVE_STORAGE_FLUSH exists so they can be committed - but only
shutdown and ROLO called it. On a device unplugged after a proper eject
and then losing power, that data was lost although the host had done
everything right.

Call storage_flush() on stop and on eject, on targets that define
HAVE_STORAGE_FLUSH. The SCSI handler runs in the USB thread, as do the
reads and writes, so the flush cannot race them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Change-Id: I5b5811858c75dfb3ee89535ab59f4a19663945df
2026-09-28 08:39:24 +02:00
..
iap usb iap: correct sample rate descriptors and packet cadence 2026-09-25 13:49:30 -04:00
usb_audio.c chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_audio.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_audio_def.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_charging_only.c chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_charging_only.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_class_driver.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_core.c FS#14011: Handle usb hosts whose first request is SET_ADDRESS (Anthony Fletcher) 2026-09-27 19:36:21 -04:00
usb_hid.c chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_hid.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_hid_def.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_hid_usage_tables.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_iap.c usb iap: correct sample rate descriptors and packet cadence 2026-09-25 13:49:30 -04:00
usb_iap.h usb: hold class_driver instance in each driver 2026-05-03 15:18:51 -04:00
usb_serial.c usb: acknowledge SET_LINE_CODING in the serial driver 2026-08-10 15:30:53 -04:00
usb_serial.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00
usb_storage.c usb_storage: flush storage when the host stops or ejects the unit 2026-09-28 08:39:24 +02:00
usb_storage.h chore: Get rid of *all* vestigal CVS '$Id:$' tags 2026-06-01 16:01:18 -04:00