From: Damien Le Moal Date: Tue, 1 Jul 2025 12:53:18 +0000 (+0900) Subject: ata: ahci: Disallow LPM policy control for external ports X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4edf1505b76d30e1e1e283d431e4f84ad01ddcef;p=users%2Fjedix%2Flinux-maple.git ata: ahci: Disallow LPM policy control for external ports Commit ae1f3db006b7 ("ata: ahci: do not enable LPM on external ports") added an early return in ahci_update_initial_lpm_policy() for all ports flagged as external with the ATA_PFLAG_EXTERNAL port flag (e.g. eSATA ports or hotplug capable ports) so that the target_lpm_policy of these ports is unchanged and set to ATA_LPM_UNKNOWN. thus forcing libata EH to not be called for external port. The goal of this change is to preserve the initial power management policy to not break the hotplug capability of external ports. However, this change is incomplete as users or system daemon (e.g. systemd-udevd) can still apply the system preferred power management policy through sysfs, thus potentially unknowingly breaking the port hotplug capability. Modify ahci_update_initial_lpm_policy() to flag external ports with ATA_FLAG_NO_LPM to prevent changes to the LPM policy by users through the sysfs link_power_management_policy host attribute. Also set the target_lpm_policy of external ports to ATA_LPM_MAX_POWER to ensure that the port is not in a low power state preventing hotplug operations. Since commit 439d47608bb3 ("ata: libata: Print if port is external on boot") introduced an unconditional print on port probe signaling that a port is external, the debug message signaling that fact and that LPM will not be enabled is removed. Signed-off-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Niklas Cassel Link: https://lore.kernel.org/r/20250701125321.69496-8-dlemoal@kernel.org Signed-off-by: Niklas Cassel --- diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 0760fa47d90ec..a061aa3299ef0 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -1776,7 +1776,8 @@ static void ahci_update_initial_lpm_policy(struct ata_port *ap) * LPM if the port advertises itself as an external port. */ if (ap->pflags & ATA_PFLAG_EXTERNAL) { - ata_port_dbg(ap, "external port, not enabling LPM\n"); + ap->flags |= ATA_FLAG_NO_LPM; + ap->target_lpm_policy = ATA_LPM_MAX_POWER; return; }