From patchwork Tue Jan 8 14:32:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tadeusz Struk X-Patchwork-Id: 1946511 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 2A77DDF23A for ; Tue, 8 Jan 2013 14:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756443Ab3AHOdB (ORCPT ); Tue, 8 Jan 2013 09:33:01 -0500 Received: from mga01.intel.com ([192.55.52.88]:22050 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756436Ab3AHOdB (ORCPT ); Tue, 8 Jan 2013 09:33:01 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 08 Jan 2013 06:33:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.84,430,1355126400"; d="scan'208";a="274267532" Received: from swsutil001.isw.intel.com ([10.237.237.11]) by fmsmga002.fm.intel.com with ESMTP; 08 Jan 2013 06:32:58 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by swsutil001.isw.intel.com (8.13.6/8.13.6/MailSET/Hub) with ESMTP id r08EWvTu017752; Tue, 8 Jan 2013 14:32:58 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id r08EWvT7029904; Tue, 8 Jan 2013 14:32:57 GMT Received: (from tstruk@localhost) by sivswdev01.ir.intel.com with id r08EWvGj029900; Tue, 8 Jan 2013 14:32:57 GMT X-Authentication-Warning: sivswdev01.ir.intel.com: tstruk set sender to tadeusz.struk@intel.com using -r Date: Tue, 08 Jan 2013 14:32:57 +0000 From: tadeusz.struk@intel.com To: bhelgaas@google.com Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, tadeusz.struk@intel.com Subject: [PATCH] PCI: Make pci_find_upstream_pcie_bridge() handle non PCIE VFs well Message-ID: <50ec2e19.EUrQfXEnsRJiPCTv%tadeusz.struk@intel.com> User-Agent: nail 11.25 7/29/05 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org pci_find_upstream_pcie_bridge() doesn't handle well non PCIE VFs that are part of a PCIE PF device. Signed-off-by: Tadeusz Struk --- drivers/pci/search.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/drivers/pci/search.c b/drivers/pci/search.c index bf969ba..8ecdab2 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -23,6 +23,8 @@ EXPORT_SYMBOL_GPL(pci_bus_sem); * if the device isn't connected to a PCIe bridge (that is its parent is a * legacy PCI bridge and the bridge is directly connected to bus 0), return its * parent + * if the device is a VF that doesn't have PCIe cap, + * but the PF is a PCIE, return NULL */ struct pci_dev * pci_find_upstream_pcie_bridge(struct pci_dev *pdev) @@ -31,6 +33,10 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) if (pci_is_pcie(pdev)) return NULL; + + if (pdev->is_virtfn && pci_is_pcie(pdev->physfn)) + return NULL; + while (1) { if (pci_is_root_bus(pdev->bus)) break;