From patchwork Thu Nov 5 01:38:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenji Kaneshige X-Patchwork-Id: 57811 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 nA51cXGB030586 for ; Thu, 5 Nov 2009 01:38:33 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750754AbZKEBiP (ORCPT ); Wed, 4 Nov 2009 20:38:15 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750752AbZKEBiP (ORCPT ); Wed, 4 Nov 2009 20:38:15 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:46688 "EHLO fgwmail6.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750754AbZKEBiO (ORCPT ); Wed, 4 Nov 2009 20:38:14 -0500 Received: from m2.gw.fujitsu.co.jp ([10.0.50.72]) by fgwmail6.fujitsu.co.jp (Fujitsu Gateway) with ESMTP id nA51cIpI028928 (envelope-from kaneshige.kenji@jp.fujitsu.com); Thu, 5 Nov 2009 10:38:18 +0900 Received: from smail (m2 [127.0.0.1]) by outgoing.m2.gw.fujitsu.co.jp (Postfix) with ESMTP id 17C0345DE65; Thu, 5 Nov 2009 10:38:18 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (s2.gw.fujitsu.co.jp [10.0.50.92]) by m2.gw.fujitsu.co.jp (Postfix) with ESMTP id C270145DE57; Thu, 5 Nov 2009 10:38:17 +0900 (JST) Received: from s2.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id 74F361DB8038; Thu, 5 Nov 2009 10:38:17 +0900 (JST) Received: from m107.s.css.fujitsu.com (m107.s.css.fujitsu.com [10.249.87.107]) by s2.gw.fujitsu.co.jp (Postfix) with ESMTP id F2C711DB8043; Thu, 5 Nov 2009 10:38:16 +0900 (JST) Received: from m107.css.fujitsu.com (m107 [127.0.0.1]) by m107.s.css.fujitsu.com (Postfix) with ESMTP id C63EC670006; Thu, 5 Nov 2009 10:38:16 +0900 (JST) Received: from [127.0.0.1] (unknown [10.124.100.137]) by m107.s.css.fujitsu.com (Postfix) with ESMTP id 67911670009; Thu, 5 Nov 2009 10:38:16 +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]); Thu, 05 Nov 2009 10:38:15 +0900 (JST) Message-ID: <4AF22C82.2040105@jp.fujitsu.com> Date: Thu, 05 Nov 2009 10:38:10 +0900 From: Kenji Kaneshige User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: rdh@east.sun.com CC: Jesse Barnes , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH] pci/pcie: Avoid unnecessary PCIe link retrains References: <19184.41676.262206.134000@gargle.gargle.HOWL> <20091104110321.5e58e112@jbarnes-piketon> In-Reply-To: <20091104110321.5e58e112@jbarnes-piketon> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Index: 20091026/drivers/pci/pcie/aspm.c =================================================================== --- 20091026.orig/drivers/pci/pcie/aspm.c +++ 20091026/drivers/pci/pcie/aspm.c @@ -186,6 +186,7 @@ static void pcie_aspm_configure_common_c unsigned long start_jiffies; struct pci_dev *child, *parent = link->pdev; struct pci_bus *linkbus = parent->subordinate; + bool ccc_updated = false; /* * All functions of a slot should have the same Slot Clock * Configuration, so just check one function @@ -214,7 +215,10 @@ static void pcie_aspm_configure_common_c reg16 |= PCI_EXP_LNKCTL_CCC; else reg16 &= ~PCI_EXP_LNKCTL_CCC; + if (reg16 == child_reg[PCI_FUNC(child->devfn)]) + continue; pci_write_config_word(child, cpos + PCI_EXP_LNKCTL, reg16); + ccc_updated = true; } /* Configure upstream component */ @@ -224,7 +228,14 @@ static void pcie_aspm_configure_common_c reg16 |= PCI_EXP_LNKCTL_CCC; else reg16 &= ~PCI_EXP_LNKCTL_CCC; - pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, reg16); + if (reg16 != parent_reg) { + pci_write_config_word(parent, ppos + PCI_EXP_LNKCTL, reg16); + ccc_updated = true; + } + + /* Don't need to retrain link if there is no change in CCC */ + if (!ccc_updated) + return; /* Retrain link */ reg16 |= PCI_EXP_LNKCTL_RL;