ARM: pci: pass a parent to pci_common_init()
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 ARM: pci: pass a parent to pci_common_init()
Quoted 17 lines · Linus Walleij
When working with device tree support for PCI on ARM you run into a problem when mapping IRQs from the device tree irqmaps:
doing this the code indrivers/of/of_pci_irq.cwill try to find the OF node on the root bridge and this fails, becausebus->dev.of_nodeis NULL, and that in turn boils down to the fact thatpci_set_bus_of_node()has calledpcibios_get_phb_of_node()fromdrivers/pci/of.cto obtain the OF node of the bridge or its parent and none is set and thus NULL is returned.Fix this by adding an additional parent argument when registering PCI bridges on the ARM architecture using the
pci_common_init()call, and pass along this parent topci_scan_root_bus()called frompcibios_init_hw()inbios32.cand voila: the IRQ mappings start working:
the OF node can be retrieved from the parent.
Quoted 3 lines
Currently all users are set to use NULL as argument to this call, but subsequent patches to the Integrator/AP make use of this facility to pass a parent.
Could you try making it a less invasive patch by renaming pci_common_init to something else and providing a wrapper like this?
static inline void pci_common_init(struct hw_pci *hw)
{
pci_common_init_dev(NULL, hw);
}That would avoid most of the churn and get the same result.
Arnd
PATCH 1/1 ARM: pci: pass a parent to pci_common_init()
Quoted 26 lines · Arnd Bergmann
Quoted 17 lines · Linus Walleij
When working with device tree support for PCI on ARM you run into a problem when mapping IRQs from the device tree irqmaps:
doing this the code indrivers/of/of_pci_irq.cwill try to find the OF node on the root bridge and this fails, becausebus->dev.of_nodeis NULL, and that in turn boils down to the fact thatpci_set_bus_of_node()has calledpcibios_get_phb_of_node()fromdrivers/pci/of.cto obtain the OF node of the bridge or its parent and none is set and thus NULL is returned.Fix this by adding an additional parent argument when registering PCI bridges on the ARM architecture using the
pci_common_init()call, and pass along this parent topci_scan_root_bus()called frompcibios_init_hw()inbios32.cand voila: the IRQ mappings start working:
the OF node can be retrieved from the parent.Quoted 3 lines
Currently all users are set to use NULL as argument to this call, but subsequent patches to the Integrator/AP make use of this facility to pass a parent.
Could you try making it a less invasive patch by renaming
pci_common_initto something else and providing a wrapper like this?
Quoted 9 lines
static inline void
pci_common_init(struct hw_pci *hw){ pci_common_init_dev(NULL, hw); }That would avoid most of the churn and get the same result.
Arnd
I would also be happy with this. Though alternatively could you not just add a struct device to hw_pci? Then change pcibios_init_hw to use hw->device instead of NULL?
Andrew Murray
PATCH 1/1 ARM: pci: pass a parent to pci_common_init()
Quoted 4 lines · Andrew Murray
I would also be happy with this. Though alternatively could you not just add a struct device to
hw_pci? Then changepcibios_init_hwto usehw->deviceinstead of NULL?
I think struct hw_pci is meant to be statically defined, so that would not work if you need the same hw_pci for two host bridge devices.
Arnd
PATCH 1/1 ARM: pci: pass a parent to pci_common_init()
Quoted 11 lines · Arnd Bergmann
Quoted 4 lines · Andrew Murray
I would also be happy with this. Though alternatively could you not just add a struct device to
hw_pci? Then changepcibios_init_hwto usehw->deviceinstead of NULL?I think struct
hw_pciis meant to be statically defined, so that would not work if you need the samehw_pcifor two host bridge devices.Arnd
Yes, though the new PCIe host/bridge drivers with DT support all seem to call pci_common_init at probe with a non-statically defined hw_pci with the nr_controllers always set to 1 (meaning that pci_common_init can be called multiple times). Also hw_pci now has a field for private_data anyway which breaks this assumption...
Is there an argument for removing hw_pci or at least .nr_controllers and call pci_common_init multiple times (as is potential current use case for DT PCI drivers)?
Andrew Murray
PATCH 1/1 ARM: pci: pass a parent to pci_common_init()
Quoted 9 lines · Andrew Murray
Yes, though the new PCIe host/bridge drivers with DT support all seem to call
pci_common_initat probe with a non-statically definedhw_pciwith thenr_controllersalways set to 1 (meaning thatpci_common_initcan be called multiple times). Alsohw_pcinow has a field forprivate_dataanyway which breaks this assumption...Is there an argument for removing
hw_pcior at least .nr_controllers and callpci_common_initmultiple times (as is potential current use case for DT PCI drivers)?
Well, I notice that there's bunches of code which have been introduced post my cleanup of the PCI stuff which insist on doing their stuff using the pre-cleanup ways... I guess I need to go through and fix peoples stuff up again in this area when I finish reading the mail backlog...
The idea behind bios32.c is that all buses get scanned and _then_ setup, rather than each get scanned and setup in sequence. This allows for a variety of setups where the buses may share a space - it allows the scan to be done, then the postinit hook to be called which can then do any post-processing prior to resources being setup.
PATCH 1/1 ARM: pci: pass a parent to pci_common_init()
In reply to Arnd BergmannQuoted 8 lines · Arnd Bergmann
Quoted 4 lines · Andrew Murray
I would also be happy with this. Though alternatively could you not just add a struct device to
hw_pci? Then changepcibios_init_hwto usehw->deviceinstead of NULL?I think struct
hw_pciis meant to be statically defined, so that would not work if you need the samehw_pcifor two host bridge devices.
The hw_pci structure is only referenced by the setup functions, and never referred to again. Anything of any relevance that is needed later is copied out of that structure into others (like pci_sys_data).