From patchwork Thu Dec 2 15:33:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Assmann X-Patchwork-Id: 374851 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 oB2FYefv021999 for ; Thu, 2 Dec 2010 15:35:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932188Ab0LBPfE (ORCPT ); Thu, 2 Dec 2010 10:35:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15803 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932118Ab0LBPfD (ORCPT ); Thu, 2 Dec 2010 10:35:03 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB2FXml5023693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Dec 2010 10:33:49 -0500 Received: from localhost6.localdomain6 (vpn2-8-127.ams2.redhat.com [10.36.8.127]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB2FXjLP006343; Thu, 2 Dec 2010 10:33:46 -0500 Date: Thu, 2 Dec 2010 10:33:45 -0500 From: Stefan Assmann To: linux-acpi@vger.kernel.org Cc: lenb@kernel.org, linux-pci@vger.kernel.org, JBeulich@novell.com, jbarnes@virtuousgeek.org, Stefan Assmann , mingo@elte.hu, bjorn.helgaas@hp.com, tglx@linutronix.de, Olaf.Dabrunz@gmx.net Message-Id: <20101202153411.29125.10231.sendpatchset@localhost6.localdomain6> In-Reply-To: <20101202153344.29125.86670.sendpatchset@localhost6.localdomain6> References: <20101202153344.29125.86670.sendpatchset@localhost6.localdomain6> Subject: [PATCH 3/5 v2] PCI: Add locking to pci_find_upstream_pcie_bridge() X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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, 02 Dec 2010 15:35:06 +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; }