1
0
Fork 0

scsi: Do not set ALPM on external SATA ports

Tuning ALPM for external SATA ports is incompatible
with reliable detection of hot plug removals (see
SATA AHCI 1.3.1, section 7.3.1). This commit skips
the ALPM setting for such ports, i.e., for all ports
that have either the ESP bit (External SATA Port)
or the HPCP bit (Hot Plug Capable Port) set to 1
in the PxCMD register (exposed in `ahci_port_cmd`).

Resolves: RHEL-79913
This commit is contained in:
Pavol Žáčik 2025-05-02 13:45:57 +02:00
parent 9392599b76
commit 0685e9e523
No known key found for this signature in database
GPG key ID: B3029C97EB97E3E4

View file

@ -83,10 +83,27 @@ class SCSIHostPlugin(hotplug.Plugin):
def _get_alpm_policy_file(self, device):
return os.path.join("/sys/class/scsi_host/", str(device), "link_power_management_policy")
def _get_ahci_port_cmd_file(self, device):
return os.path.join("/sys/class/scsi_host/", str(device), "ahci_port_cmd")
def _is_external_sata_port(self, device):
port_cmd_file = self._get_ahci_port_cmd_file(device)
if not os.path.isfile(port_cmd_file):
return False
port_cmd = int(self._cmd.read_file(port_cmd_file), 16)
# Bit 18 is HPCP (Hot Plug Capable Port)
# Bit 21 is ESP (External SATA Port)
return port_cmd & (1 << 18 | 1 << 21) != 0
@command_set("alpm", per_device = True)
def _set_alpm(self, policy, device, instance, sim, remove):
if policy is None:
return None
if self._is_external_sata_port(device):
# According to the SATA AHCI specification, external (or hot-plug capable)
# SATA ports must have power management disabled to reliably detect hot plug removal.
log.info("Device '%s' is an external SATA controller, skipping ALPM setting to support hot plug" % str(device))
return None
policy_file = self._get_alpm_policy_file(device)
if not sim:
if os.path.exists(policy_file):