Message ID | 1438721620-15493-1-git-send-email-jchandra@broadcom.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Aug 05, 2015 at 02:23:38AM +0530, Jayachandran C wrote: > The current code in pci-host-generic.c uses pci_common_init_dev() > from arm architecture to do some part of the PCI setup, and this > prevents it from being used with arm64 architecture. > > The part of pci_common_init_dev() that is really needed by > pci-host-generic.c is very limited and can be done in the same > file without using hw_pci API of ARM. The ARM platform requires > a pci_sys_data as sysdata for the PCI bus, this can be handled by > setting up gen_pci to have a pci_sys_data variable as the first > element. > > Signed-off-by: Jayachandran C <jchandra@broadcom.com> > Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> > Tested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> > Tested-by: Pavel Fedin <p.fedin@samsung.com> I applied all three of these to my pci/enumeration branch for v4.3. I made a few changes, the most important being to call pcie_bus_configure_settings() before pci_bus_add_devices(), because drivers may claim devices in pci_bus_add_devices(), and the PCI core shouldn't touch devices after drivers claim them. I dropped the acks and tested-by because of that change, but I'll happily add them back if Lorenzo and Pavel confirm. The patches are here if you want to review/test them: https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/enumeration I'm sure the other patches on that branch will need some tweaks, too, so I don't have any problem with updating these. Bjorn
Hello! > I dropped the acks and tested-by because of that change, but I'll happily > add them back if Lorenzo and Pavel confirm. Confirm. Tested-by: Pavel Fedin <p.fedin@samsung.com> I also added MSI support. Can i post it as patch on top of your branch? Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia
On Wed, Aug 12, 2015 at 08:11:29AM +0100, Pavel Fedin wrote: > Hello! Hi Pavel, > > I dropped the acks and tested-by because of that change, but I'll happily > > add them back if Lorenzo and Pavel confirm. > > Confirm. > Tested-by: Pavel Fedin <p.fedin@samsung.com> > > I also added MSI support. Can i post it as patch on top of your branch? There shouldn't be any need with the changes queued in tip/irq/core. Can you give the following branch a go, please (it doesn't look like Bjorn's stuff is in linux-next, unfortunately)? git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git devel It's a temporary testing branch (subject to rebasing), but it should be indicative of what's queued for 4.3. Will
On Wed, Aug 05, 2015 at 12:49:56AM +0100, Bjorn Helgaas wrote: > On Wed, Aug 05, 2015 at 02:23:38AM +0530, Jayachandran C wrote: > > The current code in pci-host-generic.c uses pci_common_init_dev() > > from arm architecture to do some part of the PCI setup, and this > > prevents it from being used with arm64 architecture. > > > > The part of pci_common_init_dev() that is really needed by > > pci-host-generic.c is very limited and can be done in the same > > file without using hw_pci API of ARM. The ARM platform requires > > a pci_sys_data as sysdata for the PCI bus, this can be handled by > > setting up gen_pci to have a pci_sys_data variable as the first > > element. > > > > Signed-off-by: Jayachandran C <jchandra@broadcom.com> > > Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> > > Tested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> > > Tested-by: Pavel Fedin <p.fedin@samsung.com> > > I applied all three of these to my pci/enumeration branch for v4.3. > > I made a few changes, the most important being to call > pcie_bus_configure_settings() before pci_bus_add_devices(), because drivers > may claim devices in pci_bus_add_devices(), and the PCI core shouldn't > touch devices after drivers claim them. > > I dropped the acks and tested-by because of that change, but I'll happily > add them back if Lorenzo and Pavel confirm. The patches are here if you > want to review/test them: > > https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/enumeration > I am happy with your changes so you can certainly add my acked-by/tested-by tags back, with thanks. Thank you ! Lorenzo > I'm sure the other patches on that branch will need some tweaks, too, so I > don't have any problem with updating these.
Hello! > > I also added MSI support. Can i post it as patch on top of your branch? > > There shouldn't be any need with the changes queued in tip/irq/core. Can > you give the following branch a go, please (it doesn't look like Bjorn's > stuff is in linux-next, unfortunately)? > > git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git devel I have checked, they already implemented generic handling for "msi-parent" property in the device tree, and MSI works out of the box. Kind regards, Pavel Fedin Expert Engineer Samsung Electronics Research center Russia
On Wed, Aug 12, 2015 at 10:04:50AM +0100, Will Deacon wrote: > On Wed, Aug 12, 2015 at 08:11:29AM +0100, Pavel Fedin wrote: > > > I dropped the acks and tested-by because of that change, but I'll happily > > > add them back if Lorenzo and Pavel confirm. > > > > Confirm. > > Tested-by: Pavel Fedin <p.fedin@samsung.com> > > > > I also added MSI support. Can i post it as patch on top of your branch? > > There shouldn't be any need with the changes queued in tip/irq/core. Can > you give the following branch a go, please (it doesn't look like Bjorn's > stuff is in linux-next, unfortunately)? We still have a build issue (undefined reference to pci_write_msi_msg in imx_v6_v7_defconfig) to resolve before putting it in linux-next. Hopefully we can resolve that today.
Hi Bjorn, On Fri, Aug 14, 2015 at 03:46:44PM +0100, Bjorn Helgaas wrote: > On Wed, Aug 12, 2015 at 10:04:50AM +0100, Will Deacon wrote: > > On Wed, Aug 12, 2015 at 08:11:29AM +0100, Pavel Fedin wrote: > > > > I dropped the acks and tested-by because of that change, but I'll happily > > > > add them back if Lorenzo and Pavel confirm. > > > > > > Confirm. > > > Tested-by: Pavel Fedin <p.fedin@samsung.com> > > > > > > I also added MSI support. Can i post it as patch on top of your branch? > > > > There shouldn't be any need with the changes queued in tip/irq/core. Can > > you give the following branch a go, please (it doesn't look like Bjorn's > > stuff is in linux-next, unfortunately)? > > We still have a build issue (undefined reference to pci_write_msi_msg > in imx_v6_v7_defconfig) to resolve before putting it in linux-next. > Hopefully we can resolve that today. I have sent you a fix for that, please let me know if that's ok with you or you want me to rework it. Thanks, Lorenzo
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c index ba46e58..53703e3 100644 --- a/drivers/pci/host/pci-host-generic.c +++ b/drivers/pci/host/pci-host-generic.c @@ -38,7 +38,15 @@ struct gen_pci_cfg_windows { const struct gen_pci_cfg_bus_ops *ops; }; +/* + * ARM needs platform specific pci_sys_data as the sysdata for PCI. + * We add the sys as the first field below to handle this. sys will + * set to 0, so that the pci functions in do the right thing. + */ struct gen_pci { +#ifdef CONFIG_ARM + struct pci_sys_data sys; +#endif struct pci_host_bridge host; struct gen_pci_cfg_windows cfg; struct list_head resources; @@ -48,8 +56,7 @@ static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus, unsigned int devfn, int where) { - struct pci_sys_data *sys = bus->sysdata; - struct gen_pci *pci = sys->private_data; + struct gen_pci *pci = bus->sysdata; resource_size_t idx = bus->number - pci->cfg.bus_range->start; return pci->cfg.win[idx] + ((devfn << 8) | where); @@ -64,8 +71,7 @@ static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus, unsigned int devfn, int where) { - struct pci_sys_data *sys = bus->sysdata; - struct gen_pci *pci = sys->private_data; + struct gen_pci *pci = bus->sysdata; resource_size_t idx = bus->number - pci->cfg.bus_range->start; return pci->cfg.win[idx] + ((devfn << 12) | where); @@ -198,13 +204,6 @@ static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci) return 0; } -static int gen_pci_setup(int nr, struct pci_sys_data *sys) -{ - struct gen_pci *pci = sys->private_data; - list_splice_init(&pci->resources, &sys->resources); - return 1; -} - static int gen_pci_probe(struct platform_device *pdev) { int err; @@ -214,13 +213,7 @@ static int gen_pci_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct device_node *np = dev->of_node; struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); - struct hw_pci hw = { - .nr_controllers = 1, - .private_data = (void **)&pci, - .setup = gen_pci_setup, - .map_irq = of_irq_parse_and_map_pci, - .ops = &gen_pci_ops, - }; + struct pci_bus *bus; if (!pci) return -ENOMEM; @@ -258,7 +251,31 @@ static int gen_pci_probe(struct platform_device *pdev) return err; } - pci_common_init_dev(dev, &hw); + /* do not reassign resource if probe only */ + if (!pci_has_flag(PCI_PROBE_ONLY)) + pci_add_flags(PCI_REASSIGN_ALL_RSRC | PCI_REASSIGN_ALL_BUS); + + bus = pci_scan_root_bus(dev, 0, &gen_pci_ops, pci, &pci->resources); + if (!bus) { + dev_err(dev, "Scanning rootbus failed"); + return -ENODEV; + } + + pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); + + if (!pci_has_flag(PCI_PROBE_ONLY)) { + pci_bus_size_bridges(bus); + pci_bus_assign_resources(bus); + } + pci_bus_add_devices(bus); + + /* Configure PCI Express settings */ + if (!pci_has_flag(PCI_PROBE_ONLY)) { + struct pci_bus *child; + + list_for_each_entry(child, &bus->children, node) + pcie_bus_configure_settings(child); + } return 0; }