summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2018-07-27 16:47:03 -0400
committerTejun Heo <tj@kernel.org>2018-07-30 10:09:28 -0400
commitb1a9585cc396cac5a9e5a09b2721f3b8568e62d0 (patch)
treeb0583c80ba70729d1d9c01719d0fa1ca2fad1fbf
parenta5ec5a7bfd1f28d1905499641c9f589be36808c1 (diff)
ata: ahci: Enable DEVSLP by default on x86 with SLP_S0
One of the requirement for modern x86 system to enter lowest power mode (SLP_S0) is SATA IP block to be off. This is true even during when platform is suspended to idle and not only in opportunistic (runtime) suspend. Several of these system don't have traditional ACPI S3, so it is important that they enter SLP_S0 state, to avoid draining battery even during suspend. So it is important that out of the box Linux installation reach this state. SATA IP block doesn't get turned off till SATA is in DEVSLP mode. Here user has to either use scsi-host sysfs or tools like powertop to set the sata-host link_power_management_policy to min_power. This change sets by default link power management policy to min_power with partial (preferred) or slumber support on idle for some platforms. To avoid regressions, the following conditions are used: - User didn't override the policy from module parameter - The kernel config is already set to use med_power_with_dipm or deeper - System is a SLP_S0 capable using ACPI low power idle flag This combination will make sure that systems are fairly recent and since getting shipped with SLP_S0 support, the DEVSLP function is already validated. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--drivers/ata/ahci.c38
1 files changed, 33 insertions, 5 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 738fb22978dd..b14dccda0154 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -609,7 +609,7 @@ static int marvell_enable = 1;
609module_param(marvell_enable, int, 0644); 609module_param(marvell_enable, int, 0644);
610MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)"); 610MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)");
611 611
612static int mobile_lpm_policy = CONFIG_SATA_MOBILE_LPM_POLICY; 612static int mobile_lpm_policy = -1;
613module_param(mobile_lpm_policy, int, 0644); 613module_param(mobile_lpm_policy, int, 0644);
614MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets"); 614MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");
615 615
@@ -1550,6 +1550,37 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
1550 return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX); 1550 return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
1551} 1551}
1552 1552
1553static void ahci_update_initial_lpm_policy(struct ata_port *ap,
1554 struct ahci_host_priv *hpriv)
1555{
1556 int policy = CONFIG_SATA_MOBILE_LPM_POLICY;
1557
1558
1559 /* Ignore processing for non mobile platforms */
1560 if (!(hpriv->flags & AHCI_HFLAG_IS_MOBILE))
1561 return;
1562
1563 /* user modified policy via module param */
1564 if (mobile_lpm_policy != -1) {
1565 policy = mobile_lpm_policy;
1566 goto update_policy;
1567 }
1568
1569#ifdef CONFIG_ACPI
1570 if (policy > ATA_LPM_MED_POWER &&
1571 (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) {
1572 if (hpriv->cap & HOST_CAP_PART)
1573 policy = ATA_LPM_MIN_POWER_WITH_PARTIAL;
1574 else if (hpriv->cap & HOST_CAP_SSC)
1575 policy = ATA_LPM_MIN_POWER;
1576 }
1577#endif
1578
1579update_policy:
1580 if (policy >= ATA_LPM_UNKNOWN && policy <= ATA_LPM_MIN_POWER)
1581 ap->target_lpm_policy = policy;
1582}
1583
1553static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1584static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1554{ 1585{
1555 unsigned int board_id = ent->driver_data; 1586 unsigned int board_id = ent->driver_data;
@@ -1747,10 +1778,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1747 if (ap->flags & ATA_FLAG_EM) 1778 if (ap->flags & ATA_FLAG_EM)
1748 ap->em_message_type = hpriv->em_msg_type; 1779 ap->em_message_type = hpriv->em_msg_type;
1749 1780
1750 if ((hpriv->flags & AHCI_HFLAG_IS_MOBILE) && 1781 ahci_update_initial_lpm_policy(ap, hpriv);
1751 mobile_lpm_policy >= ATA_LPM_UNKNOWN &&
1752 mobile_lpm_policy <= ATA_LPM_MIN_POWER)
1753 ap->target_lpm_policy = mobile_lpm_policy;
1754 1782
1755 /* disabled/not-implemented port */ 1783 /* disabled/not-implemented port */
1756 if (!(hpriv->port_map & (1 << i))) 1784 if (!(hpriv->port_map & (1 << i)))