[PATCH 1/2] ata: ahci: Add force LPM policy quirk for ASUS B1400CEAE

Jian-Hong Pan
2024-01-30T10:00:26Z

Some systems, like ASUS B1400CEAE equipped with the SATA controller
[8086:a0d3] can use LPM policy to save power, especially for s2idle.

However, the same controller may be failed on other platforms. So,
commit (ata: ahci: Revert "ata: ahci: Add Tiger Lake UP{3,4} AHCI
controller") drops LPM policy for [8086:a0d3]. But, this blocks going
to deeper CPU Package C-state when s2idle with enabled Intel VMD.

This patch adds ahci_force_lpm_policy DMI quirk for ASUS B1400CEAE to
fix s2idle's power consumption issue when Intel VMD feature is enabled.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=218394
Signed-off-by: Jian-Hong Pan <jhp@endlessos.org>
---
drivers/ata/ahci.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index d2460fa985b7..6bc5298a4adf 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1434,6 +1434,33 @@ static bool ahci_broken_devslp(struct pci_dev *pdev)
return pci_match_id(ids, pdev);
}

+static bool ahci_force_lpm_policy(void)
+{
+ /*
+ * Some systems, like ASUS B1400CEAE equipped with the SATA controller
+ * [8086:a0d3] can use LPM policy to save power, especially for s2idle.
+ * However, the same controller may be failed on other platforms. So,
+ * commit (ata: ahci: Revert "ata: ahci: Add Tiger Lake UP{3,4} AHCI
+ * controller") drops LPM policy for [8086:a0d3].
+ *
+ * https://bugzilla.kernel.org/show_bug.cgi?id=218394
+ */
+ static const struct dmi_system_id sysids[] = {
+ {
+ .ident = "ASUS B1400CEAE",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR,
+ "ASUSTeK COMPUTER INC."),
+ DMI_MATCH(DMI_PRODUCT_NAME,
+ "ASUS EXPERTBOOK B1400CEAE"),
+ },
+ },
+ { } /* terminate list */
+ };
+
+ return dmi_first_match(sysids);
+}
+
#ifdef CONFIG_ATA_ACPI
static void ahci_gtf_filter_workaround(struct ata_host *host)
{
@@ -1760,6 +1787,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
ahci_pci_bar = AHCI_PCI_BAR_LOONGSON;
}

+ if (ahci_force_lpm_policy()) {
+ pi = ahci_port_info[board_ahci_low_power];
+ dev_info(&pdev->dev, "force controller follow LPM policy\n");
+ }
+
/* acquire resources */
rc = pcim_enable_device(pdev);
if (rc)
--
2.43.0