[PATCH 4/5] ata: ahci: do not enable LPM on external ports

Niklas Cassel
2024-02-01T16:15:28Z

The SATA specification contains a known incompatibility between LPM and
hot-plug events, thus do not enable LPM if the port advertises itself as
being an external SATA port (i.e. either hot-plug capable or eSATA).

This matches the power policy used in Microsoft Windows, which disables
LPM for external SATA ports, such that hot-plug events can be received.

Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/ahci.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 19b605c98d42..d50d1ae44e7f 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1664,6 +1664,14 @@ static void ahci_update_initial_lpm_policy(struct ata_port *ap)
if (!(hpriv->flags & AHCI_HFLAG_USE_LPM_POLICY))
return;

+ /*
+ * The SATA specification contains a known incompatibility between LPM
+ * and hot-plug events, thus do not enable LPM if the port advertises
+ * itself as an external port (i.e. either hot-plug capable or eSATA).
+ */
+ if (ap->pflags & ATA_PFLAG_EXTERNAL)
+ return;
+
/* user modified policy via module param */
if (mobile_lpm_policy != -1) {
policy = mobile_lpm_policy;
--
2.43.0