From patchwork Thu Jan 26 22:51:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9540243 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 AFC2260429 for ; Thu, 26 Jan 2017 22:52:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4302282F5 for ; Thu, 26 Jan 2017 22:52:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95F6228319; Thu, 26 Jan 2017 22:52:05 +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 24810282F5 for ; Thu, 26 Jan 2017 22:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559AbdAZWvq (ORCPT ); Thu, 26 Jan 2017 17:51:46 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:56366 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752291AbdAZWvn (ORCPT ); Thu, 26 Jan 2017 17:51:43 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 249F76084C; Thu, 26 Jan 2017 22:51:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1485471098; bh=lc7JHk20qa17uKB0z2Ei+8B06eNGtzX/J3i8T9YEIoY=; h=From:To:Cc:Subject:Date:From; b=Oqc8Zw8UJdpoBbMWfySW4C5BqrWHAo9xAKQgZ3Lk7eOXZEWWTs/HGXbq5R67kn55b xgfCeoIEDz6VqWhRDAHTsE9PvPcX4oMS3fsPpcXxTPoDL34HKPMpXG70B1qMTmSvmj 9Lg9k3DSSgqvUpKl7HcTRpui25WT1/H0bW5FPgf0= 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 E4723601D3; Thu, 26 Jan 2017 22:51:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1485471097; bh=lc7JHk20qa17uKB0z2Ei+8B06eNGtzX/J3i8T9YEIoY=; h=From:To:Cc:Subject:Date:From; b=Bj/4GZmIPgZL04v1nlZKMywtpURMPm5mgabQ5TZyivaEaLingH3HvWLEk2LVB3gp7 tL2qXhGrnsPzPTaZl59NG+KePwfpJ4HKc99AJAlbs1pu7EdB9wBzdHPbVLe/tOVB/y Cc/x1sc+iN9nWLgWHSG3oq6D5XXvyubyur+4+5TE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E4723601D3 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, cov@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , linux-kernel@vger.kernel.org Subject: [PATCH] PCI/ASPM: reconfigure ASPM following hotplug Date: Thu, 26 Jan 2017 17:51:32 -0500 Message-Id: <1485471092-16906-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 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 When the operating system is booted with the default ASPM policy, the current code is determining the ASPM policy by querying the enable/disable states from ASPM registers. In the case of hotplug removal, the ASPM registers get cleared by calling the exit function. An insertion following remove reads incorrect policy as disabled even though ASPM was enabled during boot. Adding a flag to the struct pci_dev and saving the power up policy in the bridge to be reused during hotplug insertion. Bridge's enable counter is used as a switch to determine when to use saved value. Signed-off-by: Sinan Kaya --- drivers/pci/pcie/aspm.c | 13 ++++++++++--- include/linux/pci.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 17ac1dc..32b8a86 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -338,7 +338,9 @@ static void pcie_aspm_check_latency(struct pci_dev *endpoint) } } -static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) +static +void pcie_aspm_cap_init(struct pci_dev *pdev, struct pcie_link_state *link, + int blacklist) { struct pci_dev *child, *parent = link->pdev; struct pci_bus *linkbus = parent->subordinate; @@ -398,7 +400,12 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->latency_dw.l1 = calc_l1_latency(dwreg.latency_encoding_l1); /* Save default state */ - link->aspm_default = link->aspm_enabled; + if (!atomic_read(&pdev->enable_cnt)) { + link->aspm_default = link->aspm_enabled; + pdev->aspm_default = link->aspm_default; + } else { + link->aspm_default = pdev->aspm_default; + } /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; @@ -599,7 +606,7 @@ void pcie_aspm_init_link_state(struct pci_dev *pdev) * upstream links also because capable state of them can be * update through pcie_aspm_cap_init(). */ - pcie_aspm_cap_init(link, blacklist); + pcie_aspm_cap_init(pdev, link, blacklist); /* Setup initial Clock PM state */ pcie_clkpm_cap_init(link, blacklist); diff --git a/include/linux/pci.h b/include/linux/pci.h index e2d1a12..d0ecde6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -316,6 +316,7 @@ struct pci_dev { unsigned int hotplug_user_indicators:1; /* SlotCtl indicators controlled exclusively by user sysfs */ + unsigned int aspm_default; /* aspm policy set by BIOS */ unsigned int d3_delay; /* D3->D0 transition time in ms */ unsigned int d3cold_delay; /* D3cold->D0 transition time in ms */