From: Damien Le Moal <dlemoal@kernel.org>
To: linux-ide@vger.kernel.org, Niklas Cassel <cassel@kernel.org>
Subject: [PATCH v2 01/10] ata: libata-core: Introduce ata_dev_config_lpm()
Date: Tue, 1 Jul 2025 09:13:59 +0900 [thread overview]
Message-ID: <20250701001408.330364-2-dlemoal@kernel.org> (raw)
In-Reply-To: <20250701001408.330364-1-dlemoal@kernel.org>
If the port of a device does not support Device Initiated Power
Management (DIPM), that is, the port is flagged with ATA_FLAG_NO_DIPM,
the DIPM feature of a device should be used. Though DIPM is disabled on
a drive by default thanks to the "Software Settings Preservation
feature", DIPM may have been enabled by the system firmware when using
the LPM policy "Keep FW settings" (ATA_LPM_UNKNOWN).
Introduce the function ata_dev_config_lpm() to always disable DIPM on a
device that supports this feature if the port of the device is flagged
with ATA_FLAG_NO_DIPM. ata_dev_config_lpm() is called from
ata_dev_configure(), ensuring that a device DIPM feature is disabled
when it cannot be used.
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
---
drivers/ata/libata-core.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3918ea624e0b..0d85474f6640 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2790,6 +2790,27 @@ static void ata_dev_config_cpr(struct ata_device *dev)
kfree(buf);
}
+/*
+ * Configure features related to link power management.
+ */
+static void ata_dev_config_lpm(struct ata_device *dev)
+{
+ struct ata_port *ap = dev->link->ap;
+ unsigned int err_mask;
+
+ /*
+ * If the device port does not support Device Initiated Power Management
+ * (DIPM), and the device supports this feature, disable it.
+ */
+ if (ap->flags & ATA_FLAG_NO_DIPM && ata_id_has_dipm(dev->id)) {
+ err_mask = ata_dev_set_feature(dev,
+ SETFEATURES_SATA_DISABLE, SATA_DIPM);
+ if (err_mask && err_mask != AC_ERR_DEV)
+ ata_dev_err(dev, "Disable DIPM failed, Emask 0x%x\n",
+ err_mask);
+ }
+}
+
static void ata_dev_print_features(struct ata_device *dev)
{
if (!(dev->flags & ATA_DFLAG_FEATURES_MASK))
@@ -2963,6 +2984,7 @@ int ata_dev_configure(struct ata_device *dev)
ata_dev_config_chs(dev);
}
+ ata_dev_config_lpm(dev);
ata_dev_config_fua(dev);
ata_dev_config_devslp(dev);
ata_dev_config_sense_reporting(dev);
--
2.50.0
next prev parent reply other threads:[~2025-07-01 0:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-01 0:13 [PATCH v2 00/10] Improve link power management Damien Le Moal
2025-07-01 0:13 ` Damien Le Moal [this message]
2025-07-01 10:41 ` [PATCH v2 01/10] ata: libata-core: Introduce ata_dev_config_lpm() Niklas Cassel
2025-07-01 0:14 ` [PATCH v2 02/10] ata: libata-core: Move device LPM quirk settings to ata_dev_config_lpm() Damien Le Moal
2025-07-01 0:14 ` [PATCH v2 03/10] ata: libata-core: Advertize device support for DIPM and HIPM features Damien Le Moal
2025-07-01 0:14 ` [PATCH v2 04/10] ata: libata-eh: Avoid unnecessary resets when revalidating devices Damien Le Moal
2025-07-01 0:14 ` [PATCH v2 05/10] ata: libata-sata: Disallow changing LPM state if not supported Damien Le Moal
2025-07-01 0:14 ` [PATCH v2 06/10] ata: ahci: Disable DIPM if host lacks support Damien Le Moal
2025-07-01 0:14 ` [PATCH v2 07/10] ata: ahci: Disallow LPM policy control for external ports Damien Le Moal
2025-07-01 9:43 ` Niklas Cassel
2025-07-01 0:14 ` [PATCH v2 08/10] ata: ahci: Disallow LPM policy control if not supported Damien Le Moal
2025-07-01 9:44 ` Niklas Cassel
2025-07-01 0:14 ` [PATCH v2 09/10] ata: libata-core: Reduce the number of messages signaling broken LPM Damien Le Moal
2025-07-01 0:14 ` [PATCH v2 10/10] ata: libata_eh: Add debug messages to ata_eh_link_set_lpm() Damien Le Moal
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=20250701001408.330364-2-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).