summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)))