From: Alex Williamson <alex.williamson@redhat.com>
To: bhelgaas@google.com
Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
dsahern@gmail.com
Subject: [PATCH] pci: Account for virtual buses in pci_acs_path_enabled
Date: Sat, 04 Aug 2012 12:19:29 -0600 [thread overview]
Message-ID: <20120804181445.6598.6505.stgit@bling.home> (raw)
It's possible to have buses without an associated bridge
(bus->self == NULL). SR-IOV can generate such buses. When
we find these, skip to the parent bus to look for the next
ACS test.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
David Ahern reported an oops from iommu drivers passing NULL into
this function for the same mistake. Harden this function against
assuming bus->self is valid as well. David, please include this
patch as well as the iommu patches in your testing.
drivers/pci/pci.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f3ea977..e11a49c 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2486,18 +2486,30 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags)
bool pci_acs_path_enabled(struct pci_dev *start,
struct pci_dev *end, u16 acs_flags)
{
- struct pci_dev *pdev, *parent = start;
+ struct pci_dev *pdev = start;
+ struct pci_bus *bus;
do {
- pdev = parent;
-
if (!pci_acs_enabled(pdev, acs_flags))
return false;
- if (pci_is_root_bus(pdev->bus))
+ bus = pdev->bus;
+
+ if (pci_is_root_bus(bus))
return (end == NULL);
- parent = pdev->bus->self;
+ /*
+ * Skip buses without an associated bridge. In this
+ * case move to the parent and continue.
+ */
+ while (!bus->self) {
+ if (!pci_is_root_bus(bus))
+ bus = bus->parent;
+ else
+ return (end == NULL);
+ }
+
+ pdev = bus->self;
} while (pdev != end);
return true;
next reply other threads:[~2012-08-04 18:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-04 18:19 Alex Williamson [this message]
2012-08-06 4:51 ` [PATCH] pci: Account for virtual buses in pci_acs_path_enabled David Ahern
2012-08-06 5:30 ` Bjorn Helgaas
2012-08-06 5:55 ` Alex Williamson
2012-08-06 20:47 ` Bjorn Helgaas
2012-08-07 21:50 ` Don Dutile
2012-08-08 6:00 ` Bjorn Helgaas
2012-08-08 13:51 ` David Ahern
2012-08-08 15:24 ` Alex Williamson
2012-08-08 19:33 ` Don Dutile
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=20120804181445.6598.6505.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=dsahern@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).