linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: linux-ide@vger.kernel.org, Niklas Cassel <cassel@kernel.org>
Subject: [PATCH 02/10] ata: libata-core: Move device LPM quirk settings to ata_dev_config_lpm()
Date: Mon, 30 Jun 2025 15:26:29 +0900	[thread overview]
Message-ID: <20250630062637.258329-3-dlemoal@kernel.org> (raw)
In-Reply-To: <20250630062637.258329-1-dlemoal@kernel.org>

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>
---
 drivers/ata/libata-core.c | 43 +++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 0d85474f6640..fdce96fd3ffa 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -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;
+	}
+
 	/*
 	 * If the device port does not support Device Initiated Power Management
 	 * (DIPM), and the device supports this feature, disable it.
@@ -2881,23 +2907,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)
-- 
2.50.0


  parent reply	other threads:[~2025-06-30  6:28 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30  6:26 [PATCH 00/10] Improve link power management Damien Le Moal
2025-06-30  6:26 ` [PATCH 01/10] ata: libata-core: Introduce ata_dev_config_lpm() Damien Le Moal
2025-06-30 14:46   ` Niklas Cassel
2025-07-01  6:09   ` Hannes Reinecke
2025-06-30  6:26 ` Damien Le Moal [this message]
2025-06-30 14:47   ` [PATCH 02/10] ata: libata-core: Move device LPM quirk settings to ata_dev_config_lpm() Niklas Cassel
2025-07-01  6:13   ` Hannes Reinecke
2025-07-01  6:43     ` Damien Le Moal
2025-07-01  7:19       ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 03/10] ata: libata-core: Advertize device support for DIPM and HIPM features Damien Le Moal
2025-06-30 14:47   ` Niklas Cassel
2025-07-01  6:14   ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 04/10] ata: libata-eh: Avoid unnecessary resets when revalidating devices Damien Le Moal
2025-06-30 14:47   ` Niklas Cassel
2025-07-01  6:23   ` Hannes Reinecke
2025-07-01  6:48     ` Damien Le Moal
2025-07-01  7:21       ` Hannes Reinecke
2025-07-01  9:24       ` Niklas Cassel
2025-07-01  9:25         ` Damien Le Moal
2025-06-30  6:26 ` [PATCH 05/10] ata: libata-sata: Disallow changing LPM state if not supported Damien Le Moal
2025-06-30 14:49   ` Niklas Cassel
2025-07-01  6:23   ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 06/10] ata: ahci: Disable DIPM if host lacks support Damien Le Moal
2025-06-30 14:50   ` Niklas Cassel
2025-07-01  6:23   ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 07/10] ata: ahci: Disallow LPM policy control for external ports Damien Le Moal
2025-06-30 14:50   ` Niklas Cassel
2025-07-01  6:24   ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 08/10] ata: ahci: Disallow LPM policy control if not supported Damien Le Moal
2025-06-30  8:30   ` Sergey Shtylyov
2025-06-30 15:07   ` Niklas Cassel
2025-07-01  6:25   ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 09/10] ata: libata-core: Reduce the number of messages signaling broken LPM Damien Le Moal
2025-06-30 15:08   ` Niklas Cassel
2025-07-01  6:26   ` Hannes Reinecke
2025-06-30  6:26 ` [PATCH 10/10] ata: libata_eh: Add debug messages to ata_eh_link_set_lpm() Damien Le Moal
2025-06-30 15:11   ` Niklas Cassel
2025-06-30 15:25     ` Sergey Shtylyov
2025-07-01  6:27   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250630062637.258329-3-dlemoal@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).