* [PATCH 0/5] misc LPM related fixes
@ 2026-01-09 14:39 Niklas Cassel
2026-01-09 14:39 ` [PATCH 1/5] ata: libata: Call ata_dev_config_lpm() for ATAPI devices Niklas Cassel
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Niklas Cassel @ 2026-01-09 14:39 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, wolf, Niklas Cassel
Hello there,
we had a recent bug report on the mailing list related to LPM,
which made me review the LPM related code.
While doing so, I found some issues. This series fixes those issues.
The most serious issue is that ATA_QUIRK_NOLPM was not getting
applied for ATAPI devices.
Kind regards,
Niklas
Niklas Cassel (5):
ata: libata: Call ata_dev_config_lpm() for ATAPI devices
ata: libata: Fix ata_dev_print_features() early return
ata: libata: Print features also for ATAPI devices
ata: libata-sata: Improve link_power_management_supported sysfs
attribute
ata: ahci: Do not read per port area for unimplemented ports
drivers/ata/ahci.c | 10 +++++-----
drivers/ata/libata-core.c | 8 +++++++-
drivers/ata/libata-sata.c | 2 +-
3 files changed, 13 insertions(+), 7 deletions(-)
base-commit: 97e01439e902b743b8f89497e9c144e3ddda5e59
--
2.52.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] ata: libata: Call ata_dev_config_lpm() for ATAPI devices
2026-01-09 14:39 [PATCH 0/5] misc LPM related fixes Niklas Cassel
@ 2026-01-09 14:39 ` Niklas Cassel
2026-01-09 14:39 ` [PATCH 2/5] ata: libata: Fix ata_dev_print_features() early return Niklas Cassel
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Niklas Cassel @ 2026-01-09 14:39 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, wolf, Niklas Cassel
Commit d360121832d8 ("ata: libata-core: Introduce ata_dev_config_lpm()")
introduced ata_dev_config_lpm(). However, it only called this function for
ATA_DEV_ATA and ATA_DEV_ZAC devices, not for ATA_DEV_ATAPI devices.
Additionally, commit d99a9142e782 ("ata: libata-core: Move device LPM quirk
settings to ata_dev_config_lpm()") moved the LPM quirk application from
ata_dev_configure() to ata_dev_config_lpm(), causing LPM quirks for ATAPI
devices to no longer be applied.
Call ata_dev_config_lpm() also for ATAPI devices, such that LPM quirks are
applied for ATAPI devices with an entry in __ata_dev_quirks once again.
Fixes: d360121832d8 ("ata: libata-core: Introduce ata_dev_config_lpm()")
Fixes: d99a9142e782 ("ata: libata-core: Move device LPM quirk settings to ata_dev_config_lpm()")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/libata-core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index b96105481784..1e8e35c10b35 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3148,6 +3148,8 @@ int ata_dev_configure(struct ata_device *dev)
ata_mode_string(xfer_mask),
cdb_intr_string, atapi_an_string,
dma_dir_string);
+
+ ata_dev_config_lpm(dev);
}
/* determine max_sectors */
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] ata: libata: Fix ata_dev_print_features() early return
2026-01-09 14:39 [PATCH 0/5] misc LPM related fixes Niklas Cassel
2026-01-09 14:39 ` [PATCH 1/5] ata: libata: Call ata_dev_config_lpm() for ATAPI devices Niklas Cassel
@ 2026-01-09 14:39 ` Niklas Cassel
2026-01-09 14:39 ` [PATCH 3/5] ata: libata: Print features also for ATAPI devices Niklas Cassel
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Niklas Cassel @ 2026-01-09 14:39 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, wolf, Niklas Cassel
ata_dev_print_features() is supposed to return early and not print anything
if there are no features supported.
However, commit fe22e1c2f705 ("libata: support concurrent positioning
ranges log") added another feature to ata_dev_print_features() without
updating the early return conditional.
Likewise, commit b1f5af54f1f5 ("ata: libata-core: Advertize device support
for DIPM and HIPM features") added additional features to
ata_dev_print_features() without updating the early return conditional.
Add the missing features to the early return conditional.
Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log")
Fixes: b1f5af54f1f5 ("ata: libata-core: Advertize device support for DIPM and HIPM features")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/libata-core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 1e8e35c10b35..7656aea7663f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2904,7 +2904,8 @@ static void ata_dev_config_lpm(struct ata_device *dev)
static void ata_dev_print_features(struct ata_device *dev)
{
- if (!(dev->flags & ATA_DFLAG_FEATURES_MASK))
+ if (!(dev->flags & ATA_DFLAG_FEATURES_MASK) && !dev->cpr_log &&
+ !ata_id_has_hipm(dev->id) && !ata_id_has_dipm(dev->id))
return;
ata_dev_info(dev,
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] ata: libata: Print features also for ATAPI devices
2026-01-09 14:39 [PATCH 0/5] misc LPM related fixes Niklas Cassel
2026-01-09 14:39 ` [PATCH 1/5] ata: libata: Call ata_dev_config_lpm() for ATAPI devices Niklas Cassel
2026-01-09 14:39 ` [PATCH 2/5] ata: libata: Fix ata_dev_print_features() early return Niklas Cassel
@ 2026-01-09 14:39 ` Niklas Cassel
2026-01-09 14:39 ` [PATCH 4/5] ata: libata-sata: Improve link_power_management_supported sysfs attribute Niklas Cassel
2026-01-09 14:39 ` [PATCH 5/5] ata: ahci: Do not read per port area for unimplemented ports Niklas Cassel
4 siblings, 0 replies; 6+ messages in thread
From: Niklas Cassel @ 2026-01-09 14:39 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, wolf, Niklas Cassel
Commit d633b8a702ab ("libata: print feature list on device scan")
added a print of the features supported by the device for ATA_DEV_ATA and
ATA_DEV_ZAC devices, but not for ATA_DEV_ATAPI devices.
Fix this by printing the features also for ATAPI devices.
Before changes:
ata1.00: ATAPI: Slimtype DVD A DU8AESH, 6C2M, max UDMA/133
After changes:
ata1.00: ATAPI: Slimtype DVD A DU8AESH, 6C2M, max UDMA/133
ata1.00: Features: Dev-Attention HIPM DIPM
Fixes: d633b8a702ab ("libata: print feature list on device scan")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/libata-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 7656aea7663f..43072b1d9221 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -3151,6 +3151,9 @@ int ata_dev_configure(struct ata_device *dev)
dma_dir_string);
ata_dev_config_lpm(dev);
+
+ if (print_info)
+ ata_dev_print_features(dev);
}
/* determine max_sectors */
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] ata: libata-sata: Improve link_power_management_supported sysfs attribute
2026-01-09 14:39 [PATCH 0/5] misc LPM related fixes Niklas Cassel
` (2 preceding siblings ...)
2026-01-09 14:39 ` [PATCH 3/5] ata: libata: Print features also for ATAPI devices Niklas Cassel
@ 2026-01-09 14:39 ` Niklas Cassel
2026-01-09 14:39 ` [PATCH 5/5] ata: ahci: Do not read per port area for unimplemented ports Niklas Cassel
4 siblings, 0 replies; 6+ messages in thread
From: Niklas Cassel @ 2026-01-09 14:39 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, wolf, Niklas Cassel
The link_power_management_supported sysfs attribute is currently set as
true even for ata ports that lack a .set_lpm() callback, e.g. dummy ports.
This is a bit silly, because while writing to the
link_power_management_policy sysfs attribute will make ata_scsi_lpm_store()
update ap->target_lpm_policy (thus sysfs will reflect the new value) and
call ata_port_schedule_eh() for the port, it is essentially a no-op.
This is because for a port without a .set_lpm() callback, once EH gets to
run, the ata_eh_link_set_lpm() will simply return, since the port does not
provide a .set_lpm() callback.
Thus, make sure that the link_power_management_supported sysfs attribute
is set to false for ports that lack a .set_lpm() callback. This way the
link_power_management_policy sysfs attribute will no longer be writable,
so we will no longer be misleading users to think that their sysfs write
actually does something.
Fixes: 0060beec0bfa ("ata: libata-sata: Add link_power_management_supported sysfs attribute")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/libata-sata.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ata/libata-sata.c b/drivers/ata/libata-sata.c
index b2817a2995d6..04e1e774645e 100644
--- a/drivers/ata/libata-sata.c
+++ b/drivers/ata/libata-sata.c
@@ -909,7 +909,7 @@ static bool ata_scsi_lpm_supported(struct ata_port *ap)
struct ata_link *link;
struct ata_device *dev;
- if (ap->flags & ATA_FLAG_NO_LPM)
+ if ((ap->flags & ATA_FLAG_NO_LPM) || !ap->ops->set_lpm)
return false;
ata_for_each_link(link, ap, EDGE) {
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] ata: ahci: Do not read per port area for unimplemented ports
2026-01-09 14:39 [PATCH 0/5] misc LPM related fixes Niklas Cassel
` (3 preceding siblings ...)
2026-01-09 14:39 ` [PATCH 4/5] ata: libata-sata: Improve link_power_management_supported sysfs attribute Niklas Cassel
@ 2026-01-09 14:39 ` Niklas Cassel
4 siblings, 0 replies; 6+ messages in thread
From: Niklas Cassel @ 2026-01-09 14:39 UTC (permalink / raw)
To: dlemoal; +Cc: linux-ide, wolf, Niklas Cassel
An AHCI HBA specifies the number of ports is supports using CAP.NP.
The HBA is free to only make a subset of the number of ports available
using the PI (Ports Implemented) register.
libata currently creates dummy ports for HBA ports that are provided by
the HBA, but which are marked as "unavailable" using the PI register.
Each port will have per port area of registers in the HBA, regardless if
the port is marked as "unavailable" or not using the PI register.
ahci_mark_external_port() currently reads this per port area or registers
using readl() to see if the port is marked as external/hotplug-capable.
However, AHCI 1.3.1, section "3.1.4 Offset 0Ch: PI – Ports Implemented"
states: "Software must not read or write to registers within unavailable
ports."
Thus, make sure that we only call ahci_mark_external_port() and
ahci_update_initial_lpm_policy() for ports that are implemented.
For a libata perspective, this should not change anything related to LPM,
as dummy ports do not provide any ap->ops (they do not have a .set_lpm()
callback), so even if EH were to call .set_lpm() on a dummy port, it was
already a no-op.
Fixes: f7131935238d ("ata: ahci: move marking of external port earlier")
Signed-off-by: Niklas Cassel <cassel@kernel.org>
---
drivers/ata/ahci.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 7a7f88b3fa2b..931d0081169b 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -2094,13 +2094,13 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (ap->flags & ATA_FLAG_EM)
ap->em_message_type = hpriv->em_msg_type;
- ahci_mark_external_port(ap);
-
- ahci_update_initial_lpm_policy(ap);
-
/* disabled/not-implemented port */
- if (!(hpriv->port_map & (1 << i)))
+ if (!(hpriv->port_map & (1 << i))) {
ap->ops = &ata_dummy_port_ops;
+ } else {
+ ahci_mark_external_port(ap);
+ ahci_update_initial_lpm_policy(ap);
+ }
}
/* apply workaround for ASUS P5W DH Deluxe mainboard */
--
2.52.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-01-09 14:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-09 14:39 [PATCH 0/5] misc LPM related fixes Niklas Cassel
2026-01-09 14:39 ` [PATCH 1/5] ata: libata: Call ata_dev_config_lpm() for ATAPI devices Niklas Cassel
2026-01-09 14:39 ` [PATCH 2/5] ata: libata: Fix ata_dev_print_features() early return Niklas Cassel
2026-01-09 14:39 ` [PATCH 3/5] ata: libata: Print features also for ATAPI devices Niklas Cassel
2026-01-09 14:39 ` [PATCH 4/5] ata: libata-sata: Improve link_power_management_supported sysfs attribute Niklas Cassel
2026-01-09 14:39 ` [PATCH 5/5] ata: ahci: Do not read per port area for unimplemented ports Niklas Cassel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox