iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu: narrow the search range by iterating on current bus
@ 2016-07-28 14:52 Wei Yang
       [not found] ` <1469717579-8244-1-git-send-email-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Wei Yang @ 2016-07-28 14:52 UTC (permalink / raw)
  To: jroedel-l3A5Bk7waGM, alex.williamson-H+wXaHxf7aLQT0dZR+AlfA
  Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

According to the comments and code, get_pci_function_alias_group() and
get_pci_alias_group() do the search on the same pci bus. This means we can
just iterate on the bus the pci device attaches to.

This patch narrows the search range by just iterating on the current bus
and fix one typo in comment.

Signed-off-by: Wei Yang <richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/iommu/iommu.c |   22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3000051..0338a81 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -643,17 +643,15 @@ static struct iommu_group *get_pci_function_alias_group(struct pci_dev *pdev,
 	if (!pdev->multifunction || pci_acs_enabled(pdev, REQ_ACS_FLAGS))
 		return NULL;
 
-	for_each_pci_dev(tmp) {
-		if (tmp == pdev || tmp->bus != pdev->bus ||
+	list_for_each_entry(tmp, &pdev->bus->devices, bus_list) {
+		if (tmp == pdev ||
 		    PCI_SLOT(tmp->devfn) != PCI_SLOT(pdev->devfn) ||
 		    pci_acs_enabled(tmp, REQ_ACS_FLAGS))
 			continue;
 
 		group = get_pci_alias_group(tmp, devfns);
-		if (group) {
-			pci_dev_put(tmp);
+		if (group)
 			return group;
-		}
 	}
 
 	return NULL;
@@ -681,23 +679,19 @@ static struct iommu_group *get_pci_alias_group(struct pci_dev *pdev,
 	if (group)
 		return group;
 
-	for_each_pci_dev(tmp) {
-		if (tmp == pdev || tmp->bus != pdev->bus)
+	list_for_each_entry(tmp, &pdev->bus->devices, bus_list) {
+		if (tmp == pdev)
 			continue;
 
 		/* We alias them or they alias us */
 		if (pci_devs_are_dma_aliases(pdev, tmp)) {
 			group = get_pci_alias_group(tmp, devfns);
-			if (group) {
-				pci_dev_put(tmp);
+			if (group)
 				return group;
-			}
 
 			group = get_pci_function_alias_group(tmp, devfns);
-			if (group) {
-				pci_dev_put(tmp);
+			if (group)
 				return group;
-			}
 		}
 	}
 
@@ -794,7 +788,7 @@ struct iommu_group *pci_device_group(struct device *dev)
 
 	/*
 	 * Look for existing groups on non-isolated functions on the same
-	 * slot and aliases of those funcions, if any.  No need to clear
+	 * slot and aliases of those functions, if any. No need to clear
 	 * the search bitmap, the tested devfns are still valid.
 	 */
 	group = get_pci_function_alias_group(pdev, (unsigned long *)devfns);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-09-28 19:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-28 14:52 [PATCH] iommu: narrow the search range by iterating on current bus Wei Yang
     [not found] ` <1469717579-8244-1-git-send-email-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-07-28 15:01   ` Alex Williamson
     [not found]     ` <20160728090132.42c6ebc1-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2016-08-05 13:47       ` [PATCH 1/2] PCI: add a function to walk on local bus Wei Yang
     [not found]         ` <1470404867-26783-1-git-send-email-richard.weiyang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-05 13:47           ` [PATCH 2/2] iommu: narrow the search range by iterating on current bus Wei Yang
2016-08-05 14:03       ` [PATCH] " Wei Yang
     [not found]         ` <20160805140317.GA26921-yrDqe6+Pica9sAcnBtTtJQ@public.gmane.org>
2016-08-18 23:00           ` Wei Yang
     [not found]             ` <20160818230026.GA2631-yrDqe6+Pica9sAcnBtTtJQ@public.gmane.org>
2016-09-28 19:51               ` Wei Yang

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