ata: Rework how flushing, sleeping, and power off interacts

* FLUSH_EXT is used if featureflag is set and we are using LBA48
   (unconditionally used for CE-ATA on ipod6g)
 * FLUSH is used if featureflag is set (ATA6+) or if device claims to be ATA5+

 * Rename ata_disk_can_power_off() to ata_disk_can_sleep() as that is
   what it actually tests for.  Only use it to gate issuing the
   STANDBY IMMEDIATE command.
 * Restore behavior of ata_disk_is_active() to return 1 if drive is
   "spinning" or powered up.
 * Allow poweroff if drive claims PM support OR we are able to issue
   FLUSH/FLUSH_EXT commands.

 * Added ata_flush() to explicitly trigger a flush operation, and hook it
   up to storage_flush() in the device shutdown path. (Flushes were
   only previously used in the storage device power management path)

 * After issuing all settings, re-issue IDENTIFY_DEVICE to make sure
   it reflects everything we've enabled.

 * Update manual section on Flash/SSD mods.

Change-Id: I6770a54ef3a87f4c47120bcb96c944a6652f1bf4
This commit is contained in:
Solomon Peachy 2024-10-23 14:16:15 -04:00
parent 825e406965
commit e829ea9a5e
7 changed files with 110 additions and 66 deletions

View file

@ -208,8 +208,8 @@ static inline int ata_disk_isssd(void)
);
}
/* Returns 1 if the drive can be powered off safely */
static inline int ata_disk_can_poweroff(void)
/* Returns 1 if the drive supports power management commands */
static inline int ata_disk_can_sleep(void)
{
unsigned short *identify_info = ata_get_identify();
/* Only devices that claim to support PM can be safely powered off.
@ -217,6 +217,8 @@ static inline int ata_disk_can_poweroff(void)
return (identify_info[82] & (1<<3) && identify_info[85] & (1<<3));
}
int ata_flush(void);
#ifdef HAVE_ATA_DMA
/* Returns current DMA mode */
int ata_get_dma_mode(void);

View file

@ -174,7 +174,7 @@ static inline void storage_sleep(void) {};
#define storage_disk_is_active() ata_disk_is_active()
#define storage_soft_reset() ata_soft_reset()
#ifdef HAVE_STORAGE_FLUSH
#define storage_flush() (void)0
#define storage_flush() ata_flush()
#endif
#define storage_last_disk_activity() ata_last_disk_activity()
#define storage_spinup_time() ata_spinup_time()