Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ata: libahci: Adjust behavior when StorageD3Enable _DSD is set

The StorageD3Enable _DSD is used for the vendor to indicate that the disk
should be opted into or out of a different behavior based upon the platform
design.

For AMD's Renoir and Green Sardine platforms it's important that any
attached SATA storage has transitioned into DevSlp when s2idle is used.

If the disk is left in active/partial/slumber, then the system is not able
to resume properly.

When the StorageD3Enable _DSD is detected, check the system is using s2idle
and DevSlp is enabled and if so explicitly wait long enough for the disk to
enter DevSlp.

Cc: Nehal-bakulchandra Shah <Nehal-bakulchandra.Shah@amd.com>
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=214091
Link: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/power-management-for-storage-hardware-devices-intro
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

authored by

Mario Limonciello and committed by
Damien Le Moal
7c5f641a 1527f692

+15
+15
drivers/ata/libahci.c
··· 2323 2323 EXPORT_SYMBOL_GPL(ahci_port_resume); 2324 2324 2325 2325 #ifdef CONFIG_PM 2326 + static void ahci_handle_s2idle(struct ata_port *ap) 2327 + { 2328 + void __iomem *port_mmio = ahci_port_base(ap); 2329 + u32 devslp; 2330 + 2331 + if (pm_suspend_via_firmware()) 2332 + return; 2333 + devslp = readl(port_mmio + PORT_DEVSLP); 2334 + if ((devslp & PORT_DEVSLP_ADSE)) 2335 + ata_msleep(ap, devslp_idle_timeout); 2336 + } 2337 + 2326 2338 static int ahci_port_suspend(struct ata_port *ap, pm_message_t mesg) 2327 2339 { 2328 2340 const char *emsg = NULL; ··· 2347 2335 ata_port_err(ap, "%s (%d)\n", emsg, rc); 2348 2336 ata_port_freeze(ap); 2349 2337 } 2338 + 2339 + if (acpi_storage_d3(ap->host->dev)) 2340 + ahci_handle_s2idle(ap); 2350 2341 2351 2342 ahci_rpm_put_port(ap); 2352 2343 return rc;