mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Joerg.Roedel@amd.com, florian@dazinger.net
Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 3/5] amd_iommu: Split upstream bus device lookup
Date: Mon, 08 Oct 2012 22:49:48 -0600	[thread overview]
Message-ID: <20121009044948.16302.92834.stgit@bling.home> (raw)
In-Reply-To: <20121009044057.16302.44577.stgit@bling.home>

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 drivers/iommu/amd_iommu.c |   24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 6edbd0e..3a00b5ce 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -274,6 +274,18 @@ static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
 	*from = to;
 }
 
+static struct pci_bus *find_hosted_bus(struct pci_bus *bus)
+{
+	while (!bus->self) {
+		if (!pci_is_root_bus(bus))
+			bus = bus->parent;
+		else
+			return ERR_PTR(-ENODEV);
+	}
+
+	return bus;
+}
+
 #define REQ_ACS_FLAGS	(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF)
 
 static struct pci_dev *get_isolation_root(struct pci_dev *pdev)
@@ -300,14 +312,9 @@ static struct pci_dev *get_isolation_root(struct pci_dev *pdev)
 	 * Finding the next device may require skipping virtual buses.
 	 */
 	while (!pci_is_root_bus(dma_pdev->bus)) {
-		struct pci_bus *bus = dma_pdev->bus;
-
-		while (!bus->self) {
-			if (!pci_is_root_bus(bus))
-				bus = bus->parent;
-			else
-				goto root_bus;
-		}
+		struct pci_bus *bus = find_hosted_bus(dma_pdev->bus);
+		if (IS_ERR(bus))
+			break;
 
 		if (pci_acs_path_enabled(bus->self, NULL, REQ_ACS_FLAGS))
 			break;
@@ -315,7 +322,6 @@ static struct pci_dev *get_isolation_root(struct pci_dev *pdev)
 		swap_pci_ref(&dma_pdev, pci_dev_get(bus->self));
 	}
 
-root_bus:
 	return dma_pdev;
 }
 


  parent reply	other threads:[~2012-10-09  4:49 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-09  4:49 [RFC PATCH 0/5] amd_iommu: Refactor IOMMU group and support virtual aliases Alex Williamson
2012-10-09  4:49 ` [RFC PATCH 1/5] amd_iommu: Split IOMMU group initialization Alex Williamson
2012-10-09 14:33   ` Shuah Khan
2012-10-09 14:41     ` Alex Williamson
2012-10-09  4:49 ` [RFC PATCH 2/5] amd_iommu: Split IOMMU Group topology walk Alex Williamson
2012-10-09  4:49 ` Alex Williamson [this message]
2012-10-09  4:49 ` [RFC PATCH 4/5] amd_iommu: Split IOMMU group allocation and attach Alex Williamson
2012-10-09  4:50 ` [RFC PATCH 5/5] amd_iommu: Properly account for virtual aliases in IOMMU groups Alex Williamson
2012-10-09 18:27 ` [RFC PATCH 0/5] amd_iommu: Refactor IOMMU group and support virtual aliases Florian Dazinger
2012-10-09 18:35   ` Alex Williamson
2012-10-09 18:57     ` Florian Dazinger
2012-10-09 19:33       ` Alex Williamson
2012-10-18 21:29 ` Alex Williamson
2012-10-24 15:28   ` Joerg Roedel

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=20121009044948.16302.92834.stgit@bling.home \
    --to=alex.williamson@redhat.com \
    --cc=Joerg.Roedel@amd.com \
    --cc=florian@dazinger.net \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®