Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 31c6222

Browse files
floatiousgregkh
authored andcommitted
ata: libata: avoid superfluous disk spin down + spin up during hibernation
commit a38719e upstream. A user reported that commit aa3998d ("ata: libata-scsi: Disable scsi device manage_system_start_stop") introduced a spin down + immediate spin up of the disk both when entering and when resuming from hibernation. This behavior was not there before, and causes an increased latency both when entering and when resuming from hibernation. Hibernation is done by three consecutive PM events, in the following order: 1) PM_EVENT_FREEZE 2) PM_EVENT_THAW 3) PM_EVENT_HIBERNATE Commit aa3998d ("ata: libata-scsi: Disable scsi device manage_system_start_stop") modified ata_eh_handle_port_suspend() to call ata_dev_power_set_standby() (which spins down the disk), for both event PM_EVENT_FREEZE and event PM_EVENT_HIBERNATE. Documentation/driver-api/pm/devices.rst, section "Entering Hibernation", explicitly mentions that PM_EVENT_FREEZE does not have to be put the device in a low-power state, and actually recommends not doing so. Thus, let's not spin down the disk on PM_EVENT_FREEZE. (The disk will instead be spun down during the subsequent PM_EVENT_HIBERNATE event.) This way, PM_EVENT_FREEZE will behave as it did before commit aa3998d ("ata: libata-scsi: Disable scsi device manage_system_start_stop"), while PM_EVENT_HIBERNATE will continue to spin down the disk. This will avoid the superfluous spin down + spin up when entering and resuming from hibernation, while still making sure that the disk is spun down before actually entering hibernation. Cc: [email protected] # v6.6+ Fixes: aa3998d ("ata: libata-scsi: Disable scsi device manage_system_start_stop") Reviewed-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a448ced commit 31c6222

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

drivers/ata/libata-eh.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4049,10 +4049,20 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
40494049

40504050
WARN_ON(ap->pflags & ATA_PFLAG_SUSPENDED);
40514051

4052-
/* Set all devices attached to the port in standby mode */
4053-
ata_for_each_link(link, ap, HOST_FIRST) {
4054-
ata_for_each_dev(dev, link, ENABLED)
4055-
ata_dev_power_set_standby(dev);
4052+
/*
4053+
* We will reach this point for all of the PM events:
4054+
* PM_EVENT_SUSPEND (if runtime pm, PM_EVENT_AUTO will also be set)
4055+
* PM_EVENT_FREEZE, and PM_EVENT_HIBERNATE.
4056+
*
4057+
* We do not want to perform disk spin down for PM_EVENT_FREEZE.
4058+
* (Spin down will be performed by the subsequent PM_EVENT_HIBERNATE.)
4059+
*/
4060+
if (!(ap->pm_mesg.event & PM_EVENT_FREEZE)) {
4061+
/* Set all devices attached to the port in standby mode */
4062+
ata_for_each_link(link, ap, HOST_FIRST) {
4063+
ata_for_each_dev(dev, link, ENABLED)
4064+
ata_dev_power_set_standby(dev);
4065+
}
40564066
}
40574067

40584068
/*

0 commit comments

Comments
 (0)