From patchwork Fri Mar 3 09:43:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Patel, Mayurkumar" X-Patchwork-Id: 9602427 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 03B396016C for ; Fri, 3 Mar 2017 09:44:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9037285D3 for ; Fri, 3 Mar 2017 09:44:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DDD2C285E8; Fri, 3 Mar 2017 09:44:13 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6C7F5285D3 for ; Fri, 3 Mar 2017 09:44:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iea43Rri9v4b5CeTyR6UcmqAL+nZfW0ZgH2F7gswySg=; b=lZDWae/ulLX7Cu 6hgg6L1V7z8jyx7I+svR7E5mxWEt2OyZcQxjQKCOjmReVfromxCA57pZ2pWkICApnIReplT3LNHQl BP/YNPevYfehjw/8fbAqEDB3aI+f6TjGcbvbFwtld8MktX6Pw/pIxuDtxPs46kjJltOEY+++pe9ff G31FgDlRA5+dBuM6BnqKNIPys3GvpSq4/yNkGetdA3A+KHQAaeukb12HVNqfhxULI7zJYE0291T6c lTocGqakk0+3kqoqElCuXk+bFYJ4ZUtQMCbaqYwUwrUETzvqWaTuWBV8DvcDCmGG2bL87hcQWs6z1 BQvSN9uktBgOfnooyDKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjjkz-0000ai-5B; Fri, 03 Mar 2017 09:44:13 +0000 Received: from mga09.intel.com ([134.134.136.24]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjjku-0000Ze-BT for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2017 09:44:10 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2017 01:43:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,236,1484035200"; d="scan'208"; a="1104336075" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga001.jf.intel.com with ESMTP; 03 Mar 2017 01:43:44 -0800 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.112]) by IRSMSX104.ger.corp.intel.com ([163.33.3.159]) with mapi id 14.03.0248.002; Fri, 3 Mar 2017 09:43:44 +0000 From: "Patel, Mayurkumar" To: Sinan Kaya , "linux-pci@vger.kernel.org" , "timur@codeaurora.org" , "cov@codeaurora.org" , Bjorn Helgaas Subject: RE: [PATCH V2] PCI/ASPM: reconfigure ASPM following hotplug for POLICY_DEFAULT Thread-Topic: [PATCH V2] PCI/ASPM: reconfigure ASPM following hotplug for POLICY_DEFAULT Thread-Index: AQHSe/qttcHwVK+D9UySxiqVwThowaF+YrwwgABNHgCAADQfcIABjtUAgAD/8XCAAJX0gIABA3KA Date: Fri, 3 Mar 2017 09:43:43 +0000 Message-ID: <92EBB4272BF81E4089A7126EC1E7B2846666A1D5@IRSMSX101.ger.corp.intel.com> References: <1485891928-14573-1-git-send-email-okaya@codeaurora.org> <92EBB4272BF81E4089A7126EC1E7B2846666830C@IRSMSX101.ger.corp.intel.com> <92EBB4272BF81E4089A7126EC1E7B28466668774@IRSMSX101.ger.corp.intel.com> <92EBB4272BF81E4089A7126EC1E7B28466669BFF@IRSMSX101.ger.corp.intel.com> In-Reply-To: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_014408_506725_7217D086 X-CRM114-Status: GOOD ( 19.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-arm-msm@vger.kernel.org" , open list , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Kaya > >Hi Mayurkumar > >On 3/2/2017 11:05 AM, Patel, Mayurkumar wrote: >>> >>> Hi Bjorn, >>> >>> On 2/28/2017 1:57 PM, Patel, Mayurkumar wrote: >>>>> I was trying to figure out when to use saved values vs. the values in >>>>> registers by looking at the enable_cnt. >>>>> enable_cnt is 0 during boot on my system. >>>> enable_cnt for the root port on my system is set to 1 for "root port" already without saving >>>> any ASPM related settings. >>>> >>>> >>> >>> What would be the best way to figure out when to save power-on values from >>> the registers? >>> >> >> I can upload the diffs) because enable_cnt in pci_enable_device() can be triggered >> from multiple places at boot time so it might not be safe to use it? > >Go ahead and share your diff. It doesn't hurt to look at other alternatives. > So basically, I introduced a new atomic variable to save the aspm_policy for the first time. Below is my diff. >> >> @Kaya/Bjorn: Do you have any other suggestions or Could you also please help by comment what would make sense? >> >> >>> -- >>> Sinan Kaya >>> Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. >>> Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. >> Intel Deutschland GmbH >> Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany >> Tel: +49 89 99 8853-0, www.intel.de >> Managing Directors: Christin Eisenschmid, Christian Lamprechter >> Chairperson of the Supervisory Board: Nicole Lau >> Registered Office: Munich >> Commercial Register: Amtsgericht Muenchen HRB 186928 >> >> > > >-- >Sinan Kaya >Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. >Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Christian Lamprechter Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 3dd8bcb..c8e1e3a 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c @@ -338,8 +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, int blacklist) { + struct pcie_link_state *link = pdev->link_state; struct pci_dev *child, *parent = link->pdev; struct pci_bus *linkbus = parent->subordinate; struct aspm_register_info upreg, dwreg; @@ -397,8 +398,21 @@ static void pcie_aspm_cap_init(struct pcie_link_state *link, int blacklist) link->latency_up.l1 = calc_l1_latency(upreg.latency_encoding_l1); link->latency_dw.l1 = calc_l1_latency(dwreg.latency_encoding_l1); - /* Save default state */ - link->aspm_default = link->aspm_enabled; + /* + * Save default state from FW when enabling ASPM for the first time + * during boot by looking at the calculated link->aspm_enabled bits + * above and aspm_enable_cnt will be zero. + * + * If this path is getting called for the second/third time + * (aspm_enable_cnt will be non-zero). Assume that the current state + * of the ASPM registers may not necessarily match what FW asked us to + * do as in the case of hotplug insertion/removal. + */ + if (atomic_inc_return(&pdev->aspm_enable_cnt) == 1) + pdev->aspm_default = link->aspm_default = link->aspm_enabled; + else + link->aspm_default = pdev->aspm_default; + /* Setup initial capable state. Will be updated later */ link->aspm_capable = link->aspm_support; @@ -606,7 +620,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, 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..aa7bd7e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -321,6 +321,8 @@ struct pci_dev { #ifdef CONFIG_PCIEASPM struct pcie_link_state *link_state; /* ASPM link state */ + unsigned int aspm_default; /* ASPM policy set by BIOS */ + atomic_t aspm_enable_cnt; /* ASPM policy initialization */ #endif pci_channel_state_t error_state; /* current connectivity state */