public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Assmann <sassmann@redhat.com>
To: linux-pci@vger.kernel.org
Cc: JBeulich@novell.com, linux-acpi@vger.kernel.org,
	Olaf.Dabrunz@gmx.net, Stefan Assmann <sassmann@redhat.com>,
	mingo@elte.hu, bjorn.helgaas@hp.com, tglx@linutronix.de,
	lenb@kernel.org
Subject: [PATCH 3/4] PCI: fix locking for pci_find_upstream_pcie_bridge and add declaration
Date: Thu, 18 Nov 2010 08:52:28 -0500	[thread overview]
Message-ID: <20101118135237.2269.96220.sendpatchset@localhost6.localdomain6> (raw)
In-Reply-To: <20101118135207.2269.2593.sendpatchset@localhost6.localdomain6>

From: Stefan Assmann <sassmann@redhat.com>

Add header declaration of pci_find_upstream_pcie_bridge to pci.h. This will
allow the boot interrupt reroute code, and others, to make use of this
implementation. Also pci_find_upstream_pcie_bridge should take the pci_bus_sem
semaphore while reading global PCI structures, so update the locking as well.

Signed-off-by: Stefan Assmann <sassmann@redhat.com>
---
 drivers/pci/search.c |    4 ++++
 include/linux/pci.h  |    3 +++
 2 files changed, 7 insertions(+), 0 deletions(-)

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)
-- 
1.7.1

  parent reply	other threads:[~2010-11-18 13:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 13:51 [PATCH 0/4] x86: boot interrupt reroute fix Stefan Assmann
2010-11-18 13:52 ` [PATCH 1/4] ACPI: move struct acpi_prt_entry to actbl1.h Stefan Assmann
2010-11-18 13:52 ` [PATCH 2/4] ACPI: make acpi_pci_irq_find_prt_entry return a copy of a prt_entry Stefan Assmann
2010-11-18 13:52 ` Stefan Assmann [this message]
2010-11-18 18:18   ` [PATCH 3/4] PCI: fix locking for pci_find_upstream_pcie_bridge and add declaration Jesse Barnes
2010-11-18 13:52 ` [PATCH 4/4] PCI, ACPI: re-add boot interrupt reroute code in separate files Stefan Assmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101118135237.2269.96220.sendpatchset@localhost6.localdomain6 \
    --to=sassmann@redhat.com \
    --cc=JBeulich@novell.com \
    --cc=Olaf.Dabrunz@gmx.net \
    --cc=bjorn.helgaas@hp.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox