Skip to contentSkip to conversation

Cleanup ahci_broken_lpm()

PATCH Applied Niklas Cassel 3 participants 10 messages Jun 10, 2025 – Jun 12, 2025 libata

lore
Share & tools
lore

Niklas Cassel

author maintainer
#0 lore raw

v2 cover Cleanup ahci_broken_lpm()

Hello all,

This series cleans up ahci_broken_lpm(), and adds ASUSPRO-D840SA to the table of boards with broken LPM.

Kind regards,
Niklas

Changes since v1:
-Addressed review comments from Hans.

Niklas Cassel (3):
ata: ahci: Use correct BIOS build date for ThinkPad W541 quirk
ata: ahci: Refactor ahci_broken_lpm()
ata: ahci: Disallow LPM for ASUSPRO-D840SA motherboard

 drivers/ata/ahci.c | 41 +++++++++++++++++++++++++++++++----------
 1 file changed, 31 insertions(+), 10 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 1/3 ata: ahci: Use correct BIOS build date for ThinkPad W541 quirk

Fix the TODO in ahci_broken_lpm() by using the proper BIOS build date.

The proper BIOS build date was provided by Hans, see Link.

---
 drivers/ata/ahci.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/ata/ahci.c +1 -7
index 163ac909bd06..e7c8357cbc54 100644
@@ -1438,13 +1438,7 @@ static bool ahci_broken_lpm(struct pci_dev *pdev)
 				DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 				DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W541"),
 			},
-			/*
-			 * Note date based on release notes, 2.35 has been
-			 * reported to be good, but I've been unable to get
-			 * a hold of the reporter to get the DMI BIOS date.
-			 * TODO: fix this.
-			 */
-			.driver_data = "20180310", /* 2.35 */
+			.driver_data = "20180409", /* 2.35 */
 		},
 		{ }	/* terminate list */
 	};
Signature · 1 line
2.49.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] ata: ahci: Use correct BIOS build date for ThinkPad W541 quirk

Hi,

Quoted 6 lines · Niklas Cassel

Fix the TODO in ahci_broken_lpm() by using the proper BIOS build date.

The proper BIOS build date was provided by Hans, see Link.

Thanks, patch looks good to me:

Regards,

Hans

Quoted 23 lines
---
 drivers/ata/ahci.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/ata/ahci.c +1 -7
index 163ac909bd06..e7c8357cbc54 100644
@@ -1438,13 +1438,7 @@ static bool ahci_broken_lpm(struct pci_dev *pdev)
 				DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 				DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W541"),
 			},
-			/*
-			 * Note date based on release notes, 2.35 has been
-			 * reported to be good, but I've been unable to get
-			 * a hold of the reporter to get the DMI BIOS date.
-			 * TODO: fix this.
-			 */
-			.driver_data = "20180310", /* 2.35 */
+			.driver_data = "20180409", /* 2.35 */
 		},
 		{ }	/* terminate list */
 	};
maintainer Reviewed-by on v2 1/3
#3 lore raw

Re: [PATCH v2 1/3] ata: ahci: Use correct BIOS build date for ThinkPad W541 quirk

In reply to Niklas Cassel
Quoted 6 lines · Niklas Cassel

Fix the TODO in ahci_broken_lpm() by using the proper BIOS build date.

The proper BIOS build date was provided by Hans, see Link.

Signature · 2 lines
Damien Le Moal
Western Digital Research
author maintainer
#4 lore raw

PATCH v2 2/3 ata: ahci: Refactor ahci_broken_lpm()

In reply to Niklas Cassel

Currently, the match table in ahci_broken_lpm() contains DMI BIOS dates of BIOSes that are known to be working.

Having a list of known to be working versions is usually the wrong way to do things (as this list could theoretically be infinite).

Refactor this match table to contain DMI BIOS dates of BIOSes that are known to not be working, such that this list can be extended with BIOS versions (for other boards) that are known to not be working, where there is no good BIOS version (because all existing versions are broken).

---
 drivers/ata/ahci.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/ata/ahci.c +22 -6
index e7c8357cbc54..05ff03b80b85 100644
@@ -1411,34 +1411,50 @@ static bool ahci_broken_suspend(struct pci_dev *pdev)
 static bool ahci_broken_lpm(struct pci_dev *pdev)
 {
 	static const struct dmi_system_id sysids[] = {
-		/* Various Lenovo 50 series have LPM issues with older BIOSen */
+		/* Table contains DMI BIOS dates of BIOSes with broken LPM. */
 		{
 			.matches = {
 				DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 				DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X250"),
 			},
-			.driver_data = "20180406", /* 1.31 */
+			/*
+			 * 1.31, build date 20180406, has working LPM, mark any
+			 * DMI BIOS date before that as broken.
+			 */
+			.driver_data = "20180405",
 		},
 		{
 			.matches = {
 				DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 				DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L450"),
 			},
-			.driver_data = "20180420", /* 1.28 */
+			/*
+			 * 1.28, build date 20180420, has working LPM, mark any
+			 * DMI BIOS date before that as broken.
+			 */
+			.driver_data = "20180419",
 		},
 		{
 			.matches = {
 				DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 				DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T450s"),
 			},
-			.driver_data = "20180315", /* 1.33 */
+			/*
+			 * 1.33, build date 20180315, has working LPM, mark any
+			 * DMI BIOS date before that as broken.
+			 */
+			.driver_data = "20180314",
 		},
 		{
 			.matches = {
 				DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
 				DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad W541"),
 			},
-			.driver_data = "20180409", /* 2.35 */
+			/*
+			 * 2.35, build date 20180409, has working LPM, mark any
+			 * DMI BIOS date before that as broken.
+			 */
+			.driver_data = "20180408",
 		},
 		{ }	/* terminate list */
 	};
@@ -1452,7 +1468,7 @@ static bool ahci_broken_lpm(struct pci_dev *pdev)
 	dmi_get_date(DMI_BIOS_DATE, &year, &month, &date);
 	snprintf(buf, sizeof(buf), "%04d%02d%02d", year, month, date);
 
-	return strcmp(buf, dmi->driver_data) < 0;
+	return strcmp(buf, dmi->driver_data) <= 0;
 }
 
 static bool ahci_broken_online(struct pci_dev *pdev)
Signature · 1 line
2.49.0
maintainer Reviewed-by on v2 2/3
#5 lore raw

Re: [PATCH v2 2/3] ata: ahci: Refactor ahci_broken_lpm()

Quoted 6 lines · Niklas Cassel

Currently, the match table in ahci_broken_lpm() contains DMI BIOS dates of BIOSes that are known to be working.

Having a list of known to be working versions is usually the wrong way to do things (as this list could theoretically be infinite).

Quoted 7 lines

Refactor this match table to contain DMI BIOS dates of BIOSes that are known to not be working, such that this list can be extended with BIOS versions (for other boards) that are known to not be working, where there is no good BIOS version (because all existing versions are broken).

Signature · 2 lines
Damien Le Moal
Western Digital Research
author maintainer
#6 lore raw

PATCH v2 3/3 ata: ahci: Disallow LPM for ASUSPRO-D840SA motherboard

In reply to Niklas Cassel

A user has bisected a regression which causes graphical corruptions on his screen to commit 7627a0edef54 ("ata: ahci: Drop low power policy board type").

Simply reverting commit 7627a0edef54 ("ata: ahci: Drop low power policy board type") makes the graphical corruptions on his screen to go away. (Note: there are no visible messages in dmesg that indicates a problem with AHCI.)

The user also reports that the problem occurs regardless if there is an HDD or an SSD connected via AHCI, so the problem is not device related.

The devices also work fine on other motherboards, so it seems specific to the ASUSPRO-D840SA motherboard.

While enabling low power modes for AHCI is not supposed to affect completely unrelated hardware, like a graphics card, it does however allow the system to enter deeper PC-states, which could expose ACPI issues that were previously not visible (because the system never entered these lower power states before).

There are previous examples where enabling LPM exposed serious BIOS/ACPI bugs, see e.g. commit 240630e61870 ("ahci: Disable LPM on Lenovo 50 series laptops with a too old BIOS").

Since there hasn't been any BIOS update in years for the ASUSPRO-D840SA motherboard, disable LPM for this board, in order to avoid entering lower PC-states, which triggers graphical corruptions.

Cc [email protected] # Depends on ahci_broken_lpm() refactor
Fixes 7627a0edef54 ("ata: ahci: Drop low power policy board type")
---
 drivers/ata/ahci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/ata/ahci.c +11 -0
index 05ff03b80b85..b065440bd911 100644
@@ -1456,6 +1456,17 @@ static bool ahci_broken_lpm(struct pci_dev *pdev)
 			 */
 			.driver_data = "20180408",
 		},
+		{
+			.matches = {
+				DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+				DMI_MATCH(DMI_PRODUCT_VERSION, "ASUSPRO D840MB_M840SA"),
+			},
+			/*
+			 * 320, build date 20230208, has broken LPM, no working
+			 * BIOS exists at the time of writing.
+			 */
+			.driver_data = "20230208",
+		},
 		{ }	/* terminate list */
 	};
 	const struct dmi_system_id *dmi = dmi_first_match(sysids);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v2 3/3
#7 lore raw

Re: [PATCH v2 3/3] ata: ahci: Disallow LPM for ASUSPRO-D840SA motherboard

Quoted 29 lines · Niklas Cassel

A user has bisected a regression which causes graphical corruptions on his screen to commit 7627a0edef54 ("ata: ahci: Drop low power policy board type").

Simply reverting commit 7627a0edef54 ("ata: ahci: Drop low power policy board type") makes the graphical corruptions on his screen to go away. (Note: there are no visible messages in dmesg that indicates a problem with AHCI.)

The user also reports that the problem occurs regardless if there is an HDD or an SSD connected via AHCI, so the problem is not device related.

The devices also work fine on other motherboards, so it seems specific to the ASUSPRO-D840SA motherboard.

While enabling low power modes for AHCI is not supposed to affect completely unrelated hardware, like a graphics card, it does however allow the system to enter deeper PC-states, which could expose ACPI issues that were previously not visible (because the system never entered these lower power states before).

There are previous examples where enabling LPM exposed serious BIOS/ACPI bugs, see e.g. commit 240630e61870 ("ahci: Disable LPM on Lenovo 50 series laptops with a too old BIOS").

Since there hasn't been any BIOS update in years for the ASUSPRO-D840SA motherboard, disable LPM for this board, in order to avoid entering lower PC-states, which triggers graphical corruptions.

Quoted 6 lines
Cc [email protected] # Depends on ahci_broken_lpm() refactor
Fixes 7627a0edef54 ("ata: ahci: Drop low power policy board type")
Signature · 2 lines
Damien Le Moal
Western Digital Research
author maintainer Applied
#8 lore raw
In reply to Niklas Cassel
Quoted 8 lines · Niklas Cassel

This series cleans up ahci_broken_lpm(), and adds ASUSPRO-D840SA to the table of boards with broken LPM.

Kind regards,
Niklas

[...]

Applied to libata/linux.git (for-6.16-fixes), thanks!

[1/3] ata: ahci: Use correct BIOS build date for ThinkPad W541 quirk

      https://git.kernel.org/libata/linux/c/6f29d393
[2/3] ata: ahci: Refactor ahci_broken_lpm()
      https://git.kernel.org/libata/linux/c/e3ea4ae4
[3/3] ata: ahci: Disallow LPM for ASUSPRO-D840SA motherboard
      https://git.kernel.org/libata/linux/c/4b151c71

Kind regards,
Niklas

author maintainer
#9 lore raw
Quoted 10 lines · Niklas Cassel
Quoted 8 lines · Niklas Cassel

This series cleans up ahci_broken_lpm(), and adds ASUSPRO-D840SA to the table of boards with broken LPM.

Kind regards,
Niklas

[...]

Quoted 8 lines

Applied to libata/linux.git (for-6.16-fixes), thanks!

[1/3] ata: ahci: Use correct BIOS build date for ThinkPad W541 quirk

      https://git.kernel.org/libata/linux/c/6f29d393
[2/3] ata: ahci: Refactor ahci_broken_lpm()
      https://git.kernel.org/libata/linux/c/e3ea4ae4
[3/3] ata: ahci: Disallow LPM for ASUSPRO-D840SA motherboard
      https://git.kernel.org/libata/linux/c/4b151c71

Patch [2/3] and [3/3] have been dropped from for-6.16-fixes, will rework these as Mikko pointed out that the solution is not really future proof.

Patch [1/3] is kept.

Kind regards,
Niklas