From patchwork Mon Jul 2 19:08:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Pandruvada X-Patchwork-Id: 10502289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7F33360284 for ; Mon, 2 Jul 2018 19:08:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6805428D31 for ; Mon, 2 Jul 2018 19:08:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B21228D43; Mon, 2 Jul 2018 19:08:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB02C28D31 for ; Mon, 2 Jul 2018 19:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753032AbeGBTIs (ORCPT ); Mon, 2 Jul 2018 15:08:48 -0400 Received: from mga06.intel.com ([134.134.136.31]:52529 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752629AbeGBTIs (ORCPT ); Mon, 2 Jul 2018 15:08:48 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2018 12:08:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,299,1526367600"; d="scan'208";a="242423020" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga006.fm.intel.com with ESMTP; 02 Jul 2018 12:08:46 -0700 From: Srinivas Pandruvada To: tj@kernel.org, hdegoede@redhat.com, rjw@rjwysocki.net Cc: alan.cox@intel.com, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Mario.Limonciello@dell.com, Srinivas Subject: [RFC PATCH] ata: ahci: Enable DEVSLP by default on x86 modern standby platform Date: Mon, 2 Jul 2018 12:08:45 -0700 Message-Id: <20180702190845.7456-1-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Srinivas 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 even with out of the box Linux installation. 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 for some platforms. To avoid regressions, the following conditions are used: - The kernel config is already set to use med_power_with_dipm or deeper - System is a modern standby system using ACPI low power idle flag - The platform is not blacklisted for Suspend to Idle and suspend to idle is used instead of S3 This combination will make sure that systems are fairly recent and since getting shipped with modern standby standby, the DEVSLP function is already validated. Signed-off-by: Srinivas Pandruvada --- drivers/ata/ahci.c | 13 +++++++++++++ kernel/power/suspend.c | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 738fb22978dd..0b8bd1b6cf7c 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -1550,6 +1551,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; @@ -1736,6 +1747,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]; diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 87331565e505..969e67715cf7 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -49,6 +49,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);