From patchwork Wed Nov 28 09:19:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1004294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ElQF3Qx8"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434Zr015Wbz9s6w; Wed, 28 Nov 2018 20:20:16 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gRw0w-0000sV-5t; Wed, 28 Nov 2018 09:20:10 +0000 Received: from mail-pl1-f194.google.com ([209.85.214.194]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gRw0r-0000ot-3Z for kernel-team@lists.ubuntu.com; Wed, 28 Nov 2018 09:20:05 +0000 Received: by mail-pl1-f194.google.com with SMTP id u6so17098244plm.8 for ; Wed, 28 Nov 2018 01:20:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=fTeLu1iSF194sIqgB2qCH1idZ/7dOBhjBkbz66OdrmI=; b=ElQF3Qx8xTIcJgTytXNppIO5+9KF1Wg34XLobNGRFsrop81AL4WhupxBkJMsSBR5X/ 4PYTUt2JT/11eh3Dgc8KE68tvd1GQZg3qW9oIIz/fNuRtzqkgyI9vzQaMQwee6ufCvXc g1I/HFRpNQaHMAfRU9u9RMmRq5AbX2CtcEfEnQ2/qAvSfCwA9lMfh/xdWQjfqkbDwl9L anLuFJ/Q8dBfnmhHHiAQzam1DJaYEcuOxsK7dEaRFCi61/cgCy+OWoBXK1CJXBoiemby EP7V9OzIPraVH/F85rps7msD4ASbcUg1ZeoTXTiMLISz5fMniGMfS5nxTpATfg6pM441 1cSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=fTeLu1iSF194sIqgB2qCH1idZ/7dOBhjBkbz66OdrmI=; b=CVWkK+5EVjt5yGUDVMlKPEdZgUTF8oRcl54Z3cqBeo2+Kmyuz3WpKiogRVlccARqv1 JSc1Ori3g66JcOV9KLdGWxRsKto/qBXp2gWDFGskLlOrD0wz1zuqX3LnlowhWelQ5UIx wtPsYmFKGl1d87GHrJonSJouo0Q4UrRuwnZEIyCjSkbgi3619MgnsNK7Emf/x6NTHQmr RM0V5uOW0GMt54rgz9tCm/JVpnMBU9wi0V0Ya0x/OC9C86YA78p2lpsXNTuWRsc55dUV 8oE5lUxp5nfyEadXl35ffkJbEqNkF2MnJ8gwBB6hjgOCFbRTLhLwa4e8/LhBbEPEtQql 9JLw== X-Gm-Message-State: AA+aEWZgeRltUKs2mma3yIrRUtuuOAqbY9QKNRXGejdR5M3B52H06qTI kp334JLGPDJqQOjqSbCm5wTvHGkD X-Google-Smtp-Source: AFSGD/UbrkTX9/DZ+vvX768DwlLE/iWSJOtl+bYgtY8H+GjRVe6F4swFVafmUpLsFx7qbuPD7LCm5Q== X-Received: by 2002:a17:902:b112:: with SMTP id q18mr19577215plr.255.1543396802509; Wed, 28 Nov 2018 01:20:02 -0800 (PST) Received: from localhost (114-32-69-186.HINET-IP.hinet.net. [114.32.69.186]) by smtp.gmail.com with ESMTPSA id h10sm7126167pgn.11.2018.11.28.01.20.01 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 01:20:01 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/5][SRU][B] ata: ahci: Enable DEVSLP by default on x86 with SLP_S0 Date: Wed, 28 Nov 2018 17:19:30 +0800 Message-Id: <20181128091932.18316-10-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181128091932.18316-1-acelan.kao@canonical.com> References: <20181128091932.18316-1-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Srinivas Pandruvada BugLink: https://bugs.launchpad.net/bugs/1781533 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 Reviewed-by: Hans de Goede Signed-off-by: Tejun Heo (cherry picked from commit b1a9585cc396cac5a9e5a09b2721f3b8568e62d0) Signed-off-by: AceLan Kao --- drivers/ata/ahci.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 6389c88b3500..8e2d099caed3 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -608,7 +608,7 @@ static int marvell_enable = 1; module_param(marvell_enable, int, 0644); MODULE_PARM_DESC(marvell_enable, "Marvell SATA via AHCI (1 = enabled)"); -static int mobile_lpm_policy = CONFIG_SATA_MOBILE_LPM_POLICY; +static int mobile_lpm_policy = -1; module_param(mobile_lpm_policy, int, 0644); MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets"); @@ -1549,6 +1549,37 @@ 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_initial_lpm_policy(struct ata_port *ap, + struct ahci_host_priv *hpriv) +{ + int policy = CONFIG_SATA_MOBILE_LPM_POLICY; + + + /* Ignore processing for non mobile platforms */ + if (!(hpriv->flags & AHCI_HFLAG_IS_MOBILE)) + return; + + /* user modified policy via module param */ + if (mobile_lpm_policy != -1) { + policy = mobile_lpm_policy; + goto update_policy; + } + +#ifdef CONFIG_ACPI + if (policy > ATA_LPM_MED_POWER && + (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0)) { + if (hpriv->cap & HOST_CAP_PART) + policy = ATA_LPM_MIN_POWER_WITH_PARTIAL; + else if (hpriv->cap & HOST_CAP_SSC) + policy = ATA_LPM_MIN_POWER; + } +#endif + +update_policy: + if (policy >= ATA_LPM_UNKNOWN && policy <= ATA_LPM_MIN_POWER) + ap->target_lpm_policy = policy; +} + static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { unsigned int board_id = ent->driver_data; @@ -1746,10 +1777,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (ap->flags & ATA_FLAG_EM) ap->em_message_type = hpriv->em_msg_type; - if ((hpriv->flags & AHCI_HFLAG_IS_MOBILE) && - mobile_lpm_policy >= ATA_LPM_UNKNOWN && - mobile_lpm_policy <= ATA_LPM_MIN_POWER) - ap->target_lpm_policy = mobile_lpm_policy; + ahci_update_initial_lpm_policy(ap, hpriv); /* disabled/not-implemented port */ if (!(hpriv->port_map & (1 << i)))