ata: libata-core: Improve ata_dev_power_set_active()
authorDamien Le Moal <dlemoal@kernel.org>
Thu, 12 Oct 2023 06:56:34 +0000 (15:56 +0900)
committerDamien Le Moal <dlemoal@kernel.org>
Sun, 15 Oct 2023 22:03:02 +0000 (07:03 +0900)
commit2da4c5e24e86313fc09596ae775123b41055fd54
treeed99d8f706f9b96332ad81d2302ff2a748763685
parent54d7211da7cd8fbd286532b25f4f0b688fcf94a3
ata: libata-core: Improve ata_dev_power_set_active()

Improve the function ata_dev_power_set_active() by having it do nothing
for a disk that is already in the active power state. To do that,
introduce the function ata_dev_power_is_active() to test the current
power state of the disk and return true if the disk is in the PM0:
active or PM1: idle state (0xff value for the count field of the CHECK
POWER MODE command output).

To preserve the existing behavior, if the CHECK POWER MODE command
issued in ata_dev_power_is_active() fails, the drive is assumed to be in
standby mode and false is returned.

With this change, issuing the VERIFY command to access the disk media to
spin it up becomes unnecessary most of the time during system resume as
the port reset done by libata-eh on resume often result in the drive to
spin-up (this behavior is not clearly defined by the ACS specifications
and may thus vary between disk models).

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
drivers/ata/libata-core.c