diff mbox

[2/2] MIPS: implement pcibios_get_phb_of_node

Message ID 1365098483-26821-2-git-send-email-juhosg@openwrt.org
State Accepted
Headers show

Commit Message

Gabor Juhos April 4, 2013, 6:01 p.m. UTC
The of_node field of the device assigned to a
PCI bus is used during scanning of the PCI bus.
However on MIPS, the of_node field is assigned
only after the bus has been scanned.

Implement the architecture specific version of
'pcibios_get_phb_of_node'. Which ensures that the
PCI driver core will initialize the of_node field
before starting the scan.

Also remove the local assignment of bus->dev.of_node,
it is not needed after the patch.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/pci/pci.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Bjorn Helgaas April 10, 2013, 4:31 p.m. UTC | #1
On Thu, Apr 4, 2013 at 12:01 PM, Gabor Juhos <juhosg@openwrt.org> wrote:
> The of_node field of the device assigned to a
> PCI bus is used during scanning of the PCI bus.
> However on MIPS, the of_node field is assigned
> only after the bus has been scanned.
>
> Implement the architecture specific version of
> 'pcibios_get_phb_of_node'. Which ensures that the
> PCI driver core will initialize the of_node field
> before starting the scan.
>
> Also remove the local assignment of bus->dev.of_node,
> it is not needed after the patch.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

I removed the __weak annotation from include/linux/pci.h and applied
this patch to my pci/gabor-get-of-node.  Give it a try and make sure
it solves your problem.  If so, and Ralph approves, I can push both
for v3.10.  It should appear at
http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/gabor-get-of-node
soon.

Or if you prefer, you can take them through the MIPS tree.

Bjorn

> ---
>  arch/mips/pci/pci.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
> index 0872f12..594e60d 100644
> --- a/arch/mips/pci/pci.c
> +++ b/arch/mips/pci/pci.c
> @@ -115,7 +115,6 @@ static void pcibios_scanbus(struct pci_controller *hose)
>                         pci_bus_assign_resources(bus);
>                         pci_enable_bridges(bus);
>                 }
> -               bus->dev.of_node = hose->of_node;
>         }
>  }
>
> @@ -169,6 +168,13 @@ void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node)
>                 }
>         }
>  }
> +
> +struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
> +{
> +       struct pci_controller *hose = bus->sysdata;
> +
> +       return of_node_get(hose->of_node);
> +}
>  #endif
>
>  static DEFINE_MUTEX(pci_scan_mutex);
> --
> 1.7.10
>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gabor Juhos April 11, 2013, 5:32 p.m. UTC | #2
2013.04.10. 18:31 keltezéssel, Bjorn Helgaas írta:
> On Thu, Apr 4, 2013 at 12:01 PM, Gabor Juhos <juhosg@openwrt.org> wrote:
>> The of_node field of the device assigned to a
>> PCI bus is used during scanning of the PCI bus.
>> However on MIPS, the of_node field is assigned
>> only after the bus has been scanned.
>>
>> Implement the architecture specific version of
>> 'pcibios_get_phb_of_node'. Which ensures that the
>> PCI driver core will initialize the of_node field
>> before starting the scan.
>>
>> Also remove the local assignment of bus->dev.of_node,
>> it is not needed after the patch.
>>
>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> 
> I removed the __weak annotation from include/linux/pci.h and applied
> this patch to my pci/gabor-get-of-node.

Thank you!

> Give it a try and make sure
> it solves your problem.  If so, and Ralph approves, I can push both
> for v3.10.  It should appear at
> http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/gabor-get-of-node
> soon.

I have tried your patch on top of 3.9-rc6. The resulting kernel uses the
architecture specific implementation, and it runs fine.

  $ mipsel-openwrt-linux-readelf -s arch/mips/pci/built-in.o \
    drivers/pci/built-in.o vmlinux.o | grep pcibios_get_phb_of_node
      93: 0000046c    12 FUNC    GLOBAL DEFAULT    2 pcibios_get_phb_of_node
    1433: 00012a2c   104 FUNC    WEAK   DEFAULT    2 pcibios_get_phb_of_node
   31863: 001d4dbc    12 FUNC    GLOBAL DEFAULT    2 pcibios_get_phb_of_node
  $

For completeness, I have compiled it for X64 and for powerpc as well. I did not
try to run these kernels, but the output of readelf seems to be ok:

  $ readelf -s arch/x86/kernel/built-in.o drivers/pci/built-in.o vmlinux.o | \
    grep pcibios_get_phb_of_node
    2761: 000273a0    86 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
    1705: 00018770    77 FUNC    WEAK   DEFAULT    1 pcibios_get_phb_of_node
   60364: 000278a0    86 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
  $

  $ powerpc-openwrt-linux-readelf -s arch/powerpc/kernel/built-in.o \
    drivers/pci/built-in.o  vmlinux.o | grep pcibios_get_phb_of_node
    1002: 0000ca28    12 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
    1485: 0001453c    88 FUNC    WEAK   DEFAULT    1 pcibios_get_phb_of_node
   28959: 0000d598    12 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
  $

> Or if you prefer, you can take them through the MIPS tree.

Either is fine.

-Gabor
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas April 11, 2013, 5:35 p.m. UTC | #3
On Thu, Apr 11, 2013 at 11:32 AM, Gabor Juhos <juhosg@openwrt.org> wrote:
> 2013.04.10. 18:31 keltezéssel, Bjorn Helgaas írta:
>> On Thu, Apr 4, 2013 at 12:01 PM, Gabor Juhos <juhosg@openwrt.org> wrote:
>>> The of_node field of the device assigned to a
>>> PCI bus is used during scanning of the PCI bus.
>>> However on MIPS, the of_node field is assigned
>>> only after the bus has been scanned.
>>>
>>> Implement the architecture specific version of
>>> 'pcibios_get_phb_of_node'. Which ensures that the
>>> PCI driver core will initialize the of_node field
>>> before starting the scan.
>>>
>>> Also remove the local assignment of bus->dev.of_node,
>>> it is not needed after the patch.
>>>
>>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
>>
>> I removed the __weak annotation from include/linux/pci.h and applied
>> this patch to my pci/gabor-get-of-node.
>
> Thank you!
>
>> Give it a try and make sure
>> it solves your problem.  If so, and Ralph approves, I can push both
>> for v3.10.  It should appear at
>> http://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/gabor-get-of-node
>> soon.
>
> I have tried your patch on top of 3.9-rc6. The resulting kernel uses the
> architecture specific implementation, and it runs fine.
>
>   $ mipsel-openwrt-linux-readelf -s arch/mips/pci/built-in.o \
>     drivers/pci/built-in.o vmlinux.o | grep pcibios_get_phb_of_node
>       93: 0000046c    12 FUNC    GLOBAL DEFAULT    2 pcibios_get_phb_of_node
>     1433: 00012a2c   104 FUNC    WEAK   DEFAULT    2 pcibios_get_phb_of_node
>    31863: 001d4dbc    12 FUNC    GLOBAL DEFAULT    2 pcibios_get_phb_of_node
>   $
>
> For completeness, I have compiled it for X64 and for powerpc as well. I did not
> try to run these kernels, but the output of readelf seems to be ok:
>
>   $ readelf -s arch/x86/kernel/built-in.o drivers/pci/built-in.o vmlinux.o | \
>     grep pcibios_get_phb_of_node
>     2761: 000273a0    86 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
>     1705: 00018770    77 FUNC    WEAK   DEFAULT    1 pcibios_get_phb_of_node
>    60364: 000278a0    86 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
>   $
>
>   $ powerpc-openwrt-linux-readelf -s arch/powerpc/kernel/built-in.o \
>     drivers/pci/built-in.o  vmlinux.o | grep pcibios_get_phb_of_node
>     1002: 0000ca28    12 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
>     1485: 0001453c    88 FUNC    WEAK   DEFAULT    1 pcibios_get_phb_of_node
>    28959: 0000d598    12 FUNC    GLOBAL DEFAULT    1 pcibios_get_phb_of_node
>   $
>
>> Or if you prefer, you can take them through the MIPS tree.
>
> Either is fine.

Thanks for checking these out!  I put them in my "next" branch and
pushed it, so they should appear in v3.10.

Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Gabor Juhos April 11, 2013, 5:39 p.m. UTC | #4
2013.04.11. 19:35 keltezéssel, Bjorn Helgaas írta:

> Thanks for checking these out!  I put them in my "next" branch and
> pushed it, so they should appear in v3.10.

Great. Thank you!

-Gabor
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 0872f12..594e60d 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -115,7 +115,6 @@  static void pcibios_scanbus(struct pci_controller *hose)
 			pci_bus_assign_resources(bus);
 			pci_enable_bridges(bus);
 		}
-		bus->dev.of_node = hose->of_node;
 	}
 }
 
@@ -169,6 +168,13 @@  void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node)
 		}
 	}
 }
+
+struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
+{
+	struct pci_controller *hose = bus->sysdata;
+
+	return of_node_get(hose->of_node);
+}
 #endif
 
 static DEFINE_MUTEX(pci_scan_mutex);