From patchwork Sat Mar 25 21:38:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9644879 X-Patchwork-Delegate: bhelgaas@google.com 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 1CF0E6020B for ; Sat, 25 Mar 2017 21:40:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E21C23E64 for ; Sat, 25 Mar 2017 21:40:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3F7927165; Sat, 25 Mar 2017 21:40:01 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 A9E4E23E64 for ; Sat, 25 Mar 2017 21:40:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751192AbdCYVi5 (ORCPT ); Sat, 25 Mar 2017 17:38:57 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37486 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751205AbdCYVi4 (ORCPT ); Sat, 25 Mar 2017 17:38:56 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D0B5760DEA; Sat, 25 Mar 2017 21:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1490477912; bh=QK1yt5dosJ1jIPIgE8x0KoIv0XIpvauVoNg4gV1zP9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0YaO0jrrNbMm1JgoNJ8z2fcz0ysOHodHhEMelGjs2s2i3qpHzzM3uLPNUbC9EBol GSu18zXNyF0NKu7kkCJpGbV9qL7iDc0fNej6rkfPkStJ2SrBtUGw48D1rHzuNfRMKV dJOi1ymnH4MXIQbUYD1X32EF7Md9FzgOzcUIkCLw= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id BBD5460DEA; Sat, 25 Mar 2017 21:38:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1490477912; bh=QK1yt5dosJ1jIPIgE8x0KoIv0XIpvauVoNg4gV1zP9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M0YaO0jrrNbMm1JgoNJ8z2fcz0ysOHodHhEMelGjs2s2i3qpHzzM3uLPNUbC9EBol GSu18zXNyF0NKu7kkCJpGbV9qL7iDc0fNej6rkfPkStJ2SrBtUGw48D1rHzuNfRMKV dJOi1ymnH4MXIQbUYD1X32EF7Md9FzgOzcUIkCLw= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BBD5460DEA Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org Cc: mayurkumar.patel@intel.com, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , Rajat Jain , Julia Lawall , David Daney , Shawn Lin , linux-kernel@vger.kernel.org Subject: [PATCH V5 3/4] PCI/ASPM: save power on values during bridge init Date: Sat, 25 Mar 2017 17:38:12 -0400 Message-Id: <1490477893-9517-4-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490477893-9517-1-git-send-email-okaya@codeaurora.org> References: <1490477893-9517-1-git-send-email-okaya@codeaurora.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we added a hook to be called from device_add, save the default values from the HW registers early in the boot for further reuse during hot device add/remove operations. Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=194895 Signed-off-by: Sinan Kaya --- drivers/pci/pcie/aspm.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index f5b1fa0..f48bb29 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -521,8 +521,10 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) */ if (dwreg.support & upreg.support & PCIE_LINK_STATE_L0S) link->aspm_support |= ASPM_STATE_L0S; - if (dwreg.enabled & PCIE_LINK_STATE_L0S) + if (dwreg.enabled & PCIE_LINK_STATE_L0S) { link->aspm_enabled |= ASPM_STATE_L0S_UP; + link->aspm_default |= ASPM_STATE_L0S_UP; + } if (upreg.enabled & PCIE_LINK_STATE_L0S) link->aspm_enabled |= ASPM_STATE_L0S_DW; link->latency_up.l0s = calc_l0s_latency(upreg.latency_encoding_l0s); @@ -558,9 +560,6 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) if (link->aspm_support & ASPM_STATE_L1SS) aspm_calc_l1ss_info(link, &upreg, &dwreg); - /* Save default state */ - link->aspm_default = link->aspm_enabled; - /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; /* @@ -835,6 +834,7 @@ static struct pcie_link_state *alloc_pcie_link_state(struct pci_dev *pdev) int pci_aspm_init(struct pci_dev *pdev) { struct pcie_link_state *link; + struct aspm_register_info upreg; if (!aspm_support_enabled) return 0; @@ -851,6 +851,20 @@ int pci_aspm_init(struct pci_dev *pdev) if (!link) return -ENOMEM; + pcie_get_aspm_reg(pdev, &upreg); + if (upreg.enabled & PCIE_LINK_STATE_L0S) + link->aspm_default |= ASPM_STATE_L0S_DW; + if (upreg.enabled & PCIE_LINK_STATE_L1) + link->aspm_default |= ASPM_STATE_L1; + if (upreg.l1ss_ctl1 & PCI_L1SS_CTL1_ASPM_L1_1) + link->aspm_default |= ASPM_STATE_L1_1; + if (upreg.l1ss_ctl1 & PCI_L1SS_CTL1_ASPM_L1_2) + link->aspm_default |= ASPM_STATE_L1_2; + if (upreg.l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_1) + link->aspm_default |= ASPM_STATE_L1_1_PCIPM; + if (upreg.l1ss_ctl1 & PCI_L1SS_CTL1_PCIPM_L1_2) + link->aspm_default |= ASPM_STATE_L1_2_PCIPM; + return 0; }