From patchwork Thu Nov 18 13:52:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Assmann X-Patchwork-Id: 336261 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAIDrXLT011244 for ; Thu, 18 Nov 2010 13:53:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757997Ab0KRNxx (ORCPT ); Thu, 18 Nov 2010 08:53:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20338 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757965Ab0KRNxw (ORCPT ); Thu, 18 Nov 2010 08:53:52 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAIDqYV0007284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Nov 2010 08:52:34 -0500 Received: from localhost6.localdomain6 ([10.3.112.18]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAIDqSSo007369; Thu, 18 Nov 2010 08:52:29 -0500 Date: Thu, 18 Nov 2010 08:52:28 -0500 From: Stefan Assmann To: linux-pci@vger.kernel.org Cc: JBeulich@novell.com, linux-acpi@vger.kernel.org, Olaf.Dabrunz@gmx.net, Stefan Assmann , mingo@elte.hu, bjorn.helgaas@hp.com, tglx@linutronix.de, lenb@kernel.org Message-Id: <20101118135237.2269.96220.sendpatchset@localhost6.localdomain6> In-Reply-To: <20101118135207.2269.2593.sendpatchset@localhost6.localdomain6> References: <20101118135207.2269.2593.sendpatchset@localhost6.localdomain6> Subject: [PATCH 3/4] PCI: fix locking for pci_find_upstream_pcie_bridge and add declaration X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 18 Nov 2010 13:53:54 +0000 (UTC) diff --git a/drivers/pci/search.c b/drivers/pci/search.c index 9d75dc8..c8159b0 100644 --- a/drivers/pci/search.c +++ b/drivers/pci/search.c @@ -29,6 +29,8 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) if (pci_is_pcie(pdev)) return NULL; + + down_read(&pci_bus_sem); while (1) { if (pci_is_root_bus(pdev->bus)) break; @@ -38,6 +40,7 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) tmp = pdev; continue; } + up_read(&pci_bus_sem); /* PCI device should connect to a PCIe bridge */ if (pdev->pcie_type != PCI_EXP_TYPE_PCI_BRIDGE) { /* Busted hardware? */ @@ -46,6 +49,7 @@ pci_find_upstream_pcie_bridge(struct pci_dev *pdev) } return pdev; } + up_read(&pci_bus_sem); return tmp; } diff --git a/include/linux/pci.h b/include/linux/pci.h index 7454408..7acb6b2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -698,6 +698,7 @@ int pci_bus_find_ext_capability(struct pci_bus *bus, unsigned int devfn, int pci_find_ht_capability(struct pci_dev *dev, int ht_cap); int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap); struct pci_bus *pci_find_next_bus(const struct pci_bus *from); +struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev); struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from); @@ -1208,6 +1209,8 @@ static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) { return NULL; } +static inline struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev) +{ return NULL; } static inline struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn)