@@ -43,6 +43,7 @@
#include <linux/dmi.h>
#include <linux/gfp.h>
#include <linux/msi.h>
+#include <linux/suspend.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_cmnd.h>
#include <linux/libata.h>
@@ -1549,6 +1550,16 @@ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
return pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSIX);
}
+static void ahci_update_mobile_policy(void)
+{
+#ifdef CONFIG_ACPI
+ if (mobile_lpm_policy > ATA_LPM_MED_POWER &&
+ (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) &&
+ mem_sleep_current == PM_SUSPEND_TO_IDLE)
+ mobile_lpm_policy = ATA_LPM_MIN_POWER;
+#endif
+}
+
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
unsigned int board_id = ent->driver_data;
@@ -1735,6 +1746,8 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (pi.flags & ATA_FLAG_EM)
ahci_reset_em(host);
+ ahci_update_mobile_policy();
+
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
@@ -48,6 +48,7 @@ static const char * const mem_sleep_labels[] = {
const char *mem_sleep_states[PM_SUSPEND_MAX];
suspend_state_t mem_sleep_current = PM_SUSPEND_TO_IDLE;
+EXPORT_SYMBOL_GPL(mem_sleep_current);
suspend_state_t mem_sleep_default = PM_SUSPEND_MAX;
suspend_state_t pm_suspend_target_state;
EXPORT_SYMBOL_GPL(pm_suspend_target_state);