From patchwork Tue Aug 27 07:40:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Mintz X-Patchwork-Id: 2850015 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A0A29BF546 for ; Tue, 27 Aug 2013 07:40:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3DB91201B9 for ; Tue, 27 Aug 2013 07:40:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E5EF200DE for ; Tue, 27 Aug 2013 07:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752922Ab3H0Hka (ORCPT ); Tue, 27 Aug 2013 03:40:30 -0400 Received: from mms3.broadcom.com ([216.31.210.19]:1192 "EHLO mms3.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752349Ab3H0Hk3 convert rfc822-to-8bit (ORCPT ); Tue, 27 Aug 2013 03:40:29 -0400 Received: from [10.9.208.57] by mms3.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Tue, 27 Aug 2013 00:30:05 -0700 X-Server-Uuid: B86B6450-0931-4310-942E-F00ED04CA7AF Received: from SJEXCHCAS04.corp.ad.broadcom.com (10.16.203.10) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.1.438.0; Tue, 27 Aug 2013 00:40:18 -0700 Received: from SJEXCHMB10.corp.ad.broadcom.com ( [fe80::c9d6:2531:eeae:ffcb]) by SJEXCHCAS04.corp.ad.broadcom.com ( [::1]) with mapi id 14.01.0438.000; Tue, 27 Aug 2013 00:40:18 -0700 From: "Yuval Mintz" To: "Bjorn Helgaas" cc: "jacob.e.keller@intel.com" , "linux-pci@vger.kernel.org" , "netdev@vger.kernel.org" Subject: RE: pcie_get_minimum_link returns 0 width Thread-Topic: pcie_get_minimum_link returns 0 width Thread-Index: AQHOoXokh1WPwmxE/kiaRyaMfSlAMJmlsX8AgAAT26CAAr29AP//o0DQgAB8HgCAAApgQA== Date: Tue, 27 Aug 2013 07:40:17 +0000 Message-ID: <979A8436335E3744ADCD3A9F2A2B68A52AD13FB9@SJEXCHMB10.corp.ad.broadcom.com> References: <20130825100157.GA16500@lb-tlvb-yuvalmin.il.broadcom.com> <979A8436335E3744ADCD3A9F2A2B68A52AD136BE@SJEXCHMB10.corp.ad.broadcom.com> <979A8436335E3744ADCD3A9F2A2B68A52AD13D0C@SJEXCHMB10.corp.ad.broadcom.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.16.203.100] MIME-Version: 1.0 X-WSS-ID: 7E028AF62L878420891-02-01 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP > On Mon, Aug 26, 2013 at 5:36 PM, Yuval Mintz > wrote: > >> > Hi, > >> > > >> > I tried adding support for the newly added 'pcie_get_minimum_link' into > >> the > >> > bnx2x driver, but found out the some of my devices started showing > width > >> x0. > >> > > >> > By adding debug prints, I've found out there were devices up the chain > that > >> > Showed 0 when their PCI_EXP_LNKSTA was read by said function. > >> > However, when I tried looking via lspci the output claimed the width was > >> x4. > Looking at its implementation, one obvious difference is that > pcie_get_minimum_link() traverses up the hierarchy and keeps track of > the minimum values it finds. lspci, on the other hand, just reads > PCI_EXP_LNKSTA from a single device and decodes it. > > You said lspci reports x4 for every device from the Root Port all the > way down to your NIC, so I would think the minimum from > pcie_get_minimum_link() would be x4. But apparently it's not. Maybe > there's a bug in it. Can you post the complete "lspci -vv" output > along with your debug patch and output? > > Bjorn Here's the patch: --- drivers/pci/pci.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index c71e78c..72cb87b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3601,13 +3601,19 @@ int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, enum pcie_link_width next_width; ret = pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta); - if (ret) + if (ret) { + printk(KERN_ERR "Failed to Read LNKSTA\n"); return ret; + } next_speed = pcie_link_speed[lnksta & PCI_EXP_LNKSTA_CLS]; next_width = (lnksta & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; + printk(KERN_ERR "LnkSta %04x [%04x:%02x.%02x]\n", + lnksta, dev->bus->number, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn)); + if (next_speed < *speed) *speed = next_speed;