Patchwork [v2] powerpc/pci: clean up direct access to sysdata by iseries platform

login
register
mail settings
Submitter Kumar Gala
Date May 15, 2009, 12:47 p.m.
Message ID <1242391640-18826-1-git-send-email-galak@kernel.crashing.org>
Download mbox | patch
Permalink /patch/27250/
State Superseded, archived
Delegated to: Benjamin Herrenschmidt
Headers show

Comments

Kumar Gala - May 15, 2009, 12:47 p.m.
We shouldn't directly access sysdata to get the device node.  We should
be calling pci_device_to_OF_node().

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
* Updated based on sfr's iseries pci fix patch

 arch/powerpc/platforms/iseries/iommu.c |    2 +-
 arch/powerpc/platforms/iseries/pci.c   |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
Kumar Gala - May 15, 2009, 12:50 p.m.
On May 15, 2009, at 7:47 AM, Kumar Gala wrote:

> We shouldn't directly access sysdata to get the device node.  We  
> should
> be calling pci_device_to_OF_node().
>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> * Updated based on sfr's iseries pci fix patch
>
> arch/powerpc/platforms/iseries/iommu.c |    2 +-
> arch/powerpc/platforms/iseries/pci.c   |    8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)

Stephen if you can test this version that would be great.

thanks

- k
Benjamin Herrenschmidt - May 18, 2009, 7:05 a.m.
On Fri, 2009-05-15 at 07:50 -0500, Kumar Gala wrote:
> On May 15, 2009, at 7:47 AM, Kumar Gala wrote:
> 
> > We shouldn't directly access sysdata to get the device node.  We  
> > should
> > be calling pci_device_to_OF_node().
> >
> > Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> > ---
> > * Updated based on sfr's iseries pci fix patch
> >
> > arch/powerpc/platforms/iseries/iommu.c |    2 +-
> > arch/powerpc/platforms/iseries/pci.c   |    8 ++++----
> > 2 files changed, 5 insertions(+), 5 deletions(-)
> 
> Stephen if you can test this version that would be great.

Fails with:

/home/benh/linux-powerpc-test/arch/powerpc/platforms/iseries/iommu.c: In function ‘pci_dma_dev_setup_iseries’:
/home/benh/linux-powerpc-test/arch/powerpc/platforms/iseries/iommu.c:180: error: ‘dev’ undeclared (first use in this function)
/home/benh/linux-powerpc-test/arch/powerpc/platforms/iseries/iommu.c:180: error: (Each undeclared identifier is reported only once
/home/benh/linux-powerpc-test/arch/powerpc/platforms/iseries/iommu.c:180: error: for each function it appears in.)

(I suspect it should have been "pdev" instead of "dev")

Cheers,
Ben.

Patch

diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index 4021982..224913a 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -177,7 +177,7 @@  static struct iommu_table *iommu_table_find(struct iommu_table * tbl)
 static void pci_dma_dev_setup_iseries(struct pci_dev *pdev)
 {
 	struct iommu_table *tbl;
-	struct device_node *dn = pdev->sysdata;
+	struct device_node *dn = pci_device_to_OF_node(dev);
 	struct pci_dn *pdn = PCI_DN(dn);
 	const u32 *lsn = of_get_property(dn, "linux,logical-slot-number", NULL);
 
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index 21cddc3..175aac8 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -318,6 +318,7 @@  static void __init iomm_table_allocate_entry(struct pci_dev *dev, int bar_num)
 {
 	struct resource *bar_res = &dev->resource[bar_num];
 	long bar_size = pci_resource_len(dev, bar_num);
+	struct device_node *dn = pci_device_to_OF_node(dev);
 
 	/*
 	 * No space to allocate, quick exit, skip Allocation.
@@ -335,9 +336,9 @@  static void __init iomm_table_allocate_entry(struct pci_dev *dev, int bar_num)
 	 * Allocate the number of table entries needed for BAR.
 	 */
 	while (bar_size > 0 ) {
-		iomm_table[current_iomm_table_entry] = dev->sysdata;
+		iomm_table[current_iomm_table_entry] = dn;
 		ds_addr_table[current_iomm_table_entry] =
-			iseries_ds_addr(dev->sysdata) | (bar_num << 24);
+			iseries_ds_addr(dn) | (bar_num << 24);
 		bar_size -= IOMM_TABLE_ENTRY_SIZE;
 		++current_iomm_table_entry;
 	}
@@ -410,7 +411,7 @@  void __init iSeries_pcibios_fixup_resources(struct pci_dev *pdev)
 	struct device_node *node;
 	int i;
 
-	node = find_device_node(bus, pdev->devfn);
+	node = pci_device_to_OF_node(pdev);
 	pr_debug("PCI: iSeries %s, pdev %p, node %p\n",
 		 pci_name(pdev), pdev, node);
 	if (!node) {
@@ -441,7 +442,6 @@  void __init iSeries_pcibios_fixup_resources(struct pci_dev *pdev)
 		}
 	}
 
-	pdev->sysdata = node;
 	allocate_device_bars(pdev);
 	iseries_device_information(pdev, bus, *sub_bus);
 }