[PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP()

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE6893d

2 messages, 1 author, 2007-10-25 · open the first message on its own page

[PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP()

From: Michael Ellerman <hidden>
Date: 2007-10-24 04:24:20

The loop to check parent nodes for a dma-window property in
pci_dma_dev_setup_pSeriesLP() does not use the of_* accessors and
does not properly manage refcounts, fix it to do so.

Signed-off-by: Michael Ellerman <redacted>
---
 arch/powerpc/platforms/pseries/iommu.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index be17d23..2c6fc3f 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -481,7 +481,7 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
 
 static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 {
-	struct device_node *pdn, *dn;
+	struct device_node *pdn, *dn, *tmp;
 	struct iommu_table *tbl;
 	const void *dma_window = NULL;
 	struct pci_dn *pci;
@@ -497,18 +497,22 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	dn = pci_device_to_OF_node(dev);
 	DBG("  node is %s\n", dn->full_name);
 
-	for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
-	     pdn = pdn->parent) {
+	pdn = of_node_get(dn);
+	while (pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table) {
 		dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
 		if (dma_window)
 			break;
+
+		tmp = of_get_parent(pdn);
+		of_node_put(pdn);
+		pdn = tmp;
 	}
 
 	if (!pdn || !PCI_DN(pdn)) {
 		printk(KERN_WARNING "pci_dma_dev_setup_pSeriesLP: "
 		       "no DMA window found for pci dev=%s dn=%s\n",
 				 pci_name(dev), dn? dn->full_name : "<null>");
-		return;
+		goto out_put;
 	}
 	DBG("  parent is %s\n", pdn->full_name);
 
@@ -518,7 +522,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	if (dma_window == NULL || pdn->parent == NULL) {
 		DBG("  no dma window for device, linking to parent\n");
 		dev->dev.archdata.dma_data = PCI_DN(pdn)->iommu_table;
-		return;
+		goto out_put;
 	}
 
 	pci = PCI_DN(pdn);
@@ -538,6 +542,9 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
 	}
 
 	dev->dev.archdata.dma_data = pci->iommu_table;
+
+out_put:
+	of_node_put(pdn);
 }
 #else  /* CONFIG_PCI */
 #define pci_dma_bus_setup_pSeries	NULL
-- 
1.5.1.3.g7a33b

Re: [PATCH] Use of_get_parent() in pci_dma_dev_setup_pSeriesLP()

From: Michael Ellerman <hidden>
Date: 2007-10-25 01:46:13

On Wed, 2007-10-24 at 14:24 +1000, Michael Ellerman wrote:
The loop to check parent nodes for a dma-window property in
pci_dma_dev_setup_pSeriesLP() does not use the of_* accessors and
does not properly manage refcounts, fix it to do so.

Signed-off-by: Michael Ellerman <redacted>
---
 arch/powerpc/platforms/pseries/iommu.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
I'm starting to make a habit of this .. but nack.

Stephen points out that there are several other places in this file that
need fixing up, so I'll do them all as one series.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help