From patchwork Wed Aug 19 01:59:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenji Kaneshige X-Patchwork-Id: 42478 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7J1uolN022565 for ; Wed, 19 Aug 2009 02:00:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751348AbZHSCAI (ORCPT ); Tue, 18 Aug 2009 22:00:08 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751014AbZHSCAI (ORCPT ); Tue, 18 Aug 2009 22:00:08 -0400 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:52170 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751348AbZHSCAG (ORCPT ); Tue, 18 Aug 2009 22:00:06 -0400 Received: from m4.gw.fujitsu.co.jp ([10.0.50.74]) by fgwmail5.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id n7J206xU001043 for (envelope-from kaneshige.kenji@jp.fujitsu.com); Wed, 19 Aug 2009 11:00:07 +0900 Received: from smail (m4 [127.0.0.1]) by outgoing.m4.gw.fujitsu.co.jp (Postfix) with ESMTP id AA8E345DE6E for ; Wed, 19 Aug 2009 11:00:06 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (s4.gw.fujitsu.co.jp [10.0.50.94]) by m4.gw.fujitsu.co.jp (Postfix) with ESMTP id 3F26645DE6F for ; Wed, 19 Aug 2009 11:00:06 +0900 (JST) Received: from s4.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 0B9F3E08005 for ; Wed, 19 Aug 2009 11:00:06 +0900 (JST) Received: from m106.s.css.fujitsu.com (m106.s.css.fujitsu.com [10.249.87.106]) by s4.gw.fujitsu.co.jp (Postfix) with ESMTP id 4E2A6E08006 for ; Wed, 19 Aug 2009 11:00:05 +0900 (JST) Received: from m106.css.fujitsu.com (m106 [127.0.0.1]) by m106.s.css.fujitsu.com (Postfix) with ESMTP id 161935B887A; Wed, 19 Aug 2009 11:00:05 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.100.137]) by m106.s.css.fujitsu.com (Postfix) with ESMTP id 0F47D5B889E; Wed, 19 Aug 2009 11:00:04 +0900 (JST) X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 Received: from KANE-LIFEBOOK[10.124.100.137] by KANE-LIFEBOOK (FujitsuOutboundMailChecker v1.3.1/9992[10.124.100.137]); Wed, 19 Aug 2009 10:59:57 +0900 (JST) Message-ID: <4A8B5C98.5000608@jp.fujitsu.com> Date: Wed, 19 Aug 2009 10:59:52 +0900 From: Kenji Kaneshige User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: jbarnes@virtuousgeek.org, shaohua.li@intel.com, linux-pci@vger.kernel.org Subject: [PATCH 4/7] PCI ASPM: introduce disable flag References: <4A8B5BC8.1070907@jp.fujitsu.com> In-Reply-To: <4A8B5BC8.1070907@jp.fujitsu.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Introduce 'aspm_disable' flag to manage disabled ASPM state more robust way. Signed-off-by: Kenji Kaneshige --- drivers/pci/pcie/aspm.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: 20090818/drivers/pci/pcie/aspm.c =================================================================== --- 20090818.orig/drivers/pci/pcie/aspm.c +++ 20090818/drivers/pci/pcie/aspm.c @@ -43,6 +43,7 @@ struct pcie_link_state { u32 aspm_support:2; /* Supported ASPM state */ u32 aspm_enabled:2; /* Enabled ASPM state */ u32 aspm_default:2; /* Default ASPM state by BIOS */ + u32 aspm_disable:2; /* Disabled ASPM state */ /* Clock PM state */ u32 clkpm_capable:1; /* Clock PM capable? */ @@ -322,10 +323,9 @@ static void pcie_aspm_cap_init(struct pc struct pci_bus *linkbus = parent->subordinate; if (blacklist) { - /* Set support state to 0, so we will disable ASPM later */ - link->aspm_support = 0; - link->aspm_default = 0; + /* Set enabled/disable so that we will disable ASPM later */ link->aspm_enabled = PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1; + link->aspm_disable = PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1; return; } @@ -348,6 +348,17 @@ static void pcie_aspm_cap_init(struct pc /* Save default state */ link->aspm_default = link->aspm_enabled; + /* + * If the downstream component has pci bridge function, don't + * do ASPM for now. + */ + list_for_each_entry(child, &linkbus->devices, bus_list) { + if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) { + link->aspm_disable = + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1; + break; + } + } if (!link->aspm_support) return; @@ -458,14 +469,10 @@ static void __pcie_aspm_config_link(stru struct pci_dev *child, *parent = link->pdev; struct pci_bus *linkbus = parent->subordinate; - /* - * If the downstream component has pci bridge function, don't - * do ASPM now. - */ - list_for_each_entry(child, &linkbus->devices, bus_list) { - if (child->pcie_type == PCI_EXP_TYPE_PCI_BRIDGE) - return; - } + state &= ~link->aspm_disable; + /* Nothing to do if the link is already in the requested state */ + if (link->aspm_enabled == state) + return; /* * Spec 2.0 suggests all functions should be configured the * same setting for ASPM. Enabling ASPM L1 should be done in @@ -719,7 +726,7 @@ void pcie_aspm_pm_state_change(struct pc void pci_disable_link_state(struct pci_dev *pdev, int state) { struct pci_dev *parent = pdev->bus->self; - struct pcie_link_state *link_state; + struct pcie_link_state *link; if (aspm_disabled || !pdev->is_pcie) return; @@ -731,12 +738,12 @@ void pci_disable_link_state(struct pci_d down_read(&pci_bus_sem); mutex_lock(&aspm_lock); - link_state = parent->link_state; - link_state->aspm_support &= ~state; - __pcie_aspm_configure_link_state(link_state, link_state->aspm_enabled); + link = parent->link_state; + link->aspm_disable |= state; + __pcie_aspm_configure_link_state(link, link->aspm_enabled); if (state & PCIE_LINK_STATE_CLKPM) { - link_state->clkpm_capable = 0; - pcie_set_clkpm(link_state, 0); + link->clkpm_capable = 0; + pcie_set_clkpm(link, 0); } mutex_unlock(&aspm_lock); up_read(&pci_bus_sem);