ata: libata-core: Move device LPM quirk settings to ata_dev_config_lpm()

Move the various cases of setting the ATA_QUIRK_NOLPM quirk flag for a
device in ata_dev_configure() to the function ata_dev_config_lpm().
This allows having all LPM related settings in one place to facilitate
maintenance.

No functional changes.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20250701125321.69496-3-dlemoal@kernel.org
Signed-off-by: Niklas Cassel <cassel@kernel.org>
This commit is contained in:
Damien Le Moal 2025-07-01 21:53:13 +09:00 committed by Niklas Cassel
parent d360121832
commit d99a9142e7

View file

@ -2798,6 +2798,32 @@ static void ata_dev_config_lpm(struct ata_device *dev)
struct ata_port *ap = dev->link->ap;
unsigned int err_mask;
if (ap->flags & ATA_FLAG_NO_LPM) {
/*
* When the port does not support LPM, we cannot support it on
* the device either.
*/
dev->quirks |= ATA_QUIRK_NOLPM;
} else {
/*
* Some WD SATA-1 drives have issues with LPM, turn on NOLPM for
* them.
*/
if ((dev->quirks & ATA_QUIRK_WD_BROKEN_LPM) &&
(dev->id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2)
dev->quirks |= ATA_QUIRK_NOLPM;
/* ATI specific quirk */
if ((dev->quirks & ATA_QUIRK_NO_LPM_ON_ATI) &&
ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI))
dev->quirks |= ATA_QUIRK_NOLPM;
}
if (dev->quirks & ATA_QUIRK_NOLPM) {
ata_dev_warn(dev, "LPM support broken, forcing max_power\n");
ap->target_lpm_policy = ATA_LPM_MAX_POWER;
}
/*
* Device Initiated Power Management (DIPM) is normally disabled by
* default on a device. However, DIPM may have been enabled and that
@ -2884,23 +2910,6 @@ int ata_dev_configure(struct ata_device *dev)
if (rc)
return rc;
/* some WD SATA-1 drives have issues with LPM, turn on NOLPM for them */
if ((dev->quirks & ATA_QUIRK_WD_BROKEN_LPM) &&
(id[ATA_ID_SATA_CAPABILITY] & 0xe) == 0x2)
dev->quirks |= ATA_QUIRK_NOLPM;
if (dev->quirks & ATA_QUIRK_NO_LPM_ON_ATI &&
ata_dev_check_adapter(dev, PCI_VENDOR_ID_ATI))
dev->quirks |= ATA_QUIRK_NOLPM;
if (ap->flags & ATA_FLAG_NO_LPM)
dev->quirks |= ATA_QUIRK_NOLPM;
if (dev->quirks & ATA_QUIRK_NOLPM) {
ata_dev_warn(dev, "LPM support broken, forcing max_power\n");
dev->link->ap->target_lpm_policy = ATA_LPM_MAX_POWER;
}
/* let ACPI work its magic */
rc = ata_acpi_on_devcfg(dev);
if (rc)