PCI: Another round of host clean-ups
Subsystems (27)
Rob Herring
maintainercover PCI: Another round of host clean-ups
Here's another round PCI host bridge clean-ups. This one aims to reduce the amount of duplication in host probe functions by providing more default initialization of the pci_host_bridge. With the prior clean-ups, it's now possible to alloc and initialize the pci_host_bridge struct from DT in one step.
Patches 2 and 3 drop some pci_host_bridge init. Patches 4-11 clean-up handling of root bus number and bus ranges. Patches 12 and 13 are cleanups for Cadence driver. Patches 14 and 15 are clean-ups for rCar driver. Patch 16 makes missing non-prefetchable region just a warning instead of an error in order to work with rcar-gen2. Patch 17 converts rcar-gen2 to not use the arm32 specific PCI setup. Patch 18 updates how the DT resource parsing is done for all the controller drivers. Any other new controller drivers will need updating. Patch 19 moves the default IRQ mapping to the bridge init core code.
This is based on my previous series of clean-ups[1].
Compile tested only. Any testing would be appreciated as I don't have any of this h/w (well, I have a rock960c, but have not gotten PCIe to work on it).
Rob
Rob Herring (19):
PCI: versatile: Drop flag PCI_ENABLE_PROC_DOMAINS
PCI: Set default bridge parent device
PCI: Drop unnecessary zeroing of bridge fields
PCI: aardvark: Use pci_is_root_bus() to check if bus is root bus
PCI: designware: Use pci_is_root_bus() to check if bus is root bus
PCI: mobiveil: Use pci_is_root_bus() to check if bus is root bus
PCI: xilinx-nwl: Use pci_is_root_bus() to check if bus is root bus
PCI: xilinx: Use pci_is_root_bus() to check if bus is root bus
PCI: rockchip: Use pci_is_root_bus() to check if bus is root bus
PCI: rcar: Use pci_is_root_bus() to check if bus is root bus
PCI: Move setting pci_host_bridge.busnr out of host drivers
PCI: cadence: Use bridge resources for outbound window setup
PCI: cadence: Remove private bus number and range storage
PCI: rcar: Use devm_pci_alloc_host_bridge()
PCI: rcar: Use struct pci_host_bridge.windows list directly
PCI: of: Reduce missing non-prefetchable memory region to a warning
PCI: rcar-gen2: Convert to use modern host bridge probe functions
PCI: Move DT resource setup into devm_pci_alloc_host_bridge()
PCI: Set bridge map_irq and swizzle_irq to default functions
.../pci/controller/cadence/pcie-cadence-ep.c | 6 +- .../controller/cadence/pcie-cadence-host.c | 65 +++---- drivers/pci/controller/cadence/pcie-cadence.c | 9 +- drivers/pci/controller/cadence/pcie-cadence.h | 8 +- drivers/pci/controller/dwc/pci-imx6.c | 2 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-host.c | 28 +-- drivers/pci/controller/dwc/pcie-designware.h | 2 - .../controller/mobiveil/pcie-mobiveil-host.c | 21 +-- .../pci/controller/mobiveil/pcie-mobiveil.h | 1 - drivers/pci/controller/pci-aardvark.c | 25 +-- drivers/pci/controller/pci-ftpci100.c | 10 -- drivers/pci/controller/pci-host-common.c | 17 +- drivers/pci/controller/pci-loongson.c | 8 - drivers/pci/controller/pci-mvebu.c | 4 - drivers/pci/controller/pci-rcar-gen2.c | 162 +++++------------- drivers/pci/controller/pci-tegra.c | 10 -- drivers/pci/controller/pci-v3-semi.c | 12 -- drivers/pci/controller/pci-versatile.c | 13 +- drivers/pci/controller/pci-xgene.c | 9 - drivers/pci/controller/pcie-altera.c | 10 -- drivers/pci/controller/pcie-brcmstb.c | 9 - drivers/pci/controller/pcie-iproc-platform.c | 10 +- drivers/pci/controller/pcie-iproc.c | 3 - drivers/pci/controller/pcie-mediatek.c | 16 -- drivers/pci/controller/pcie-rcar-host.c | 73 +------- drivers/pci/controller/pcie-rockchip-host.c | 24 +-- drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 20 +-- drivers/pci/controller/pcie-xilinx.c | 22 +-- drivers/pci/of.c | 45 +++-- drivers/pci/pci.h | 8 + drivers/pci/probe.c | 7 + include/linux/pci.h | 12 -- 34 files changed, 160 insertions(+), 516 deletions(-)
Rob Herring
maintainerPATCH 1/19 PCI: versatile: Drop flag PCI_ENABLE_PROC_DOMAINS
PCI_ENABLE_PROC_DOMAINS is only used on powerpc and doesn't do anything for the Versatile host driver, so let's drop it. I'm not sure how or why I had this to begin with. PCI_ENABLE_PROC_DOMAINS was never used on ARM.
--- drivers/pci/controller/pci-versatile.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/controller/pci-versatile.c +0 -1
@@ -153,7 +153,6 @@ static int versatile_pci_probe(struct platform_device *pdev)*/ writel (0 , versatile_cfg_base[0 ] +PCI_INTERRUPT_LINE ); -pci_add_flags (PCI_ENABLE_PROC_DOMAINS );pci_add_flags (PCI_REASSIGN_ALL_BUS ); bridge->dev.parent = dev;
Rob Herring
maintainerPATCH 2/19 PCI: Set default bridge parent device
In reply to Rob HerringThe host bridge's parent device is always the platform device. As we already have a pointer to it in the devres functions, let's initialize the parent device. Drivers can still override the parent if desired.
--- drivers/pci/controller/cadence/pcie-cadence-host.c | 1 - drivers/pci/controller/dwc/pcie-designware-host.c | 1 - drivers/pci/controller/mobiveil/pcie-mobiveil-host.c | 1 - drivers/pci/controller/pci-aardvark.c | 1 - drivers/pci/controller/pci-ftpci100.c | 1 - drivers/pci/controller/pci-host-common.c | 1 - drivers/pci/controller/pci-loongson.c | 1 - drivers/pci/controller/pci-mvebu.c | 1 - drivers/pci/controller/pci-tegra.c | 1 - drivers/pci/controller/pci-v3-semi.c | 1 - drivers/pci/controller/pci-versatile.c | 1 - drivers/pci/controller/pci-xgene.c | 1 - drivers/pci/controller/pcie-altera.c | 1 - drivers/pci/controller/pcie-brcmstb.c | 1 - drivers/pci/controller/pcie-iproc.c | 1 - drivers/pci/controller/pcie-mediatek.c | 1 - drivers/pci/controller/pcie-rcar-host.c | 2 -- drivers/pci/controller/pcie-rockchip-host.c | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 1 - drivers/pci/controller/pcie-xilinx.c | 1 - drivers/pci/probe.c | 2 ++ 21 files changed, 2 insertions(+), 21 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +0 -1
@@ -244,7 +244,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)if (ret) goto err_init; - bridge->dev.parent = dev; bridge->busnr = pcie->bus; bridge->ops = &cdns_pcie_host_ops; bridge->map_irq = of_irq_parse_and_map_pci;
drivers/pci/controller/dwc/pcie-designware-host.c +0 -1
@@ -475,7 +475,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->root_bus_nr = pp->busn->start; - bridge->dev.parent = dev; bridge->sysdata = pp; bridge->busnr = pp->root_bus_nr; bridge->ops = &dw_pcie_ops;
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +0 -1
@@ -605,7 +605,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie) }/* Initialize bridge */ - bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = rp->root_bus_nr; bridge->ops = &mobiveil_pcie_ops;
drivers/pci/controller/pci-aardvark.c +0 -1
@@ -1184,7 +1184,6 @@ static int advk_pcie_probe(struct platform_device *pdev)return ret; } - bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr =0 ; bridge->ops = &advk_pcie_ops;
drivers/pci/controller/pci-ftpci100.c +0 -1
@@ -437,7 +437,6 @@ static int faraday_pci_probe(struct platform_device *pdev)if (!host)return -ENOMEM ; - host->dev.parent = dev; host->ops = &faraday_pci_ops; host->busnr =0 ; host->msi =NULL ;
drivers/pci/controller/pci-host-common.c +0 -1
@@ -76,7 +76,6 @@ int pci_host_common_probe(struct platform_device *pdev)if (!pci_has_flag (PCI_PROBE_ONLY ))pci_add_flags (PCI_REASSIGN_ALL_BUS ); - bridge->dev.parent = dev; bridge->sysdata = cfg; bridge->busnr = cfg->busr.start; bridge->ops = (struct pci_ops *)&ops->pci_ops;
drivers/pci/controller/pci-loongson.c +0 -1
@@ -225,7 +225,6 @@ static int loongson_pci_probe(struct platform_device *pdev)return err; } - bridge->dev.parent = dev; bridge->sysdata = priv; bridge->ops = &loongson_pci_ops; bridge->map_irq = loongson_map_irq;
drivers/pci/controller/pci-mvebu.c +0 -1
@@ -1116,7 +1116,6 @@ static int mvebu_pcie_probe(struct platform_device *pdev) pcie->nports = i; - bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr =0 ; bridge->ops = &mvebu_pcie_ops;
drivers/pci/controller/pci-tegra.c +0 -1
@@ -2715,7 +2715,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) } host->busnr = bus->start; - host->dev.parent = &pdev->dev; host->ops = &tegra_pcie_ops; host->map_irq = tegra_pcie_map_irq; host->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pci-v3-semi.c +0 -1
@@ -723,7 +723,6 @@ static int v3_pci_probe(struct platform_device *pdev)if (!host)return -ENOMEM ; - host->dev.parent = dev; host->ops = &v3_pci_ops; host->busnr =0 ; host->msi =NULL ;
drivers/pci/controller/pci-versatile.c +0 -1
@@ -155,7 +155,6 @@ static int versatile_pci_probe(struct platform_device *pdev)pci_add_flags (PCI_REASSIGN_ALL_BUS ); - bridge->dev.parent = dev; bridge->sysdata =NULL ; bridge->busnr =0 ; bridge->ops = &pci_versatile_ops;
drivers/pci/controller/pci-xgene.c +0 -1
@@ -624,7 +624,6 @@ static int xgene_pcie_probe(struct platform_device *pdev)if (ret)return ret; - bridge->dev.parent = dev; bridge->sysdata = port; bridge->busnr =0 ; bridge->ops = &xgene_pcie_ops;
drivers/pci/controller/pcie-altera.c +0 -1
@@ -816,7 +816,6 @@ static int altera_pcie_probe(struct platform_device *pdev)cra_writel (pcie,P2A_INT_ENA_ALL ,P2A_INT_ENABLE );altera_pcie_host_init (pcie); - bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = pcie->root_bus_nr; bridge->ops = &altera_pcie_ops;
drivers/pci/controller/pcie-brcmstb.c +0 -1
@@ -996,7 +996,6 @@ static int brcm_pcie_probe(struct platform_device *pdev) } } - bridge->dev.parent = &pdev->dev; bridge->busnr =0 ; bridge->ops = &brcm_pcie_ops; bridge->sysdata = pcie;
drivers/pci/controller/pcie-iproc.c +0 -1
@@ -1524,7 +1524,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)dev_info (dev,"not using iProc MSI\n" ); host->busnr =0 ; - host->dev.parent = dev; host->ops = &iproc_pcie_ops; host->sysdata = pcie; host->map_irq = pcie->map_irq;
drivers/pci/controller/pcie-mediatek.c +0 -1
@@ -1097,7 +1097,6 @@ static int mtk_pcie_probe(struct platform_device *pdev)return err; host->busnr = pcie->busnr; - host->dev.parent = pcie->dev; host->ops = pcie->soc->ops; host->map_irq = of_irq_parse_and_map_pci; host->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pcie-rcar-host.c +0 -2
@@ -329,7 +329,6 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host) {struct pci_host_bridge *bridge =pci_host_bridge_from_priv (host);struct rcar_pcie *pcie = &host->pcie; -struct device *dev = pcie->dev;/* Try setting 5 GT/s link speed */ rcar_pcie_force_speedup (pcie);
@@ -338,7 +337,6 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host)pci_add_flags (PCI_REASSIGN_ALL_BUS ); - bridge->dev.parent = dev; bridge->sysdata = host; bridge->busnr = host->root_bus_nr; bridge->ops = &rcar_pcie_ops;
drivers/pci/controller/pcie-rockchip-host.c +0 -1
@@ -1007,7 +1007,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) goto err_remove_irq_domain; } - bridge->dev.parent = dev; bridge->sysdata = rockchip; bridge->busnr =0 ; bridge->ops = &rockchip_pcie_ops;
drivers/pci/controller/pcie-xilinx-nwl.c +0 -1
@@ -854,7 +854,6 @@ static int nwl_pcie_probe(struct platform_device *pdev)return err; } - bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr = pcie->root_busno; bridge->ops = &nwl_pcie_ops;
drivers/pci/controller/pcie-xilinx.c +0 -1
@@ -651,7 +651,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev)return err; } - bridge->dev.parent = dev; bridge->sysdata = port; bridge->busnr =0 ; bridge->ops = &xilinx_pcie_ops;
drivers/pci/probe.c +2 -0
@@ -628,6 +628,8 @@ struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,if (!bridge)return NULL ; + bridge->dev.parent = dev; + ret =devm_add_action_or_reset (dev, devm_pci_alloc_host_bridge_release, bridge);if (ret)
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 3/19 PCI: Drop unnecessary zeroing of bridge fields
In reply to Rob HerringThe struct pci_host_bridge is 0 initialized when allocated, so there's no need to explicitly set fields to 0.
--- drivers/pci/controller/pci-aardvark.c | 1 - drivers/pci/controller/pci-ftpci100.c | 2 -- drivers/pci/controller/pci-mvebu.c | 1 - drivers/pci/controller/pci-v3-semi.c | 2 -- drivers/pci/controller/pci-versatile.c | 2 -- drivers/pci/controller/pci-xgene.c | 1 - drivers/pci/controller/pcie-brcmstb.c | 1 - drivers/pci/controller/pcie-iproc.c | 1 - drivers/pci/controller/pcie-rockchip-host.c | 1 - drivers/pci/controller/pcie-xilinx.c | 1 - 10 files changed, 13 deletions(-)
drivers/pci/controller/pci-aardvark.c +0 -1
@@ -1185,7 +1185,6 @@ static int advk_pcie_probe(struct platform_device *pdev) } bridge->sysdata = pcie; - bridge->busnr =0 ; bridge->ops = &advk_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pci-ftpci100.c +0 -2
@@ -438,8 +438,6 @@ static int faraday_pci_probe(struct platform_device *pdev)return -ENOMEM ; host->ops = &faraday_pci_ops; - host->busnr =0 ; - host->msi =NULL ; host->map_irq = of_irq_parse_and_map_pci; host->swizzle_irq = pci_common_swizzle; p =pci_host_bridge_priv (host);
drivers/pci/controller/pci-mvebu.c +0 -1
@@ -1117,7 +1117,6 @@ static int mvebu_pcie_probe(struct platform_device *pdev) pcie->nports = i; bridge->sysdata = pcie; - bridge->busnr =0 ; bridge->ops = &mvebu_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pci-v3-semi.c +0 -2
@@ -724,8 +724,6 @@ static int v3_pci_probe(struct platform_device *pdev)return -ENOMEM ; host->ops = &v3_pci_ops; - host->busnr =0 ; - host->msi =NULL ; host->map_irq = of_irq_parse_and_map_pci; host->swizzle_irq = pci_common_swizzle; v3 =pci_host_bridge_priv (host);
drivers/pci/controller/pci-versatile.c +0 -2
@@ -155,8 +155,6 @@ static int versatile_pci_probe(struct platform_device *pdev)pci_add_flags (PCI_REASSIGN_ALL_BUS ); - bridge->sysdata =NULL ; - bridge->busnr =0 ; bridge->ops = &pci_versatile_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pci-xgene.c +0 -1
@@ -625,7 +625,6 @@ static int xgene_pcie_probe(struct platform_device *pdev)return ret; bridge->sysdata = port; - bridge->busnr =0 ; bridge->ops = &xgene_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pcie-brcmstb.c +0 -1
@@ -996,7 +996,6 @@ static int brcm_pcie_probe(struct platform_device *pdev) } } - bridge->busnr =0 ; bridge->ops = &brcm_pcie_ops; bridge->sysdata = pcie; bridge->map_irq = of_irq_parse_and_map_pci;
drivers/pci/controller/pcie-iproc.c +0 -1
@@ -1523,7 +1523,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res)if (iproc_pcie_msi_enable (pcie))dev_info (dev,"not using iProc MSI\n" ); - host->busnr =0 ; host->ops = &iproc_pcie_ops; host->sysdata = pcie; host->map_irq = pcie->map_irq;
drivers/pci/controller/pcie-rockchip-host.c +0 -1
@@ -1008,7 +1008,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) } bridge->sysdata = rockchip; - bridge->busnr =0 ; bridge->ops = &rockchip_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pcie-xilinx.c +0 -1
@@ -652,7 +652,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev) } bridge->sysdata = port; - bridge->busnr =0 ; bridge->ops = &xilinx_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 4/19 PCI: aardvark: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
--- drivers/pci/controller/pci-aardvark.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/pci/controller/pci-aardvark.c +6 -7
@@ -195,7 +195,6 @@ struct advk_pcie {DECLARE_BITMAP (msi_used,MSI_IRQ_NUM );struct mutex msi_used_lock;u16 msi_msg; -int root_bus_nr;int link_gen;struct pci_bridge_emul bridge;struct gpio_desc *reset_gpio;
@@ -641,7 +640,7 @@ static void advk_sw_pci_bridge_init(struct advk_pcie *pcie)static bool advk_pcie_valid_device (struct advk_pcie *pcie,struct pci_bus *bus,int devfn) { -if ((bus->number == pcie->root_bus_nr) &&PCI_SLOT (devfn) !=0 ) +if (pci_is_root_bus (bus) &&PCI_SLOT (devfn) !=0 )return false;return true;
@@ -659,7 +658,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,return PCIBIOS_DEVICE_NOT_FOUND ; } -if (bus->number == pcie->root_bus_nr) +if (pci_is_root_bus (bus))return pci_bridge_emul_conf_read (&pcie->bridge, where, size, val);
@@ -670,7 +669,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,/* Program the control register */ reg =advk_readl (pcie,PIO_CTRL ); reg &= ~PIO_CTRL_TYPE_MASK ; -if (bus->primary == pcie->root_bus_nr) +if (pci_is_root_bus (bus->parent)) reg |=PCIE_CONFIG_RD_TYPE0 ;else reg |=PCIE_CONFIG_RD_TYPE1 ;
@@ -715,7 +714,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,if (!advk_pcie_valid_device (pcie, bus, devfn))return PCIBIOS_DEVICE_NOT_FOUND ; -if (bus->number == pcie->root_bus_nr) +if (pci_is_root_bus (bus))return pci_bridge_emul_conf_write (&pcie->bridge, where, size, val);
@@ -729,7 +728,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,/* Program the control register */ reg =advk_readl (pcie,PIO_CTRL ); reg &= ~PIO_CTRL_TYPE_MASK ; -if (bus->primary == pcie->root_bus_nr) +if (pci_is_root_bus (bus->parent)) reg |=PCIE_CONFIG_WR_TYPE0 ;else reg |=PCIE_CONFIG_WR_TYPE1 ;
@@ -1139,7 +1138,7 @@ static int advk_pcie_probe(struct platform_device *pdev)dev_err (dev,"Failed to parse resources\n" );return ret; } - pcie->root_bus_nr = bus->start; + bridge->busnr = bus->start; pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, "reset-gpios", 0,
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 5/19 PCI: designware: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
--- drivers/pci/controller/dwc/pci-imx6.c | 2 +- drivers/pci/controller/dwc/pci-keystone.c | 4 ++-- .../pci/controller/dwc/pcie-designware-host.c | 18 +++++++----------- drivers/pci/controller/dwc/pcie-designware.h | 1 - 4 files changed, 10 insertions(+), 15 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +1 -1
@@ -1269,7 +1269,7 @@ static void imx6_pcie_quirk(struct pci_dev *dev)if (bus->dev.parent->parent->driver != &imx6_pcie_driver.driver)return ; -if (bus->number == pp->root_bus_nr) { +if (pci_is_root_bus (bus)) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);struct imx6_pcie *imx6_pcie =to_imx6_pcie (pci);
drivers/pci/controller/dwc/pci-keystone.c +2 -2
@@ -440,7 +440,7 @@ static int ks_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, reg =CFG_BUS (bus->number) |CFG_DEVICE (PCI_SLOT (devfn)) |CFG_FUNC (PCI_FUNC (devfn)); -if (bus->parent->number != pp->root_bus_nr) +if (!pci_is_root_bus (bus->parent)) reg |=CFG_TYPE1 ;ks_pcie_app_writel (ks_pcie,CFG_SETUP , reg);
@@ -457,7 +457,7 @@ static int ks_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus, reg =CFG_BUS (bus->number) |CFG_DEVICE (PCI_SLOT (devfn)) |CFG_FUNC (PCI_FUNC (devfn)); -if (bus->parent->number != pp->root_bus_nr) +if (!pci_is_root_bus (bus->parent)) reg |=CFG_TYPE1 ;ks_pcie_app_writel (ks_pcie,CFG_SETUP , reg);
drivers/pci/controller/dwc/pcie-designware-host.c +7 -11
@@ -473,10 +473,8 @@ int dw_pcie_host_init(struct pcie_port *pp) goto err_free_msi; } - pp->root_bus_nr = pp->busn->start; - bridge->sysdata = pp; - bridge->busnr = pp->root_bus_nr; + bridge->busnr = pp->busn->start; bridge->ops = &dw_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
@@ -528,7 +526,7 @@ static int dw_pcie_access_other_conf(struct pcie_port *pp, struct pci_bus *bus, busdev =PCIE_ATU_BUS (bus->number) |PCIE_ATU_DEV (PCI_SLOT (devfn)) |PCIE_ATU_FUNC (PCI_FUNC (devfn)); -if (bus->parent->number == pp->root_bus_nr) { +if (pci_is_root_bus (bus->parent)) { type =PCIE_ATU_TYPE_CFG0 ; cpu_addr = pp->cfg0_base; cfg_size = pp->cfg0_size;
@@ -584,13 +582,11 @@ static int dw_pcie_valid_device(struct pcie_port *pp, struct pci_bus *bus,struct dw_pcie *pci =to_dw_pcie_from_pp (pp);/* If there is no link, then there is no device */ -if (bus->number != pp->root_bus_nr) { +if (!pci_is_root_bus (bus)) {if (!dw_pcie_link_up (pci))return 0 ; - } - -/* Access only one slot on each root port */ -if (bus->number == pp->root_bus_nr && dev >0 ) + }else if (dev >0 ) +/* Access only one slot on each root port */ return 0 ;return 1 ;
@@ -606,7 +602,7 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,return PCIBIOS_DEVICE_NOT_FOUND ; } -if (bus->number == pp->root_bus_nr) +if (pci_is_root_bus (bus))return dw_pcie_rd_own_conf (pp, where, size, val);return dw_pcie_rd_other_conf (pp, bus, devfn, where, size, val);
@@ -620,7 +616,7 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,if (!dw_pcie_valid_device (pp, bus,PCI_SLOT (devfn)))return PCIBIOS_DEVICE_NOT_FOUND ; -if (bus->number == pp->root_bus_nr) +if (pci_is_root_bus (bus))return dw_pcie_wr_own_conf (pp, where, size, val);return dw_pcie_wr_other_conf (pp, bus, devfn, where, size, val);
drivers/pci/controller/dwc/pcie-designware.h +0 -1
@@ -173,7 +173,6 @@ struct dw_pcie_host_ops { };struct pcie_port { -u8 root_bus_nr;u64 cfg0_base;void __iomem *va_cfg0_base;u32 cfg0_size;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 6/19 PCI: mobiveil: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
--- drivers/pci/controller/mobiveil/pcie-mobiveil-host.c | 10 +++------- drivers/pci/controller/mobiveil/pcie-mobiveil.h | 1 - 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +3 -7
@@ -29,18 +29,15 @@static bool mobiveil_pcie_valid_device (struct pci_bus *bus,unsigned int devfn) { -struct mobiveil_pcie *pcie = bus->sysdata; -struct mobiveil_root_port *rp = &pcie->rp; -/* Only one device down on each root port */ -if ((bus->number == rp->root_bus_nr) && (devfn >0 )) +if (pci_is_root_bus (bus) && (devfn >0 ))return false;/* * Do not read more than one device on the bus directly * attached to RC */ -if ((bus->primary == rp->root_bus_nr) && (PCI_SLOT (devfn) >0 )) +if ((bus->primary ==to_pci_host_bridge (bus->bridge)->busnr) && (PCI_SLOT (devfn) >0 ))return false;return true;
@@ -61,7 +58,7 @@ static void __iomem *mobiveil_pcie_map_bus(struct pci_bus *bus,return NULL ;/* RC config access */ -if (bus->number == rp->root_bus_nr) +if (pci_is_root_bus (bus))return pcie->csr_axi_slave_base + where;/*
@@ -606,7 +603,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)/* Initialize bridge */ bridge->sysdata = pcie; - bridge->busnr = rp->root_bus_nr; bridge->ops = &mobiveil_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/mobiveil/pcie-mobiveil.h +0 -1
@@ -149,7 +149,6 @@ struct mobiveil_rp_ops { };struct mobiveil_root_port { -char root_bus_nr;void __iomem *config_axi_slave_base;/* endpoint config base */ struct resource *ob_io_res;struct mobiveil_rp_ops *ops;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 7/19 PCI: xilinx-nwl: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
There was also a bug that the pci_host_bridge.busnr is set from root_busno, but root_busno is never set which means the root bus number is always 0 even if the DT said something else.
--- drivers/pci/controller/pcie-xilinx-nwl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +3 -7
@@ -166,7 +166,6 @@ struct nwl_pcie {int irq_misc;u32 ecam_value;u8 last_busno; -u8 root_busno;struct nwl_msi msi;struct irq_domain *legacy_irq_domain;raw_spinlock_t leg_mask_lock;
@@ -217,13 +216,11 @@ static bool nwl_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)struct nwl_pcie *pcie = bus->sysdata;/* Check link before accessing downstream ports */ -if (bus->number != pcie->root_busno) { +if (!pci_is_root_bus (bus)) {if (!nwl_pcie_link_up (pcie))return false; - } - -/* Only one device down on each root port */ -if (bus->number == pcie->root_busno && devfn >0 ) + }else if (devfn >0 ) +/* Only one device down on each root port */ return false;return true;
@@ -855,7 +852,6 @@ static int nwl_pcie_probe(struct platform_device *pdev) } bridge->sysdata = pcie; - bridge->busnr = pcie->root_busno; bridge->ops = &nwl_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 8/19 PCI: xilinx: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
There was also a bug that the root_busno is never set which means the root bus number is always 0 even if the DT said something else.
--- drivers/pci/controller/pcie-xilinx.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/pci/controller/pcie-xilinx.c +4 -7
@@ -98,7 +98,6 @@* @reg_base: IO Mapped Register Base * @irq: Interrupt number * @msi_pages: MSI pages -* @root_busno: Root Bus number * @dev: Device pointer * @msi_domain: MSI IRQ domain pointer * @leg_domain: Legacy IRQ domain pointer
@@ -108,7 +107,6 @@ struct xilinx_pcie_port {void __iomem *reg_base;u32 irq;unsigned long msi_pages; -u8 root_busno;struct device *dev;struct irq_domain *msi_domain;struct irq_domain *leg_domain;
@@ -162,14 +160,13 @@ static bool xilinx_pcie_valid_device(struct pci_bus *bus, unsigned int devfn)struct xilinx_pcie_port *port = bus->sysdata;/* Check if link is up when trying to access downstream ports */ -if (bus->number != port->root_busno) +if (!pci_is_root_bus (bus)) {if (!xilinx_pcie_link_up (port))return false; - -/* Only one device down on each root port */ -if (bus->number == port->root_busno && devfn >0 ) + }else if (devfn >0 ) { +/* Only one device down on each root port */ return false; - + }return true; }
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 9/19 PCI: rockchip: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
Also, bridge->busnr is never set so effectively the root bus must be 0. This will be fixed by a subsequent commit.
--- drivers/pci/controller/pcie-rockchip-host.c | 17 +++++++---------- drivers/pci/controller/pcie-rockchip.h | 1 - 2 files changed, 7 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-rockchip-host.c +7 -10
@@ -72,14 +72,14 @@ static int rockchip_pcie_valid_device(struct rockchip_pcie *rockchip, struct pci_bus *bus, int dev) {/* access only one slot on each root port */ -if (bus->number == rockchip->root_bus_nr && dev >0 ) +if (pci_is_root_bus (bus) && dev >0 )return 0 ;/* * do not read more than one device on the bus directly attached * to RC's downstream side. */ -if (bus->primary == rockchip->root_bus_nr && dev >0 ) +if (pci_is_root_bus (bus->parent) && dev >0 )return 0 ;return 1 ;
@@ -170,7 +170,7 @@ static int rockchip_pcie_rd_other_conf(struct rockchip_pcie *rockchip,return PCIBIOS_BAD_REGISTER_NUMBER ; } -if (bus->parent->number == rockchip->root_bus_nr) +if (pci_is_root_bus (bus->parent))rockchip_pcie_cfg_configuration_accesses (rockchip,AXI_WRAPPER_TYPE0_CFG );else
@@ -201,7 +201,7 @@ static int rockchip_pcie_wr_other_conf(struct rockchip_pcie *rockchip,if (!IS_ALIGNED (busdev, size))return PCIBIOS_BAD_REGISTER_NUMBER ; -if (bus->parent->number == rockchip->root_bus_nr) +if (pci_is_root_bus (bus->parent))rockchip_pcie_cfg_configuration_accesses (rockchip,AXI_WRAPPER_TYPE0_CFG );else
@@ -230,7 +230,7 @@ static int rockchip_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,return PCIBIOS_DEVICE_NOT_FOUND ; } -if (bus->number == rockchip->root_bus_nr) +if (pci_is_root_bus (bus))return rockchip_pcie_rd_own_conf (rockchip, where, size, val); return rockchip_pcie_rd_other_conf(rockchip, bus, devfn, where, size,
@@ -245,7 +245,7 @@ static int rockchip_pcie_wr_conf(struct pci_bus *bus, u32 devfn,if (!rockchip_pcie_valid_device (rockchip, bus,PCI_SLOT (devfn)))return PCIBIOS_DEVICE_NOT_FOUND ; -if (bus->number == rockchip->root_bus_nr) +if (pci_is_root_bus (bus))return rockchip_pcie_wr_own_conf (rockchip, where, size, val); return rockchip_pcie_wr_other_conf(rockchip, bus, devfn, where, size,
@@ -950,7 +950,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)struct rockchip_pcie *rockchip;struct device *dev = &pdev->dev;struct pci_host_bridge *bridge; -struct resource *bus_res;int err;if (!dev->of_node)
@@ -991,12 +990,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev) goto err_deinit_port; err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges, &bus_res); + &bridge->dma_ranges,NULL );if (err) goto err_remove_irq_domain; - rockchip->root_bus_nr = bus_res->start; - err =rockchip_pcie_cfg_atu (rockchip);if (err) goto err_remove_irq_domain;
drivers/pci/controller/pcie-rockchip.h +0 -1
@@ -298,7 +298,6 @@ struct rockchip_pcie {struct gpio_desc *ep_gpio;u32 lanes;u8 lanes_map; -u8 root_bus_nr;int link_gen;struct device *dev;struct irq_domain *irq_domain;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 10/19 PCI: rcar: Use pci_is_root_bus() to check if bus is root bus
In reply to Rob HerringUse pci_is_root_bus() rather than tracking the root bus number to determine if the bus is the root bus or not. This removes storing duplicated data as well as the need for the host bridge driver to have to care about the bus numbers in most cases.
--- drivers/pci/controller/pcie-rcar-host.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/pci/controller/pcie-rcar-host.c +5 -14
@@ -54,7 +54,6 @@ struct rcar_pcie_host {struct phy *phy;void __iomem *base;struct list_head resources; -int root_bus_nr;struct clk *bus_clk;struct rcar_msi msi;int (*phy_init_fn)(struct rcar_pcie_host *host);
@@ -100,22 +99,14 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host,if (dev !=0 )return PCIBIOS_DEVICE_NOT_FOUND ; -if (access_type ==RCAR_PCI_ACCESS_READ ) { +if (access_type ==RCAR_PCI_ACCESS_READ ) *data =rcar_pci_read_reg (pcie,PCICONF (index)); - }else { -/* Keep an eye out for changes to the root bus number */ -if (pci_is_root_bus (bus) && (reg ==PCI_PRIMARY_BUS )) - host->root_bus_nr = *data &0xff ; - +else rcar_pci_write_reg (pcie, *data,PCICONF (index)); - }return PCIBIOS_SUCCESSFUL ; } -if (host->root_bus_nr <0 ) -return PCIBIOS_DEVICE_NOT_FOUND ; -/* Clear errors */ rcar_pci_write_reg (pcie,rcar_pci_read_reg (pcie,PCIEERRFR ),PCIEERRFR );
@@ -124,7 +115,7 @@ static int rcar_pcie_config_access(struct rcar_pcie_host *host, PCIE_CONF_DEV(dev) | PCIE_CONF_FUNC(func) | reg, PCIECAR);/* Enable the configuration access */ -if (bus->parent->number == host->root_bus_nr) +if (pci_is_root_bus (bus->parent))rcar_pci_write_reg (pcie,CONFIG_SEND_ENABLE |TYPE0 ,PCIECCTLR );else rcar_pci_write_reg (pcie,CONFIG_SEND_ENABLE |TYPE1 ,PCIECCTLR );
@@ -215,6 +206,7 @@ static struct pci_ops rcar_pcie_ops = {static int rcar_pcie_setup (struct list_head *resource,struct rcar_pcie_host *host) { +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (host);struct resource_entry *win;int i =0 ;
@@ -232,7 +224,7 @@ static int rcar_pcie_setup(struct list_head *resource, i++;break ;case IORESOURCE_BUS : - host->root_bus_nr = res->start; + bridge->busnr = res->start;break ;default :continue ;
@@ -338,7 +330,6 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host)pci_add_flags (PCI_REASSIGN_ALL_BUS ); bridge->sysdata = host; - bridge->busnr = host->root_bus_nr; bridge->ops = &rcar_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 11/19 PCI: Move setting pci_host_bridge.busnr out of host drivers
In reply to Rob HerringMost host drivers only parse the DT bus range to set the root bus number in pci_host_bridge.busnr. The ones that don't set busnr are buggy in that they ignore what's in DT. Let's set busnr in pci_scan_root_bus_bridge() where we already check for the bus resource and remove setting it in host drivers.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 4 ---- drivers/pci/controller/dwc/pcie-designware.h | 1 - drivers/pci/controller/pci-aardvark.c | 5 ++--- drivers/pci/controller/pci-host-common.c | 1 - drivers/pci/controller/pci-tegra.c | 4 +--- drivers/pci/controller/pci-v3-semi.c | 2 -- drivers/pci/controller/pcie-mediatek.c | 8 +------- drivers/pci/controller/pcie-rcar-host.c | 1 - drivers/pci/probe.c | 1 + 9 files changed, 5 insertions(+), 22 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +0 -4
@@ -374,9 +374,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg0_base = pp->cfg->start; pp->cfg1_base = pp->cfg->start + pp->cfg0_size;break ; -case IORESOURCE_BUS : - pp->busn = win->res; -break ; } }
@@ -474,7 +471,6 @@ int dw_pcie_host_init(struct pcie_port *pp) } bridge->sysdata = pp; - bridge->busnr = pp->busn->start; bridge->ops = &dw_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/dwc/pcie-designware.h +0 -1
@@ -188,7 +188,6 @@ struct pcie_port {struct resource *cfg;struct resource *io;struct resource *mem; -struct resource *busn;int irq;const struct dw_pcie_host_ops *ops;int msi_irq;
drivers/pci/controller/pci-aardvark.c +2 -3
@@ -1104,7 +1104,7 @@ static int advk_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct advk_pcie *pcie; -struct resource *res, *bus; +struct resource *res;struct pci_host_bridge *bridge;int ret, irq;
@@ -1133,12 +1133,11 @@ static int advk_pcie_probe(struct platform_device *pdev) } ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges, &bus); + &bridge->dma_ranges,NULL );if (ret) {dev_err (dev,"Failed to parse resources\n" );return ret; } - bridge->busnr = bus->start; pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, "reset-gpios", 0,
drivers/pci/controller/pci-host-common.c +0 -1
@@ -77,7 +77,6 @@ int pci_host_common_probe(struct platform_device *pdev)pci_add_flags (PCI_REASSIGN_ALL_BUS ); bridge->sysdata = cfg; - bridge->busnr = cfg->busr.start; bridge->ops = (struct pci_ops *)&ops->pci_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pci-tegra.c +1 -3
@@ -2670,7 +2670,6 @@ static int tegra_pcie_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct pci_host_bridge *host;struct tegra_pcie *pcie; -struct resource *bus;int err; host =devm_pci_alloc_host_bridge (dev,sizeof (*pcie));
@@ -2685,7 +2684,7 @@ static int tegra_pcie_probe(struct platform_device *pdev)INIT_LIST_HEAD (&pcie->ports); pcie->dev = dev; - err =pci_parse_request_of_pci_ranges (dev, &host->windows,NULL , &bus); + err =pci_parse_request_of_pci_ranges (dev, &host->windows,NULL ,NULL );if (err) {dev_err (dev,"Getting bridge resources failed\n" );return err;
@@ -2714,7 +2713,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) goto pm_runtime_put; } - host->busnr = bus->start; host->ops = &tegra_pcie_ops; host->map_irq = tegra_pcie_map_irq; host->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pci-v3-semi.c +0 -2
@@ -584,8 +584,6 @@ static int v3_pci_setup_resource(struct v3_pci *v3, }break ;case IORESOURCE_BUS : -dev_dbg (dev,"BUS %pR\n" , win->res); - host->busnr = win->res->start;break ;default : dev_info(dev, "Unknown resource type %lu\n",
drivers/pci/controller/pcie-mediatek.c +1 -7
@@ -209,7 +209,6 @@ struct mtk_pcie_port {* @mem: non-prefetchable memory resource * @ports: pointer to PCIe port information * @soc: pointer to SoC-dependent operations -* @busnr: root bus number */ struct mtk_pcie {struct device *dev;
@@ -218,7 +217,6 @@ struct mtk_pcie {struct list_head ports;const struct mtk_pcie_soc *soc; -unsigned int busnr; };static void mtk_pcie_subsys_powerdown (struct mtk_pcie *pcie)
@@ -1033,16 +1031,13 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie)struct mtk_pcie_port *port, *tmp;struct pci_host_bridge *host =pci_host_bridge_from_priv (pcie);struct list_head *windows = &host->windows; -struct resource *bus;int err; err =pci_parse_request_of_pci_ranges (dev, windows, - &host->dma_ranges, &bus); + &host->dma_ranges,NULL );if (err)return err; - pcie->busnr = bus->start; -for_each_available_child_of_node (node, child) {int slot;
@@ -1096,7 +1091,6 @@ static int mtk_pcie_probe(struct platform_device *pdev)if (err)return err; - host->busnr = pcie->busnr; host->ops = pcie->soc->ops; host->map_irq = of_irq_parse_and_map_pci; host->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/pcie-rcar-host.c +0 -1
@@ -224,7 +224,6 @@ static int rcar_pcie_setup(struct list_head *resource, i++;break ;case IORESOURCE_BUS : - bridge->busnr = res->start;break ;default :continue ;
drivers/pci/probe.c +1 -0
@@ -3088,6 +3088,7 @@ int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge)resource_list_for_each_entry (window, &bridge->windows)if (window->res->flags &IORESOURCE_BUS ) { + bridge->busnr = window->res->start; found = true;break ; }
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH 11/19] PCI: Move setting pci_host_bridge.busnr out of host drivers
Quoted 55 lines · Rob Herring
Most host drivers only parse the DT bus range to set the root bus number in pci_host_bridge.busnr. The ones that don't set busnr are buggy in that they ignore what's in DT. Let's set busnr in
pci_scan_root_bus_bridge()where we already check for the bus resource and remove setting it in host drivers.Cc Jingoo Han <[email protected]>Cc Gustavo Pimentel <gustavo.pimentel-HKixBCOQz3hWk0Htik3J/[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Will Deacon <[email protected]>Cc Thierry Reding <[email protected]>Cc Jonathan Hunter <[email protected]>Cc Linus Walleij <[email protected]>Cc Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/[email protected]>Cc Marek Vasut <[email protected]>Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/dwc/pcie-designware-host.c | 4 ---- drivers/pci/controller/dwc/pcie-designware.h | 1 - drivers/pci/controller/pci-aardvark.c | 5 ++--- drivers/pci/controller/pci-host-common.c | 1 - drivers/pci/controller/pci-tegra.c | 4 +--- drivers/pci/controller/pci-v3-semi.c | 2 -- drivers/pci/controller/pcie-mediatek.c | 8 +------- drivers/pci/controller/pcie-rcar-host.c | 1 - drivers/pci/probe.c | 1 + 9 files changed, 5 insertions(+), 22 deletions(-)drivers/pci/controller/dwc/pcie-designware-host.c +0
-3@@ -374,9 +374,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg0_base = pp->cfg->start; pp->cfg1_base = pp->cfg->start + pp->cfg0_size;break ; -case IORESOURCE_BUS : - pp->busn = win->res; -break ; } }drivers/pci/controller/dwc/pcie-designware.h +0
-0
drivers/pci/controller/dwc/pcie-designware.h struct pcie_port { · line 193
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.h +0
-1@@ -188,7 +188,6 @@ struct pcie_port {struct resource *cfg;struct resource *io;struct resource *mem; -struct resource *busn;int irq;const struct dw_pcie_host_ops *ops;int msi_irq;
These 2 hunks should be dropped as they are breaking the Amazon driver.
Lorenzo, do you want to fixup or I can send a fix?
Rob
Re: [PATCH 11/19] PCI: Move setting pci_host_bridge.busnr out of host drivers
Quoted 66 lines · Rob Herring
Quoted 55 lines · Rob Herring
Most host drivers only parse the DT bus range to set the root bus number in pci_host_bridge.busnr. The ones that don't set busnr are buggy in that they ignore what's in DT. Let's set busnr in
pci_scan_root_bus_bridge()where we already check for the bus resource and remove setting it in host drivers.Cc Jingoo Han <[email protected]>Cc Gustavo Pimentel <gustavo.pimentel-HKixBCOQz3hWk0Htik3J/[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Will Deacon <[email protected]>Cc Thierry Reding <[email protected]>Cc Jonathan Hunter <[email protected]>Cc Linus Walleij <[email protected]>Cc Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/[email protected]>Cc Marek Vasut <[email protected]>Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/dwc/pcie-designware-host.c | 4 ---- drivers/pci/controller/dwc/pcie-designware.h | 1 - drivers/pci/controller/pci-aardvark.c | 5 ++--- drivers/pci/controller/pci-host-common.c | 1 - drivers/pci/controller/pci-tegra.c | 4 +--- drivers/pci/controller/pci-v3-semi.c | 2 -- drivers/pci/controller/pcie-mediatek.c | 8 +------- drivers/pci/controller/pcie-rcar-host.c | 1 - drivers/pci/probe.c | 1 + 9 files changed, 5 insertions(+), 22 deletions(-)drivers/pci/controller/dwc/pcie-designware-host.c +0
-3@@ -374,9 +374,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg0_base = pp->cfg->start; pp->cfg1_base = pp->cfg->start + pp->cfg0_size;break ; -case IORESOURCE_BUS : - pp->busn = win->res; -break ; } }drivers/pci/controller/dwc/pcie-designware.h +0
-0drivers/pci/controller/dwc/pcie-designware.h struct pcie_port { · line 193
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.h +0
-1@@ -188,7 +188,6 @@ struct pcie_port {struct resource *cfg;struct resource *io;struct resource *mem; -struct resource *busn;int irq;const struct dw_pcie_host_ops *ops;int msi_irq;These 2 hunks should be dropped as they are breaking the Amazon driver.
Quoted 1 line
Lorenzo, do you want to fixup or I can send a fix?
Done (I have not removed the hunk below though):
drivers/pci/controller/dwc/pcie-designware-host.c +0 -1
@@ -474,7 +474,6 @@ int dw_pcie_host_init(struct pcie_port *pp) } bridge->sysdata = pp; - bridge->busnr = pp->busn->start; bridge->ops = &dw_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
Rob Herring
maintainerRe: [PATCH 11/19] PCI: Move setting pci_host_bridge.busnr out of host drivers
Quoted 68 lines · Lorenzo Pieralisi
Quoted 66 lines · Rob Herring
Quoted 55 lines · Rob Herring
Most host drivers only parse the DT bus range to set the root bus number in pci_host_bridge.busnr. The ones that don't set busnr are buggy in that they ignore what's in DT. Let's set busnr in
pci_scan_root_bus_bridge()where we already check for the bus resource and remove setting it in host drivers.Cc Jingoo Han <[email protected]>Cc Gustavo Pimentel <gustavo.pimentel-HKixBCOQz3hWk0Htik3J/[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Will Deacon <[email protected]>Cc Thierry Reding <[email protected]>Cc Jonathan Hunter <[email protected]>Cc Linus Walleij <[email protected]>Cc Ryder Lee <ryder.lee-NuS5LvNUpcJWk0Htik3J/[email protected]>Cc Marek Vasut <[email protected]>Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/dwc/pcie-designware-host.c | 4 ---- drivers/pci/controller/dwc/pcie-designware.h | 1 - drivers/pci/controller/pci-aardvark.c | 5 ++--- drivers/pci/controller/pci-host-common.c | 1 - drivers/pci/controller/pci-tegra.c | 4 +--- drivers/pci/controller/pci-v3-semi.c | 2 -- drivers/pci/controller/pcie-mediatek.c | 8 +------- drivers/pci/controller/pcie-rcar-host.c | 1 - drivers/pci/probe.c | 1 + 9 files changed, 5 insertions(+), 22 deletions(-)drivers/pci/controller/dwc/pcie-designware-host.c +0
-3@@ -374,9 +374,6 @@ int dw_pcie_host_init(struct pcie_port *pp) pp->cfg0_base = pp->cfg->start; pp->cfg1_base = pp->cfg->start + pp->cfg0_size;break ; -case IORESOURCE_BUS : - pp->busn = win->res; -break ; } }drivers/pci/controller/dwc/pcie-designware.h +0
-0drivers/pci/controller/dwc/pcie-designware.h struct pcie_port { · line 193
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.h +0
-1@@ -188,7 +188,6 @@ struct pcie_port {struct resource *cfg;struct resource *io;struct resource *mem; -struct resource *busn;int irq;const struct dw_pcie_host_ops *ops;int msi_irq;These 2 hunks should be dropped as they are breaking the Amazon driver.
Quoted 3 lines
Quoted 1 line
Lorenzo, do you want to fixup or I can send a fix?
Done (I have not removed the hunk below though):
Right, that's correct. I'll post a separate patch removing 'pp->busn' as that's available from the bridge struct. The bridge struct surprisingly is not accessible from the DWC structs. I guess that's why there's a bunch of duplication of data.
Rob
Quoted 12 lines
drivers/pci/controller/dwc/pcie-designware-host.c +0
-1@@ -474,7 +474,6 @@ int dw_pcie_host_init(struct pcie_port *pp) } bridge->sysdata = pp; - bridge->busnr = pp->busn->start; bridge->ops = &dw_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
Rob Herring
maintainerPATCH 12/19 PCI: cadence: Use bridge resources for outbound window setup
In reply to Rob HerringInstead of parsing 'ranges' from DT again, use the bridge window resources.
--- .../controller/cadence/pcie-cadence-host.c | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +16 -21
@@ -104,16 +104,14 @@ static int cdns_pcie_host_init_root_port(struct cdns_pcie_rc *rc)static int cdns_pcie_host_init_address_translation (struct cdns_pcie_rc *rc) {struct cdns_pcie *pcie = &rc->pcie; +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (rc);struct resource *mem_res = pcie->mem_res;struct resource *bus_range = rc->bus_range;struct resource *cfg_res = rc->cfg_res; -struct device *dev = pcie->dev; -struct device_node *np = dev->of_node; -struct of_pci_range_parser parser; -struct of_pci_range range; +struct resource_entry *entry;u32 addr0, addr1, desc1;u64 cpu_addr; -int r, err; +int r;/* * Reserve region 0 for PCI configure space accesses:
@@ -132,25 +130,22 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (0 ), addr0);cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (0 ), addr1); - err =of_pci_range_parser_init (&parser, np); -if (err) -return err; - r =1 ; -for_each_of_pci_range (&parser, &range) { -bool is_io; - -if ((range.flags &IORESOURCE_TYPE_BITS ) ==IORESOURCE_MEM ) - is_io = false; -else if ((range.flags &IORESOURCE_TYPE_BITS ) ==IORESOURCE_IO ) - is_io = true; +resource_list_for_each_entry (entry, &bridge->windows) { +struct resource *res = entry->res; +u64 pci_addr = res->start - entry->offset; + +if (resource_type (res) ==IORESOURCE_IO ) +cdns_pcie_set_outbound_region (pcie,0 , r, true, +pci_pio_to_address (res->start), + pci_addr, +resource_size (res));else -continue ; +cdns_pcie_set_outbound_region (pcie,0 , r, false, + res->start, + pci_addr, +resource_size (res)); -cdns_pcie_set_outbound_region (pcie,0 , r, is_io, - range.cpu_addr, - range.pci_addr, - range.size); r++; }
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 13/19 PCI: cadence: Remove private bus number and range storage
In reply to Rob HerringThere's no need to store the bus number or range resource as the driver only needs the bus number which is already in the pci_host_bridge.
For endpoint mode, the bus number is always 0.
--- .../pci/controller/cadence/pcie-cadence-ep.c | 6 ++--- .../controller/cadence/pcie-cadence-host.c | 27 +++++++++---------- drivers/pci/controller/cadence/pcie-cadence.c | 9 ++++--- drivers/pci/controller/cadence/pcie-cadence.h | 8 +++--- 4 files changed, 24 insertions(+), 26 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-ep.c +3 -3
@@ -156,7 +156,7 @@ static int cdns_pcie_ep_map_addr(struct pci_epc *epc, u8 fn, phys_addr_t addr,return -EINVAL ; } -cdns_pcie_set_outbound_region (pcie, fn, r, false, addr, pci_addr, size); +cdns_pcie_set_outbound_region (pcie,0 , fn, r, false, addr, pci_addr, size);set_bit (r, &ep->ob_region_map); ep->ob_addr[r] = addr;
@@ -239,7 +239,7 @@ static void cdns_pcie_ep_assert_intx(struct cdns_pcie_ep *ep, u8 fn,if (unlikely (ep->irq_pci_addr !=CDNS_PCIE_EP_IRQ_PCI_ADDR_LEGACY || ep->irq_pci_fn != fn)) {/* First region was reserved for IRQ writes. */ -cdns_pcie_set_outbound_region_for_normal_msg (pcie, fn,0 , +cdns_pcie_set_outbound_region_for_normal_msg (pcie,0 , fn,0 , ep->irq_phys_addr); ep->irq_pci_addr =CDNS_PCIE_EP_IRQ_PCI_ADDR_LEGACY ; ep->irq_pci_fn = fn;
@@ -318,7 +318,7 @@ static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn,if (unlikely (ep->irq_pci_addr != (pci_addr & ~pci_addr_mask) || ep->irq_pci_fn != fn)) {/* First region was reserved for IRQ writes. */ - cdns_pcie_set_outbound_region(pcie, fn, 0, + cdns_pcie_set_outbound_region(pcie, 0, fn, 0, false, ep->irq_phys_addr, pci_addr & ~pci_addr_mask,
drivers/pci/controller/cadence/pcie-cadence-host.c +13 -14
@@ -20,7 +20,7 @@ static void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,unsigned int busn = bus->number;u32 addr0, desc0; -if (busn == rc->bus_range->start) { +if (pci_is_root_bus (bus)) {/* * Only the root port (devfn == 0) is connected to this bus. * All other PCI devices are behind some bridge hence on another
@@ -50,7 +50,7 @@ static void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,* The bus number was already set once for all in desc1 by * cdns_pcie_host_init_address_translation(). */ -if (busn == rc->bus_range->start +1 ) +if (busn == bridge->busnr +1 ) desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 ;else desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 ;
@@ -106,12 +106,15 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)struct cdns_pcie *pcie = &rc->pcie;struct pci_host_bridge *bridge =pci_host_bridge_from_priv (rc);struct resource *mem_res = pcie->mem_res; -struct resource *bus_range = rc->bus_range;struct resource *cfg_res = rc->cfg_res;struct resource_entry *entry;u32 addr0, addr1, desc1;u64 cpu_addr; -int r; +int r, busnr =0 ; + + entry =resource_list_first_type (&bridge->windows,IORESOURCE_BUS ); +if (entry) + busnr = entry->res->start;/* * Reserve region 0 for PCI configure space accesses:
@@ -119,7 +122,7 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)* cdns_pci_map_bus(), other region registers are set here once for all. */ addr1 =0 ;/* Should be programmed to zero. */ - desc1 =CDNS_PCIE_AT_OB_REGION_DESC1_BUS (bus_range->start); + desc1 =CDNS_PCIE_AT_OB_REGION_DESC1_BUS (busnr);cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (0 ), addr1);cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC1 (0 ), desc1);
@@ -136,12 +139,14 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)u64 pci_addr = res->start - entry->offset;if (resource_type (res) ==IORESOURCE_IO ) -cdns_pcie_set_outbound_region (pcie,0 , r, true, +cdns_pcie_set_outbound_region (pcie, busnr,0 , r, + true,pci_pio_to_address (res->start), pci_addr,resource_size (res));else -cdns_pcie_set_outbound_region (pcie,0 , r, false, +cdns_pcie_set_outbound_region (pcie, busnr,0 , r, + false, res->start, pci_addr,resource_size (res));
@@ -167,18 +172,13 @@ static int cdns_pcie_host_init(struct device *dev, struct cdns_pcie_rc *rc) {struct pci_host_bridge *bridge =pci_host_bridge_from_priv (rc); -struct resource *bus_range =NULL ;int err;/* Parse our PCI ranges and request their resources */ - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows,NULL , - &bus_range); + err =pci_parse_request_of_pci_ranges (dev, &bridge->windows,NULL ,NULL );if (err)return err; - rc->bus_range = bus_range; - rc->pcie.bus = bus_range->start; - err =cdns_pcie_host_init_root_port (rc);if (err)return err;
@@ -239,7 +239,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)if (ret) goto err_init; - bridge->busnr = pcie->bus; bridge->ops = &cdns_pcie_host_ops; bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle;
drivers/pci/controller/cadence/pcie-cadence.c +5 -4
@@ -7,7 +7,7 @@#include "pcie-cadence.h" -void cdns_pcie_set_outbound_region (struct cdns_pcie *pcie,u8 fn, +void cdns_pcie_set_outbound_region (struct cdns_pcie *pcie,u8 busnr,u8 fn,u32 r,bool is_io,u64 cpu_addr,u64 pci_addr,size_t size) {
@@ -60,7 +60,7 @@ void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 fn,/* The device and function numbers are always 0. */ desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID |CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (0 ); - desc1 |=CDNS_PCIE_AT_OB_REGION_DESC1_BUS (pcie->bus); + desc1 |=CDNS_PCIE_AT_OB_REGION_DESC1_BUS (busnr); }else {/* * Use captured values for bus and device numbers but still
@@ -82,7 +82,8 @@ void cdns_pcie_set_outbound_region(struct cdns_pcie *pcie, u8 fn,cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (r), addr1); } -void cdns_pcie_set_outbound_region_for_normal_msg (struct cdns_pcie *pcie,u8 fn, +void cdns_pcie_set_outbound_region_for_normal_msg (struct cdns_pcie *pcie, +u8 busnr,u8 fn,u32 r,u64 cpu_addr) {u32 addr0, addr1, desc0, desc1;
@@ -94,7 +95,7 @@ void cdns_pcie_set_outbound_region_for_normal_msg(struct cdns_pcie *pcie, u8 fn,if (pcie->is_rc) { desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID |CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (0 ); - desc1 |=CDNS_PCIE_AT_OB_REGION_DESC1_BUS (pcie->bus); + desc1 |=CDNS_PCIE_AT_OB_REGION_DESC1_BUS (busnr); }else { desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (fn); }
drivers/pci/controller/cadence/pcie-cadence.h +3 -5
@@ -235,7 +235,6 @@ struct cdns_pcie {struct resource *mem_res;struct device *dev;bool is_rc; -u8 bus;int phy_count;struct phy **phy;struct device_link **link;
@@ -248,7 +247,6 @@ struct cdns_pcie {* @dev: pointer to PCIe device * @cfg_res: start/end offsets in the physical system memory to map PCI * configuration space accesses -* @bus_range: first/last buses behind the PCIe host controller * @cfg_base: IO mapped window to access the PCI configuration space of a * single function at a time * @no_bar_nbits: Number of bits to keep for inbound (PCIe -> CPU) address
@@ -259,7 +257,6 @@ struct cdns_pcie {struct cdns_pcie_rc {struct cdns_pcie pcie;struct resource *cfg_res; -struct resource *bus_range;void __iomem *cfg_base;u32 no_bar_nbits;u32 vendor_id;
@@ -381,11 +378,12 @@ static inline int cdns_pcie_ep_setup(struct cdns_pcie_ep *ep) return 0; }#endif -void cdns_pcie_set_outbound_region (struct cdns_pcie *pcie,u8 fn, +void cdns_pcie_set_outbound_region (struct cdns_pcie *pcie,u8 busnr,u8 fn,u32 r,bool is_io,u64 cpu_addr,u64 pci_addr,size_t size); -void cdns_pcie_set_outbound_region_for_normal_msg (struct cdns_pcie *pcie,u8 fn, +void cdns_pcie_set_outbound_region_for_normal_msg (struct cdns_pcie *pcie, +u8 busnr,u8 fn,u32 r,u64 cpu_addr);void cdns_pcie_reset_outbound_region (struct cdns_pcie *pcie,u32 r);
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 14/19 PCI: rcar: Use devm_pci_alloc_host_bridge()
In reply to Rob HerringMove to the resource managed devm_pci_alloc_host_bridge() and simplify the error path.
--- drivers/pci/controller/pcie-rcar-host.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/pci/controller/pcie-rcar-host.c +2 -5
@@ -940,7 +940,7 @@ static int rcar_pcie_probe(struct platform_device *pdev)int err;struct pci_host_bridge *bridge; - bridge =pci_alloc_host_bridge (sizeof (*host)); + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*host));if (!bridge)return -ENOMEM ;
@@ -952,7 +952,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) err =pci_parse_request_of_pci_ranges (dev, &host->resources, &bridge->dma_ranges,NULL );if (err) - goto err_free_bridge; +return err;pm_runtime_enable (pcie->dev); err =pm_runtime_get_sync (pcie->dev);
@@ -1034,9 +1034,6 @@ static int rcar_pcie_probe(struct platform_device *pdev)pm_runtime_disable (dev);pci_free_resource_list (&host->resources); -err_free_bridge: -pci_free_host_bridge (bridge); -return err; }
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 15/19 PCI: rcar: Use struct pci_host_bridge.windows list directly
In reply to Rob HerringThere's no need to create a temporary resource list and then splice it to struct pci_host_bridge.windows list. Just use pci_host_bridge.windows directly. The necessary clean-up is already handled by the PCI core.
--- drivers/pci/controller/pcie-rcar-host.c | 45 +++---------------------- 1 file changed, 4 insertions(+), 41 deletions(-)
drivers/pci/controller/pcie-rcar-host.c +4 -41
@@ -53,7 +53,6 @@ struct rcar_pcie_host {struct device *dev;struct phy *phy;void __iomem *base; -struct list_head resources;struct clk *bus_clk;struct rcar_msi msi;int (*phy_init_fn)(struct rcar_pcie_host *host);
@@ -203,38 +202,6 @@ static struct pci_ops rcar_pcie_ops = { .write = rcar_pcie_write_conf, }; -static int rcar_pcie_setup (struct list_head *resource, -struct rcar_pcie_host *host) -{ -struct pci_host_bridge *bridge =pci_host_bridge_from_priv (host); -struct resource_entry *win; -int i =0 ; - -/* Setup PCI resources */ -resource_list_for_each_entry (win, &host->resources) { -struct resource *res = win->res; - -if (!res->flags) -continue ; - -switch (resource_type (res)) { -case IORESOURCE_IO : -case IORESOURCE_MEM : -rcar_pcie_set_outbound (&host->pcie, i, win); - i++; -break ; -case IORESOURCE_BUS : -break ; -default : -continue ; - } - -pci_add_resource (resource, res); - } - -return 1 ; -} -static void rcar_pcie_force_speedup (struct rcar_pcie *pcie) {struct device *dev = pcie->dev;
@@ -292,6 +259,7 @@ static void rcar_pcie_force_speedup(struct rcar_pcie *pcie)static void rcar_pcie_hw_enable (struct rcar_pcie_host *host) {struct rcar_pcie *pcie = &host->pcie; +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (host);struct resource_entry *win;LIST_HEAD (res);int i =0 ;
@@ -300,7 +268,7 @@ static void rcar_pcie_hw_enable(struct rcar_pcie_host *host)rcar_pcie_force_speedup (pcie);/* Setup PCI resources */ -resource_list_for_each_entry (win, &host->resources) { +resource_list_for_each_entry (win, &bridge->windows) {struct resource *res = win->res;if (!res->flags)
@@ -319,12 +287,8 @@ static void rcar_pcie_hw_enable(struct rcar_pcie_host *host)static int rcar_pcie_enable (struct rcar_pcie_host *host) {struct pci_host_bridge *bridge =pci_host_bridge_from_priv (host); -struct rcar_pcie *pcie = &host->pcie; -/* Try setting 5 GT/s link speed */ -rcar_pcie_force_speedup (pcie); - -rcar_pcie_setup (&bridge->windows, host); +rcar_pcie_hw_enable (host);pci_add_flags (PCI_REASSIGN_ALL_BUS );
@@ -949,7 +913,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) pcie->dev = dev;platform_set_drvdata (pdev, host); - err =pci_parse_request_of_pci_ranges (dev, &host->resources, + err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, &bridge->dma_ranges,NULL );if (err)return err;
@@ -1032,7 +996,6 @@ static int rcar_pcie_probe(struct platform_device *pdev) err_pm_disable:pm_runtime_disable (dev); -pci_free_resource_list (&host->resources);return err; }
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 16/19 PCI: of: Reduce missing non-prefetchable memory region to a warning
In reply to Rob HerringThe pci-rcar-gen2 controller requires only a prefetchable memory region, and the error prevents using pci_parse_request_of_pci_ranges() for it. Let's reduce this to just a warning message so this function can be used for pci-rcar-gen2.
--- drivers/pci/of.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/pci/of.c +3 -4
@@ -564,11 +564,10 @@ int pci_parse_request_of_pci_ranges(struct device *dev, } } -if (res_valid) -return 0 ; +if (!res_valid) +dev_warn (dev,"non-prefetchable memory resource required\n" ); -dev_err (dev,"non-prefetchable memory resource required\n" ); - err = -EINVAL ; +return 0 ; out_release_res:pci_free_resource_list (resources);
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 17/19 PCI: rcar-gen2: Convert to use modern host bridge probe functions
In reply to Rob HerringThe rcar-gen2 host driver still uses the old Arm PCI setup function pci_common_init_dev(). Let's update it to use the modern devm_pci_alloc_host_bridge(), pci_parse_request_of_pci_ranges() and pci_host_probe() functions.
--- drivers/pci/controller/pci-rcar-gen2.c | 168 +++++++------------------ 1 file changed, 46 insertions(+), 122 deletions(-)
drivers/pci/controller/pci-rcar-gen2.c +46 -122
@@ -98,22 +98,17 @@ struct rcar_pci_priv {void __iomem *reg;struct resource mem_res;struct resource *cfg_res; -unsigned busnr;int irq; -unsigned long window_size; -unsigned long window_addr; -unsigned long window_pci; };/* PCI configuration space operations */ static void __iomem *rcar_pci_cfg_base (struct pci_bus *bus,unsigned int devfn,int where) { -struct pci_sys_data *sys = bus->sysdata; -struct rcar_pci_priv *priv = sys->private_data; +struct rcar_pci_priv *priv = bus->sysdata;int slot, val; -if (sys->busnr != bus->number ||PCI_FUNC (devfn)) +if (!pci_is_root_bus (bus) ||PCI_FUNC (devfn))return NULL ;/* Only one EHCI/OHCI device built-in */
@@ -132,20 +127,6 @@ static void __iomem *rcar_pci_cfg_base(struct pci_bus *bus, unsigned int devfn,return priv->reg + (slot >>1 ) *0x100 + where; } -/* PCI interrupt mapping */ -static int rcar_pci_map_irq (const struct pci_dev *dev,u8 slot,u8 pin) -{ -struct pci_sys_data *sys = dev->bus->sysdata; -struct rcar_pci_priv *priv = sys->private_data; -int irq; - - irq =of_irq_parse_and_map_pci (dev, slot, pin); -if (!irq) - irq = priv->irq; - -return irq; -} -#ifdef CONFIG_PCI_DEBUG /* if debug enabled, then attach an error handler irq to the bridge */
@@ -189,19 +170,33 @@ static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { }#endif /* PCI host controller setup */ -static int rcar_pci_setup (int nr,struct pci_sys_data *sys) +static void rcar_pci_setup (struct rcar_pci_priv *priv) { -struct rcar_pci_priv *priv = sys->private_data; +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (priv);struct device *dev = priv->dev;void __iomem *reg = priv->reg; +struct resource_entry *entry; +unsigned long window_size; +unsigned long window_addr; +unsigned long window_pci;u32 val; -int ret; + + entry =resource_list_first_type (&bridge->dma_ranges,IORESOURCE_MEM ); +if (!entry) { + window_addr =0x40000000 ; + window_pci =0x40000000 ; + window_size =SZ_1G ; + }else { + window_addr = entry->res->start; + window_pci = entry->res->start - entry->offset; + window_size =resource_size (entry->res); + }pm_runtime_enable (dev);pm_runtime_get_sync (dev); val =ioread32 (reg +RCAR_PCI_UNIT_REV_REG ); -dev_info (dev,"PCI: bus%u revision %x\n" , sys->busnr, val); +dev_info (dev,"PCI: revision %x\n" , val);/* Disable Direct Power Down State and assert reset */ val =ioread32 (reg +RCAR_USBCTR_REG ) & ~RCAR_USBCTR_DIRPD ;
@@ -214,7 +209,7 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys) RCAR_USBCTR_USBH_RST | RCAR_USBCTR_PLL_RST);/* Setup PCIAHB window1 size */ -switch (priv->window_size) { +switch (window_size) {case SZ_2G : val |=RCAR_USBCTR_PCIAHB_WIN1_2G ;break ;
@@ -226,8 +221,8 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys)break ;default :pr_warn ("unknown window size %ld - defaulting to 256M\n" , - priv->window_size); - priv->window_size =SZ_256M ; + window_size); + window_size =SZ_256M ;/* fall-through */ case SZ_256M : val |=RCAR_USBCTR_PCIAHB_WIN1_256M ;
@@ -245,7 +240,7 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys)iowrite32 (val, reg +RCAR_PCI_ARBITER_CTR_REG );/* PCI-AHB mapping */ -iowrite32 (priv->window_addr |RCAR_PCIAHB_PREFETCH16 , +iowrite32 (window_addr |RCAR_PCIAHB_PREFETCH16 , reg +RCAR_PCIAHB_WIN1_CTR_REG );/* AHB-PCI mapping: OHCI/EHCI registers */
@@ -256,7 +251,7 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys)iowrite32 (RCAR_AHBPCI_WIN1_HOST |RCAR_AHBPCI_WIN_CTR_CFG , reg +RCAR_AHBPCI_WIN1_CTR_REG );/* Set PCI-AHB Window1 address */ -iowrite32 (priv->window_pci |PCI_BASE_ADDRESS_MEM_PREFETCH , +iowrite32 (window_pci |PCI_BASE_ADDRESS_MEM_PREFETCH , reg +PCI_BASE_ADDRESS_1 );/* Set AHB-PCI bridge PCI communication area address */ val = priv->cfg_res->start +RCAR_AHBPCI_PCICOM_OFFSET ;
@@ -271,18 +266,7 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys)iowrite32 (RCAR_PCI_INT_A |RCAR_PCI_INT_B |RCAR_PCI_INT_PME , reg +RCAR_PCI_INT_ENABLE_REG ); -if (priv->irq >0 ) -rcar_pci_setup_errirq (priv); - -/* Add PCI resources */ -pci_add_resource (&sys->resources, &priv->mem_res); - ret =devm_request_pci_bus_resources (dev, &sys->resources); -if (ret <0 ) -return ret; - -/* Setup bus number based on platform device id / of bus-range */ - sys->busnr = priv->busnr; -return 1 ; +rcar_pci_setup_errirq (priv); }static struct pci_ops rcar_pci_ops = {
@@ -291,55 +275,21 @@ static struct pci_ops rcar_pci_ops = { .write = pci_generic_config_write, }; -static int rcar_pci_parse_map_dma_ranges (struct rcar_pci_priv *pci, -struct device_node *np) -{ -struct device *dev = pci->dev; -struct of_pci_range range; -struct of_pci_range_parser parser; -int index =0 ; - -/* Failure to parse is ok as we fall back to defaults */ -if (of_pci_dma_range_parser_init (&parser, np)) -return 0 ; - -/* Get the dma-ranges from DT */ -for_each_of_pci_range (&parser, &range) { -/* Hardware only allows one inbound 32-bit range */ -if (index) -return -EINVAL ; - - pci->window_addr = (unsigned long )range.cpu_addr; - pci->window_pci = (unsigned long )range.pci_addr; - pci->window_size = (unsigned long )range.size; - -/* Catch HW limitations */ -if (!(range.flags &IORESOURCE_PREFETCH )) { -dev_err (dev,"window must be prefetchable\n" ); -return -EINVAL ; - } -if (pci->window_addr) { -u32 lowaddr =1 << (ffs (pci->window_addr) -1 ); - -if (lowaddr < pci->window_size) { -dev_err (dev,"invalid window size/addr\n" ); -return -EINVAL ; - } - } - index++; - } - -return 0 ; -} -static int rcar_pci_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct resource *cfg_res, *mem_res;struct rcar_pci_priv *priv; +struct pci_host_bridge *bridge;void __iomem *reg; -struct hw_pci hw; -void *hw_private[1 ]; +int ret; + + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*priv)); +if (!bridge) +return -ENOMEM ; + + priv =pci_host_bridge_priv (bridge); + bridge->sysdata = priv; cfg_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); reg =devm_ioremap_resource (dev, cfg_res);
@@ -369,44 +319,18 @@ static int rcar_pci_probe(struct platform_device *pdev)return priv->irq; } -/* default window addr and size if not specified in DT */ - priv->window_addr =0x40000000 ; - priv->window_pci =0x40000000 ; - priv->window_size =SZ_1G ; - -if (dev->of_node) { -struct resource busnr; -int ret; - - ret =of_pci_parse_bus_range (dev->of_node, &busnr); -if (ret <0 ) { -dev_err (dev,"failed to parse bus-range\n" ); -return ret; - } - - priv->busnr = busnr.start; -if (busnr.end != busnr.start) -dev_warn (dev,"only one bus number supported\n" ); - - ret =rcar_pci_parse_map_dma_ranges (priv, dev->of_node); -if (ret <0 ) { -dev_err (dev,"failed to parse dma-range\n" ); -return ret; - } - }else { - priv->busnr = pdev->id; - } + ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, + &bridge->dma_ranges,NULL ); +if (ret) +return ret; + + bridge->ops = &rcar_pci_ops; + +pci_add_flags (PCI_REASSIGN_ALL_BUS ); + +rcar_pci_setup (priv); - hw_private[0 ] = priv; -memset (&hw,0 ,sizeof (hw)); - hw.nr_controllers =ARRAY_SIZE (hw_private); - hw.io_optional =1 ; - hw.private_data = hw_private; - hw.map_irq = rcar_pci_map_irq; - hw.ops = &rcar_pci_ops; - hw.setup = rcar_pci_setup; -pci_common_init_dev (dev, &hw); -return 0 ; +return pci_host_probe (bridge); }static const struct of_device_id rcar_pci_of_match[] = {
Signature · 1 line
2.25.1
Re: [PATCH 17/19] PCI: rcar-gen2: Convert to use modern host bridge probe functions
Hi Rob,
Quoted 11 lines · Rob Herring
The rcar-gen2 host driver still uses the old Arm PCI setup function
pci_common_init_dev(). Let's update it to use the moderndevm_pci_alloc_host_bridge(),pci_parse_request_of_pci_ranges()andpci_host_probe()functions.Cc Marek Vasut <[email protected]>Cc Yoshihiro Shimoda <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Signed-off-by Rob Herring <[email protected]>
This is now commit 92d69cc6275845a7 ("PCI: rcar-gen2: Convert to use modern host bridge probe functions"), and causes a crash on r8a7791/koelsch:
Unable to handle kernel NULL pointer dereference at virtual address 00000008
pgd = (ptrval)
[00000008] *pgd=00000000
Internal error: Oops: 5 [#1] SMP ARM
CPU: 0 PID: 1 Comm: swapper/0 Not tainted
5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645
Hardware name: Generic R-Car Gen2 (Flattened Device Tree)
PC is at rcar_pci_probe+0x154/0x340
LR is at _raw_spin_unlock_irqrestore+0x18/0x20Quoted 11 lines
drivers/pci/controller/pci-rcar-gen2.c +2
-2@@ -189,19 +170,33 @@ static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { }#endif /* PCI host controller setup */ -static int rcar_pci_setup (int nr,struct pci_sys_data *sys) +static void rcar_pci_setup (struct rcar_pci_priv *priv) { -struct rcar_pci_priv *priv = sys->private_data; +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (priv);
drivers/pci/controller/pci-rcar-gen2.c static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { } · line 184
Quoted 10 lines
drivers/pci/controller/pci-rcar-gen2.c +6
-1struct device *dev = priv->dev;void __iomem *reg = priv->reg; +struct resource_entry *entry; +unsigned long window_size; +unsigned long window_addr; +unsigned long window_pci;u32 val; -int ret; + + entry =resource_list_first_type (&bridge->dma_ranges,IORESOURCE_MEM );
bridge->dma_ranges is not initialized => BOOM.
Quoted 6 lines
drivers/pci/controller/pci-rcar-gen2.c +1
-0static int rcar_pci_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct resource *cfg_res, *mem_res;struct rcar_pci_priv *priv; +struct pci_host_bridge *bridge;
drivers/pci/controller/pci-rcar-gen2.c static struct pci_ops rcar_pci_ops = { · line 291
Quoted 10 lines
drivers/pci/controller/pci-rcar-gen2.c +7
-2void __iomem *reg; -struct hw_pci hw; -void *hw_private[1 ]; +int ret; + + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*priv)); +if (!bridge) +return -ENOMEM ; + + priv =pci_host_bridge_priv (bridge);
This is the "new" priv instance.
drivers/pci/controller/pci-rcar-gen2.c static struct pci_ops rcar_pci_ops = { · line 295
Quoted 4 lines
drivers/pci/controller/pci-rcar-gen2.c +1
-0+ bridge->sysdata = priv; cfg_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); reg =devm_ioremap_resource (dev, cfg_res);
However, the "old" instance is still allocated below, and should be removed.
I've send a patch to fix that, which should appear soon at
https://lore.kernel.org/r/[email protected]
BTW, the conversion has the following impact on r8a7791/koelsch:
-pci-rcar-gen2 ee090000.pci: PCI: bus0 revision 11
+pci-rcar-gen2 ee090000.pci: host bridge /soc/pci@ee090000 ranges:
+pci-rcar-gen2 ee090000.pci: MEM 0x00ee080000..0x00ee08ffff
-> 0x00ee080000
+pci-rcar-gen2 ee090000.pci: PCI: revision 11
pci-rcar-gen2 ee090000.pci: PCI host bridge to bus 0000:00
-pci_bus 0000:00: root bus resource [mem 0xee080000-0xee0810ff]
^^^^^^^^^^^^^^^^^^^^^
-pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
+pci_bus 0000:00: root bus resource [bus 00]
+pci_bus 0000:00: root bus resource [mem 0xee080000-0xee08ffff]
^^^^^^^^^^^^^^^^^^^^^
pci0: pci@ee090000 {
...
reg = <0 0xee090000 0 0xc00>,
<0 0xee080000 0 0x1100>;
...
ranges = <0x02000000 0 0xee080000 0 0xee080000 0 0x00010000>;
...
usb@1,0 {
reg = <0x800 0 0 0 0>;
...
};
usb@2,0 {
reg = <0x1000 0 0 0 0>;
...
};
}The old root bus resource size was based on the "reg" property. The new root bus resource size is based on the "ranges" property.
Given the only children are hardcoded, I guess that is OK?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Rob Herring
maintainerRe: [PATCH 17/19] PCI: rcar-gen2: Convert to use modern host bridge probe functions
Quoted 16 lines · Geert Uytterhoeven
Hi Rob,
Quoted 11 lines · Rob Herring
The rcar-gen2 host driver still uses the old Arm PCI setup function
pci_common_init_dev(). Let's update it to use the moderndevm_pci_alloc_host_bridge(),pci_parse_request_of_pci_ranges()andpci_host_probe()functions.Cc Marek Vasut <[email protected]>Cc Yoshihiro Shimoda <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Bjorn Helgaas <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 2 lines
This is now commit
92d69cc6275845a7("PCI: rcar-gen2: Convert to use modern host bridge probe functions"), and causes a crash on r8a7791/koelsch:
Can't say I'm surprised, this was a big change. Thanks for testing.
Quoted 97 lines
Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = (ptrval) [00000008] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1-shmobile-00035-g92d69cc6275845a7 #645 Hardware name: Generic R-Car Gen2 (Flattened Device Tree) PC is at rcar_pci_probe+0x154/0x340 LR is at _raw_spin_unlock_irqrestore+0x18/0x20Quoted 11 lines
drivers/pci/controller/pci-rcar-gen2.c +2
-2@@ -189,19 +170,33 @@ static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { }#endif /* PCI host controller setup */ -static int rcar_pci_setup (int nr,struct pci_sys_data *sys) +static void rcar_pci_setup (struct rcar_pci_priv *priv) { -struct rcar_pci_priv *priv = sys->private_data; +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (priv);drivers/pci/controller/pci-rcar-gen2.c static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { } · line 184
Quoted 10 lines
drivers/pci/controller/pci-rcar-gen2.c +6
-1struct device *dev = priv->dev;void __iomem *reg = priv->reg; +struct resource_entry *entry; +unsigned long window_size; +unsigned long window_addr; +unsigned long window_pci;u32 val; -int ret; + + entry =resource_list_first_type (&bridge->dma_ranges,IORESOURCE_MEM );
bridge->dma_rangesis not initialized => BOOM.Quoted 6 lines
drivers/pci/controller/pci-rcar-gen2.c +1
-0static int rcar_pci_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct resource *cfg_res, *mem_res;struct rcar_pci_priv *priv; +struct pci_host_bridge *bridge;drivers/pci/controller/pci-rcar-gen2.c static struct pci_ops rcar_pci_ops = { · line 291
Quoted 10 lines
drivers/pci/controller/pci-rcar-gen2.c +7
-2void __iomem *reg; -struct hw_pci hw; -void *hw_private[1 ]; +int ret; + + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*priv)); +if (!bridge) +return -ENOMEM ; + + priv =pci_host_bridge_priv (bridge);This is the "new" priv instance.
drivers/pci/controller/pci-rcar-gen2.c static struct pci_ops rcar_pci_ops = { · line 295
Quoted 4 lines
drivers/pci/controller/pci-rcar-gen2.c +1
-0+ bridge->sysdata = priv; cfg_res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); reg =devm_ioremap_resource (dev, cfg_res);However, the "old" instance is still allocated below, and should be removed.
I've send a patch to fix that, which should appear soon at
https://lore.kernel.org/r/20200804120430.9253-1-geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.orgBTW, the conversion has the following impact on r8a7791/koelsch:
-pci-rcar-gen2 ee090000.pci: PCI: bus0 revision 11 +pci-rcar-gen2 ee090000.pci: host bridge /soc/pci@ee090000 ranges: +pci-rcar-gen2 ee090000.pci: MEM 0x00ee080000..0x00ee08ffff -> 0x00ee080000 +pci-rcar-gen2 ee090000.pci: PCI: revision 11 pci-rcar-gen2 ee090000.pci: PCI host bridge to bus 0000:00 -pci_bus 0000:00: root bus resource [mem 0xee080000-0xee0810ff] ^^^^^^^^^^^^^^^^^^^^^ -pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff] +pci_bus 0000:00: root bus resource [bus 00] +pci_bus 0000:00: root bus resource [mem 0xee080000-0xee08ffff] ^^^^^^^^^^^^^^^^^^^^^ pci0: pci@ee090000 { ... reg = <0 0xee090000 0 0xc00>, <0 0xee080000 0 0x1100>; ... ranges = <0x02000000 0 0xee080000 0 0xee080000 0 0x00010000>; ... usb@1,0 { reg = <0x800 0 0 0 0>; ... }; usb@2,0 { reg = <0x1000 0 0 0 0>; ... }; }
Quoted 2 lines
The old root bus resource size was based on the "reg" property. The new root bus resource size is based on the "ranges" property.
That was wrong to have PCI memory space in 'reg', but the driver could always adjust the size to 0x1100 if needed.
BTW, the binding description seems to have the 'reg' description reversed.
Quoted 1 line
Given the only children are hardcoded, I guess that is OK?
In the sense that those are the only 2 devices and you know their memory fits, yes. However, the memory space itself isn't hardcoded. If you wanted to do that, then the children really need 'assigned-addresses' properties. I guess it happens to work because memory space is allocated from the start and goes in order of device addresses. But if that changed to top down allocation?
Rob
Rob Herring
maintainerPATCH 18/19 PCI: Move DT resource setup into devm_pci_alloc_host_bridge()
In reply to Rob HerringNow that pci_parse_request_of_pci_ranges() callers just setup pci_host_bridge.windows and dma_ranges directly and don't need the bus range returned, we can just initialize them when allocating the pci_host_bridge struct.
With this, pci_parse_request_of_pci_ranges() becomes a static function.
--- .../controller/cadence/pcie-cadence-host.c | 6 --- .../pci/controller/dwc/pcie-designware-host.c | 5 --- .../controller/mobiveil/pcie-mobiveil-host.c | 8 ---- drivers/pci/controller/pci-aardvark.c | 7 ---- drivers/pci/controller/pci-ftpci100.c | 5 --- drivers/pci/controller/pci-host-common.c | 13 +++---- drivers/pci/controller/pci-loongson.c | 7 ---- drivers/pci/controller/pci-rcar-gen2.c | 6 --- drivers/pci/controller/pci-tegra.c | 6 --- drivers/pci/controller/pci-v3-semi.c | 5 --- drivers/pci/controller/pci-versatile.c | 7 +--- drivers/pci/controller/pci-xgene.c | 5 --- drivers/pci/controller/pcie-altera.c | 7 ---- drivers/pci/controller/pcie-brcmstb.c | 5 --- drivers/pci/controller/pcie-iproc-platform.c | 7 ---- drivers/pci/controller/pcie-mediatek.c | 7 ---- drivers/pci/controller/pcie-rcar-host.c | 5 --- drivers/pci/controller/pcie-rockchip-host.c | 5 --- drivers/pci/controller/pcie-xilinx-nwl.c | 7 ---- drivers/pci/controller/pcie-xilinx.c | 7 ---- drivers/pci/of.c | 37 +++++++++---------- drivers/pci/pci.h | 8 ++++ drivers/pci/probe.c | 4 ++ include/linux/pci.h | 12 ------ 24 files changed, 36 insertions(+), 155 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +0 -6
@@ -171,14 +171,8 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc)static int cdns_pcie_host_init (struct device *dev,struct cdns_pcie_rc *rc) { -struct pci_host_bridge *bridge =pci_host_bridge_from_priv (rc);int err; -/* Parse our PCI ranges and request their resources */ - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows,NULL ,NULL ); -if (err) -return err; - err =cdns_pcie_host_init_root_port (rc);if (err)return err;
drivers/pci/controller/dwc/pcie-designware-host.c +0 -5
@@ -346,11 +346,6 @@ int dw_pcie_host_init(struct pcie_port *pp)if (!bridge)return -ENOMEM ; - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) -return ret; -/* Get the I/O and memory ranges from DT */ resource_list_for_each_entry (win, &bridge->windows) {switch (resource_type (win->res)) {
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +0 -8
@@ -577,14 +577,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)if (!mobiveil_pcie_is_bridge (pcie))return -ENODEV ; -/* parse the host bridge base addresses from the device tree file */ - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) { -dev_err (dev,"Getting bridge resources failed\n" ); -return ret; - } -/* * configure all inbound and outbound windows and prepare the RC for * config access
drivers/pci/controller/pci-aardvark.c +0 -7
@@ -1132,13 +1132,6 @@ static int advk_pcie_probe(struct platform_device *pdev)return ret; } - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) { -dev_err (dev,"Failed to parse resources\n" ); -return ret; - } - pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, "reset-gpios", 0, GPIOD_OUT_LOW,
drivers/pci/controller/pci-ftpci100.c +0 -5
@@ -467,11 +467,6 @@ static int faraday_pci_probe(struct platform_device *pdev)if (IS_ERR (p->base))return PTR_ERR (p->base); - ret =pci_parse_request_of_pci_ranges (dev, &host->windows, - &host->dma_ranges,NULL ); -if (ret) -return ret; - win =resource_list_first_type (&host->windows,IORESOURCE_IO );if (win) { io = win->res;
drivers/pci/controller/pci-host-common.c +6 -7
@@ -25,21 +25,20 @@ static struct pci_config_window *gen_pci_init(struct device *dev, {int err;struct resource cfgres; -struct resource *bus_range =NULL ; +struct resource_entry *bus;struct pci_config_window *cfg; -/* Parse our PCI ranges and request their resources */ - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows,NULL , &bus_range); -if (err) -return ERR_PTR (err); - err =of_address_to_resource (dev->of_node,0 , &cfgres);if (err) {dev_err (dev,"missing \"reg\" property\n" );return ERR_PTR (err); } - cfg =pci_ecam_create (dev, &cfgres, bus_range, ops); + bus =resource_list_first_type (&bridge->windows,IORESOURCE_BUS ); +if (!bus) +return ERR_PTR (-ENODEV ); + + cfg =pci_ecam_create (dev, &cfgres, bus->res, ops);if (IS_ERR (cfg))return cfg;
drivers/pci/controller/pci-loongson.c +0 -7
@@ -218,13 +218,6 @@ static int loongson_pci_probe(struct platform_device *pdev) } } - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (err) { -dev_err (dev,"failed to get bridge resources\n" ); -return err; - } - bridge->sysdata = priv; bridge->ops = &loongson_pci_ops; bridge->map_irq = loongson_map_irq;
drivers/pci/controller/pci-rcar-gen2.c +0 -6
@@ -282,7 +282,6 @@ static int rcar_pci_probe(struct platform_device *pdev)struct rcar_pci_priv *priv;struct pci_host_bridge *bridge;void __iomem *reg; -int ret; bridge =devm_pci_alloc_host_bridge (dev,sizeof (*priv));if (!bridge)
@@ -319,11 +318,6 @@ static int rcar_pci_probe(struct platform_device *pdev)return priv->irq; } - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) -return ret; - bridge->ops = &rcar_pci_ops;pci_add_flags (PCI_REASSIGN_ALL_BUS );
drivers/pci/controller/pci-tegra.c +0 -6
@@ -2684,12 +2684,6 @@ static int tegra_pcie_probe(struct platform_device *pdev)INIT_LIST_HEAD (&pcie->ports); pcie->dev = dev; - err =pci_parse_request_of_pci_ranges (dev, &host->windows,NULL ,NULL ); -if (err) { -dev_err (dev,"Getting bridge resources failed\n" ); -return err; - } - err =tegra_pcie_parse_dt (pcie);if (err <0 )return err;
drivers/pci/controller/pci-v3-semi.c +0 -5
@@ -764,11 +764,6 @@ static int v3_pci_probe(struct platform_device *pdev)if (IS_ERR (v3->config_base))return PTR_ERR (v3->config_base); - ret =pci_parse_request_of_pci_ranges (dev, &host->windows, - &host->dma_ranges,NULL ); -if (ret) -return ret; -/* Get and request error IRQ resource */ irq =platform_get_irq (pdev,0 );if (irq <0 ) {
drivers/pci/controller/pci-versatile.c +1 -6
@@ -67,7 +67,7 @@ static int versatile_pci_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct resource *res;struct resource_entry *entry; -int ret, i, myslot =-1 , mem =1 ; +int i, myslot =-1 , mem =1 ;u32 val;void __iomem *local_pci_cfg_base;struct pci_host_bridge *bridge;
@@ -91,11 +91,6 @@ static int versatile_pci_probe(struct platform_device *pdev)if (IS_ERR (versatile_cfg_base[1 ]))return PTR_ERR (versatile_cfg_base[1 ]); - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, -NULL ,NULL ); -if (ret) -return ret; -resource_list_for_each_entry (entry, &bridge->windows) {if (resource_type (entry->res) ==IORESOURCE_MEM ) {writel (entry->res->start >>28 ,PCI_IMAP (mem));
drivers/pci/controller/pci-xgene.c +0 -5
@@ -615,11 +615,6 @@ static int xgene_pcie_probe(struct platform_device *pdev)if (ret)return ret; - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) -return ret; - ret =xgene_pcie_setup (port);if (ret)return ret;
drivers/pci/controller/pcie-altera.c +0 -7
@@ -797,13 +797,6 @@ static int altera_pcie_probe(struct platform_device *pdev)return ret; } - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) { -dev_err (dev,"Failed add resources\n" ); -return ret; - } - ret =altera_pcie_init_irq_domain (pcie);if (ret) {dev_err (dev,"Failed creating IRQ Domain\n" );
drivers/pci/controller/pcie-brcmstb.c +0 -5
@@ -972,11 +972,6 @@ static int brcm_pcie_probe(struct platform_device *pdev) pcie->ssc =of_property_read_bool (np,"brcm,enable-ssc" ); - ret =pci_parse_request_of_pci_ranges (pcie->dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) -return ret; - ret =clk_prepare_enable (pcie->clk);if (ret) {dev_err (&pdev->dev,"could not enable clock\n" );
drivers/pci/controller/pcie-iproc-platform.c +0 -7
@@ -95,13 +95,6 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)if (IS_ERR (pcie->phy))return PTR_ERR (pcie->phy); - ret =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (ret) { -dev_err (dev,"unable to get PCI host bridge resources\n" ); -return ret; - } -/* PAXC doesn't support legacy IRQs, skip mapping */ switch (pcie->type) {case IPROC_PCIE_PAXC :
drivers/pci/controller/pcie-mediatek.c +0 -7
@@ -1029,15 +1029,8 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie)struct device *dev = pcie->dev;struct device_node *node = dev->of_node, *child;struct mtk_pcie_port *port, *tmp; -struct pci_host_bridge *host =pci_host_bridge_from_priv (pcie); -struct list_head *windows = &host->windows;int err; - err =pci_parse_request_of_pci_ranges (dev, windows, - &host->dma_ranges,NULL ); -if (err) -return err; -for_each_available_child_of_node (node, child) {int slot;
drivers/pci/controller/pcie-rcar-host.c +0 -5
@@ -913,11 +913,6 @@ static int rcar_pcie_probe(struct platform_device *pdev) pcie->dev = dev;platform_set_drvdata (pdev, host); - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (err) -return err; -pm_runtime_enable (pcie->dev); err =pm_runtime_get_sync (pcie->dev);if (err <0 ) {
drivers/pci/controller/pcie-rockchip-host.c +0 -5
@@ -989,11 +989,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev)if (err <0 ) goto err_deinit_port; - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (err) - goto err_remove_irq_domain; - err =rockchip_pcie_cfg_atu (rockchip);if (err) goto err_remove_irq_domain;
drivers/pci/controller/pcie-xilinx-nwl.c +0 -7
@@ -838,13 +838,6 @@ static int nwl_pcie_probe(struct platform_device *pdev)return err; } - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (err) { -dev_err (dev,"Getting bridge resources failed\n" ); -return err; - } - err =nwl_pcie_init_irq_domain (pcie);if (err) {dev_err (dev,"Failed creating IRQ Domain\n" );
drivers/pci/controller/pcie-xilinx.c +0 -7
@@ -641,13 +641,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev)return err; } - err =pci_parse_request_of_pci_ranges (dev, &bridge->windows, - &bridge->dma_ranges,NULL ); -if (err) { -dev_err (dev,"Getting bridge resources failed\n" ); -return err; - } - bridge->sysdata = port; bridge->ops = &xilinx_pcie_ops; bridge->map_irq = of_irq_parse_and_map_pci;
drivers/pci/of.c +17 -20
@@ -521,28 +521,26 @@ int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin)EXPORT_SYMBOL_GPL (of_irq_parse_and_map_pci);#endif /* CONFIG_OF_IRQ */ -int pci_parse_request_of_pci_ranges (struct device *dev, -struct list_head *resources, -struct list_head *ib_resources, -struct resource **bus_range) +static int pci_parse_request_of_pci_ranges (struct device *dev, +struct pci_host_bridge *bridge) {int err, res_valid =0 ;resource_size_t iobase;struct resource_entry *win, *tmp; -INIT_LIST_HEAD (resources); -if (ib_resources) -INIT_LIST_HEAD (ib_resources); - err =devm_of_pci_get_host_bridge_resources (dev,0 ,0xff , resources, - ib_resources, &iobase); +INIT_LIST_HEAD (&bridge->windows); +INIT_LIST_HEAD (&bridge->dma_ranges); + + err =devm_of_pci_get_host_bridge_resources (dev,0 ,0xff , &bridge->windows, + &bridge->dma_ranges, &iobase);if (err)return err; - err =devm_request_pci_bus_resources (dev, resources); + err =devm_request_pci_bus_resources (dev, &bridge->windows);if (err) - goto out_release_res; +return err; -resource_list_for_each_entry_safe (win, tmp, resources) { +resource_list_for_each_entry_safe (win, tmp, &bridge->windows) {struct resource *res = win->res;switch (resource_type (res)) {
@@ -557,10 +555,6 @@ int pci_parse_request_of_pci_ranges(struct device *dev,case IORESOURCE_MEM : res_valid |= !(res->flags &IORESOURCE_PREFETCH );break ; -case IORESOURCE_BUS : -if (bus_range) - *bus_range = res; -break ; } }
@@ -568,12 +562,15 @@ int pci_parse_request_of_pci_ranges(struct device *dev,dev_warn (dev,"non-prefetchable memory resource required\n" ); return 0; +} - out_release_res: -pci_free_resource_list (resources); - return err; +int devm_of_pci_bridge_init (struct device *dev,struct pci_host_bridge *bridge) +{ +if (!dev->of_node) +return 0 ; + +return pci_parse_request_of_pci_ranges (dev, bridge); } -EXPORT_SYMBOL_GPL (pci_parse_request_of_pci_ranges);#endif /* CONFIG_PCI */
drivers/pci/pci.h +8 -0
@@ -627,6 +627,8 @@ void pci_release_of_node(struct pci_dev *dev);void pci_set_bus_of_node (struct pci_bus *bus);void pci_release_bus_of_node (struct pci_bus *bus); +int devm_of_pci_bridge_init (struct device *dev,struct pci_host_bridge *bridge); +#else static inline int of_pci_parse_bus_range (struct device_node *node,struct resource *res)
@@ -650,6 +652,12 @@ static inline void pci_set_of_node(struct pci_dev *dev) { }static inline void pci_release_of_node (struct pci_dev *dev) { }static inline void pci_set_bus_of_node (struct pci_bus *bus) { }static inline void pci_release_bus_of_node (struct pci_bus *bus) { } + +static inline int devm_of_pci_bridge_init (struct device *dev,struct pci_host_bridge *bridge) +{ +return 0 ; +} +#endif /* CONFIG_OF */ #ifdef CONFIG_PCIEAER
drivers/pci/probe.c +4 -0
@@ -635,6 +635,10 @@ struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,if (ret)return NULL ; + ret =devm_of_pci_bridge_init (dev, bridge); +if (ret) +return NULL ; +return bridge; }EXPORT_SYMBOL (devm_pci_alloc_host_bridge);
include/linux/pci.h +0 -12
@@ -2303,10 +2303,6 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,struct device_node ;struct irq_domain ;struct irq_domain *pci_host_bridge_of_msi_domain (struct pci_bus *bus); -int pci_parse_request_of_pci_ranges (struct device *dev, -struct list_head *resources, -struct list_head *ib_resources, -struct resource **bus_range);/* Arch may override this (weak) */ struct device_node *pcibios_get_phb_of_node (struct pci_bus *bus);
@@ -2314,14 +2310,6 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);#else /* CONFIG_OF */ static inline struct irq_domain *pci_host_bridge_of_msi_domain (struct pci_bus *bus) {return NULL ; } -static inline int -pci_parse_request_of_pci_ranges (struct device *dev, -struct list_head *resources, -struct list_head *ib_resources, -struct resource **bus_range) -{ -return -EINVAL ; -}#endif /* CONFIG_OF */ static inline struct device_node *
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 19/19 PCI: Set bridge map_irq and swizzle_irq to default functions
In reply to Rob HerringThe majority of DT based host drivers use the default .map_irq() and .swizzle_irq() functions, so let's initialize the function pointers to the default and drop setting them in the host drivers.
Drivers like iProc which don't support legacy interrupts need to set .map_irq() back to NULL.
--- drivers/pci/controller/cadence/pcie-cadence-host.c | 2 -- drivers/pci/controller/dwc/pcie-designware-host.c | 2 -- drivers/pci/controller/mobiveil/pcie-mobiveil-host.c | 2 -- drivers/pci/controller/pci-aardvark.c | 2 -- drivers/pci/controller/pci-ftpci100.c | 2 -- drivers/pci/controller/pci-host-common.c | 2 -- drivers/pci/controller/pci-mvebu.c | 2 -- drivers/pci/controller/pci-tegra.c | 1 - drivers/pci/controller/pci-v3-semi.c | 2 -- drivers/pci/controller/pci-versatile.c | 2 -- drivers/pci/controller/pci-xgene.c | 2 -- drivers/pci/controller/pcie-altera.c | 2 -- drivers/pci/controller/pcie-brcmstb.c | 2 -- drivers/pci/controller/pcie-iproc-platform.c | 3 ++- drivers/pci/controller/pcie-iproc.c | 1 - drivers/pci/controller/pcie-mediatek.c | 2 -- drivers/pci/controller/pcie-rcar-host.c | 2 -- drivers/pci/controller/pcie-rockchip-host.c | 2 -- drivers/pci/controller/pcie-xilinx-nwl.c | 2 -- drivers/pci/controller/pcie-xilinx.c | 2 -- drivers/pci/of.c | 3 +++ 21 files changed, 5 insertions(+), 37 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +0 -2
@@ -234,8 +234,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) goto err_init; bridge->ops = &cdns_pcie_host_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle; ret =pci_host_probe (bridge);if (ret <0 )
drivers/pci/controller/dwc/pcie-designware-host.c +0 -2
@@ -467,8 +467,6 @@ int dw_pcie_host_init(struct pcie_port *pp) bridge->sysdata = pp; bridge->ops = &dw_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle; ret =pci_scan_root_bus_bridge (bridge);if (ret)
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +0 -2
@@ -596,8 +596,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)/* Initialize bridge */ bridge->sysdata = pcie; bridge->ops = &mobiveil_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle; ret =mobiveil_bringup_link (pcie);if (ret) {
drivers/pci/controller/pci-aardvark.c +0 -2
@@ -1177,8 +1177,6 @@ static int advk_pcie_probe(struct platform_device *pdev) bridge->sysdata = pcie; bridge->ops = &advk_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle; ret =pci_host_probe (bridge);if (ret <0 ) {
drivers/pci/controller/pci-ftpci100.c +0 -2
@@ -438,8 +438,6 @@ static int faraday_pci_probe(struct platform_device *pdev)return -ENOMEM ; host->ops = &faraday_pci_ops; - host->map_irq = of_irq_parse_and_map_pci; - host->swizzle_irq = pci_common_swizzle; p =pci_host_bridge_priv (host); host->sysdata = p; p->dev = dev;
drivers/pci/controller/pci-host-common.c +0 -2
@@ -77,8 +77,6 @@ int pci_host_common_probe(struct platform_device *pdev) bridge->sysdata = cfg; bridge->ops = (struct pci_ops *)&ops->pci_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;platform_set_drvdata (pdev, bridge);
drivers/pci/controller/pci-mvebu.c +0 -2
@@ -1118,8 +1118,6 @@ static int mvebu_pcie_probe(struct platform_device *pdev) bridge->sysdata = pcie; bridge->ops = &mvebu_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle; bridge->align_resource = mvebu_pcie_align_resource; bridge->msi = pcie->msi;
drivers/pci/controller/pci-tegra.c +0 -1
@@ -2709,7 +2709,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) host->ops = &tegra_pcie_ops; host->map_irq = tegra_pcie_map_irq; - host->swizzle_irq = pci_common_swizzle; err =pci_host_probe (host);if (err <0 ) {
drivers/pci/controller/pci-v3-semi.c +0 -2
@@ -722,8 +722,6 @@ static int v3_pci_probe(struct platform_device *pdev)return -ENOMEM ; host->ops = &v3_pci_ops; - host->map_irq = of_irq_parse_and_map_pci; - host->swizzle_irq = pci_common_swizzle; v3 =pci_host_bridge_priv (host); host->sysdata = v3; v3->dev = dev;
drivers/pci/controller/pci-versatile.c +0 -2
@@ -151,8 +151,6 @@ static int versatile_pci_probe(struct platform_device *pdev)pci_add_flags (PCI_REASSIGN_ALL_BUS ); bridge->ops = &pci_versatile_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;return pci_host_probe (bridge); }
drivers/pci/controller/pci-xgene.c +0 -2
@@ -621,8 +621,6 @@ static int xgene_pcie_probe(struct platform_device *pdev) bridge->sysdata = port; bridge->ops = &xgene_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;return pci_host_probe (bridge); }
drivers/pci/controller/pcie-altera.c +0 -2
@@ -812,8 +812,6 @@ static int altera_pcie_probe(struct platform_device *pdev) bridge->sysdata = pcie; bridge->busnr = pcie->root_bus_nr; bridge->ops = &altera_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;return pci_host_probe (bridge); }
drivers/pci/controller/pcie-brcmstb.c +0 -2
@@ -993,8 +993,6 @@ static int brcm_pcie_probe(struct platform_device *pdev) bridge->ops = &brcm_pcie_ops; bridge->sysdata = pcie; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;platform_set_drvdata (pdev, pcie);
drivers/pci/controller/pcie-iproc-platform.c +2 -1
@@ -99,9 +99,10 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)switch (pcie->type) {case IPROC_PCIE_PAXC :case IPROC_PCIE_PAXC_V2 : + pcie->map_irq =0 ;break ;default : - pcie->map_irq = of_irq_parse_and_map_pci; +break ; } ret =iproc_pcie_setup (pcie, &bridge->windows);
drivers/pci/controller/pcie-iproc.c +0 -1
@@ -1526,7 +1526,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) host->ops = &iproc_pcie_ops; host->sysdata = pcie; host->map_irq = pcie->map_irq; - host->swizzle_irq = pci_common_swizzle; ret =pci_host_probe (host);if (ret <0 ) {
drivers/pci/controller/pcie-mediatek.c +0 -2
@@ -1085,8 +1085,6 @@ static int mtk_pcie_probe(struct platform_device *pdev)return err; host->ops = pcie->soc->ops; - host->map_irq = of_irq_parse_and_map_pci; - host->swizzle_irq = pci_common_swizzle; host->sysdata = pcie; err =pci_host_probe (host);
drivers/pci/controller/pcie-rcar-host.c +0 -2
@@ -294,8 +294,6 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host) bridge->sysdata = host; bridge->ops = &rcar_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;if (IS_ENABLED (CONFIG_PCI_MSI )) bridge->msi = &host->msi.chip;
drivers/pci/controller/pcie-rockchip-host.c +0 -2
@@ -1001,8 +1001,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) bridge->sysdata = rockchip; bridge->ops = &rockchip_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle; err =pci_host_probe (bridge);if (err <0 )
drivers/pci/controller/pcie-xilinx-nwl.c +0 -2
@@ -846,8 +846,6 @@ static int nwl_pcie_probe(struct platform_device *pdev) bridge->sysdata = pcie; bridge->ops = &nwl_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;if (IS_ENABLED (CONFIG_PCI_MSI )) { err =nwl_pcie_enable_msi (pcie);
drivers/pci/controller/pcie-xilinx.c +0 -2
@@ -643,8 +643,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev) bridge->sysdata = port; bridge->ops = &xilinx_pcie_ops; - bridge->map_irq = of_irq_parse_and_map_pci; - bridge->swizzle_irq = pci_common_swizzle;#ifdef CONFIG_PCI_MSI xilinx_pcie_msi_chip.dev = dev;
drivers/pci/of.c +3 -0
@@ -569,6 +569,9 @@ int devm_of_pci_bridge_init(struct device *dev, struct pci_host_bridge *bridge)if (!dev->of_node)return 0 ; + bridge->swizzle_irq = pci_common_swizzle; + bridge->map_irq = of_irq_parse_and_map_pci; +return pci_parse_request_of_pci_ranges (dev, bridge); }
Signature · 1 line
2.25.1
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
[-cc many, +cc iproc, loongson, tegra maintainers]
Quoted 6 lines · Rob Herring
The majority of DT based host drivers use the default .map_irq() and .swizzle_irq() functions, so let's initialize the function pointers to the default and drop setting them in the host drivers.
Drivers like iProc which don't support legacy interrupts need to set .map_irq() back to NULL.
Probably a dumb question...
This patch removed all the ->swizzle_irq users in drivers/pci/, which is great -- IIUC swizzling is specified by the PCI-to-PCI Bridge Spec, r1.2, sec 9.1, and should not be device-specific. I assume the few remaining arch/ users (arm and alpha) are either bugs or workarounds for broken devices.
My question is why we still have a few users of ->map_irq: loongson, tegra, iproc. Shouldn't this mapping be described somehow via DT?
Quoted 35 lines
drivers/pci/controller/pci-tegra.c +0
-1@@ -2709,7 +2709,6 @@ static int tegra_pcie_probe(struct platform_device *pdev) host->ops = &tegra_pcie_ops; host->map_irq = tegra_pcie_map_irq; - host->swizzle_irq = pci_common_swizzle; err =pci_host_probe (host);if (err <0 ) {drivers/pci/controller/pcie-iproc-platform.c +2
-1@@ -99,9 +99,10 @@ static int iproc_pcie_pltfm_probe(struct platform_device *pdev)switch (pcie->type) {case IPROC_PCIE_PAXC :case IPROC_PCIE_PAXC_V2 : + pcie->map_irq =0 ;break ;default : - pcie->map_irq = of_irq_parse_and_map_pci; +break ; } ret =iproc_pcie_setup (pcie, &bridge->windows);drivers/pci/controller/pcie-iproc.c +0
-0
drivers/pci/controller/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) · line 1531
Quoted 7 lines
drivers/pci/controller/pcie-iproc.c +0
-1@@ -1526,7 +1526,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) host->ops = &iproc_pcie_ops; host->sysdata = pcie; host->map_irq = pcie->map_irq; - host->swizzle_irq = pci_common_swizzle; ret =pci_host_probe (host);if (ret <0 ) {
drivers/pci/controller/pci-loongson.c:
static int loongson_pci_probe(struct platform_device *pdev)
{
...
bridge->map_irq = loongson_map_irq;Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
Quoted 12 lines · 在2022年1月11日一月 下午9:46,Bjorn Helgaas写道:
[-cc many, +cc iproc, loongson, tegra maintainers]
Quoted 6 lines · Rob Herring
The majority of DT based host drivers use the default .map_irq() and .swizzle_irq() functions, so let's initialize the function pointers to the default and drop setting them in the host drivers.
Drivers like iProc which don't support legacy interrupts need to set .map_irq() back to NULL.
Probably a dumb question...
Quoted 9 lines
This patch removed all the ->swizzle_irq users in
drivers/pci/, which is great -- IIUC swizzling is specified by the PCI-to-PCI Bridge Spec, r1.2, sec 9.1, and should not be device-specific. I assume the few remainingarch/users (arm and alpha) are either bugs or workarounds for broken devices.My question is why we still have a few users of ->map_irq: loongson, tegra, iproc. Shouldn't this mapping be described somehow via DT?
Hi all,
For Loongson we are describing IRQ map in DT for newer platforms. But for legacy platforms (AMD RS780E North Bridge) with i8259 irqchip, we need to read PCI IRQ registers to get mapping information.
It is not known until boot time, so we have to use map_irq callback.
Thanks.
- Jiaxun
[...]
Signature · 1 line
- Jiaxun
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
Quoted 19 lines · Jiaxun Yang
Quoted 18 lines · 在2022年1月11日一月 下午9:46,Bjorn Helgaas写道:
[-cc many, +cc iproc, loongson, tegra maintainers]
Quoted 6 lines · Rob Herring
The majority of DT based host drivers use the default .map_irq() and .swizzle_irq() functions, so let's initialize the function pointers to the default and drop setting them in the host drivers.
Drivers like iProc which don't support legacy interrupts need to set .map_irq() back to NULL.
Probably a dumb question...
This patch removed all the ->swizzle_irq users in
drivers/pci/, which is great -- IIUC swizzling is specified by the PCI-to-PCI Bridge Spec, r1.2, sec 9.1, and should not be device-specific. I assume the few remainingarch/users (arm and alpha) are either bugs or workarounds for broken devices.
Quoted 8 lines
Quoted 2 lines
My question is why we still have a few users of ->map_irq: loongson, tegra, iproc. Shouldn't this mapping be described somehow via DT?
For Loongson we are describing IRQ map in DT for newer platforms. But for legacy platforms (AMD RS780E North Bridge) with i8259 irqchip, we need to read PCI IRQ registers to get mapping information.
It is not known until boot time, so we have to use
map_irqcallback.
I see these:
Documentation/devicetree/bindings/pci/loongson.yaml arch/mips/boot/dts/loongson/rs780e-pch.dtsi
which makes me think there are Loongson systems with DT. Are there some Loongson systems with DT and some legacy ones without?
The only driver I see is drivers/pci/controller/pci-loongson.c. Is that used for all Loongson system? It unconditionally uses ->map_irq = loongson_map_irq().
loongson_map_irq() reads PCI_INTERRUPT_LINE; I think that depends on firmware having previously programmed it, right?
Bjorn
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
Quoted 3 lines · 在2022年1月12日一月 下午3:19,Bjorn Helgaas写道:
Quoted 2 lines · Jiaxun Yang
Quoted 1 line · 在2022年1月11日一月 下午9:46,Bjorn Helgaas写道:
[-cc many, +cc iproc, loongson, tegra maintainers]
[...]
Quoted 7 lines
I see these:
Documentation/devicetree/bindings/pci/loongson.yamlarch/mips/boot/dts/loongson/rs780e-pch.dtsiwhich makes me think there are Loongson systems with DT. Are there some Loongson systems with DT and some legacy ones without?
Actually all present MIPS/Loongson systems are legacy and we just built-in DTs in kernel and select which one to use at boot time.
Quoted 4 lines
The only driver I see is
drivers/pci/controller/pci-loongson.c. Is that used for all Loongson system? It unconditionally uses ->map_irq =loongson_map_irq().
Yes, it's used among all Loongson systems.
For system using LS7A PCH the IRQ mapping is fixed so we just programed it in DT. For RS780E we use this rountine to read PCI_INTERRUPT_LINE to select which I8259 IRQ to use.
Quoted 3 lines
loongson_map_irq()readsPCI_INTERRUPT_LINE; I think that depends on firmware having previously programmed it, right?
I'm unclear about what did firmware do but as AMD RS780E is used in x86 PCs as well it should be the same way.
Thanks.
Quoted 2 lines
Bjorn
Signature · 1 line
- Jiaxun
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
Quoted 7 lines · Jiaxun Yang
Quoted 3 lines · 在2022年1月12日一月 下午3:19,Bjorn Helgaas写道:
Quoted 2 lines · Jiaxun Yang
Quoted 1 line · 在2022年1月11日一月 下午9:46,Bjorn Helgaas写道:
[-cc many, +cc iproc, loongson, tegra maintainers]
[...]
Quoted 2 lines
I see these:
Quoted 8 lines
Quoted 5 lines
Documentation/devicetree/bindings/pci/loongson.yamlarch/mips/boot/dts/loongson/rs780e-pch.dtsiwhich makes me think there are Loongson systems with DT. Are there some Loongson systems with DT and some legacy ones without?
Actually all present MIPS/Loongson systems are legacy and we just built-in DTs in kernel and select which one to use at boot time.
So I guess you know enough about what platform it is to select which DT to use, but you don't know enough to know the I8259 routing?
If you *could* select a DT that described the I8259 routing, I guess maybe you could select a matching DT or update a DT in-place?
Quoted 9 lines
Quoted 3 lines
The only driver I see is
drivers/pci/controller/pci-loongson.c. Is that used for all Loongson system? It unconditionally uses ->map_irq =loongson_map_irq().Yes, it's used among all Loongson systems. For system using LS7A PCH the IRQ mapping is fixed so we just programmed it in DT. For RS780E we use this routine to read
PCI_INTERRUPT_LINEto select which I8259 IRQ to use.
Quoted 5 lines
Quoted 2 lines
loongson_map_irq()readsPCI_INTERRUPT_LINE; I think that depends on firmware having previously programmed it, right?I'm unclear about what did firmware do but as AMD RS780E is used in x86 PCs as well it should be the same way.
PCI devices don't use the value in PCI_INTERRUPT_LINE, and the spec doesn't define a default value. It's only for use by software.
I'm pretty sure that on ACPI x86, we don't depend on PCI_INTERRUPT_LINE except for things like quirks.
I think the ACPI MADT and _PRT are supposed to contain all the INTx routing information we need. Obviously this isn't an ACPI system. I'm just making the point that it *should* be possible to remove this dependency on firmware if we can identify the specific platform (which determines the I8259 routing).
Bjorn
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
Quoted 41 lines · 在2022年1月12日一月 下午9:10,Bjorn Helgaas写道:
Quoted 7 lines · Jiaxun Yang
Quoted 3 lines · 在2022年1月12日一月 下午3:19,Bjorn Helgaas写道:
Quoted 2 lines · Jiaxun Yang
Quoted 1 line · 在2022年1月11日一月 下午9:46,Bjorn Helgaas写道:
[-cc many, +cc iproc, loongson, tegra maintainers]
[...]
Quoted 2 lines
I see these:
Quoted 8 lines
Quoted 5 lines
Documentation/devicetree/bindings/pci/loongson.yamlarch/mips/boot/dts/loongson/rs780e-pch.dtsiwhich makes me think there are Loongson systems with DT. Are there some Loongson systems with DT and some legacy ones without?
Actually all present MIPS/Loongson systems are legacy and we just built-in DTs in kernel and select which one to use at boot time.
So I guess you know enough about what platform it is to select which DT to use, but you don't know enough to know the I8259 routing?
If you *could* select a DT that described the I8259 routing, I guess maybe you could select a matching DT or update a DT in-place?
Quoted 9 lines
Quoted 3 lines
The only driver I see is
drivers/pci/controller/pci-loongson.c. Is that used for all Loongson system? It unconditionally uses ->map_irq =loongson_map_irq().Yes, it's used among all Loongson systems. For system using LS7A PCH the IRQ mapping is fixed so we just programmed it in DT. For RS780E we use this routine to read
PCI_INTERRUPT_LINEto select which I8259 IRQ to use.Quoted 5 lines
Quoted 2 lines
loongson_map_irq()readsPCI_INTERRUPT_LINE; I think that depends on firmware having previously programmed it, right?I'm unclear about what did firmware do but as AMD RS780E is used in x86 PCs as well it should be the same way.
PCI devices don't use the value in
PCI_INTERRUPT_LINE, and the spec doesn't define a default value. It's only for use by software.
Quoted 8 lines
I'm pretty sure that on ACPI x86, we don't depend on
PCI_INTERRUPT_LINEexcept for things like quirks.I think the ACPI MADT and
_PRTare supposed to contain all the INTx routing information we need. Obviously this isn't an ACPI system. I'm just making the point that it *should* be possible to remove this dependency on firmware if we can identify the specific platform (which determines the I8259 routing).
Hi,
Thanks for the information, I had send a enquire to Loongson to ask about those details.
Patching DT at boot time should be possible :-)
Thanks.
Quoted 2 lines
Bjorn
Signature · 1 line
- Jiaxun
Rob Herring
maintainerRe: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
In reply to Bjorn HelgaasQuoted 13 lines · Bjorn Helgaas
[-cc many, +cc iproc, loongson, tegra maintainers]
Quoted 6 lines · Rob Herring
The majority of DT based host drivers use the default .map_irq() and .swizzle_irq() functions, so let's initialize the function pointers to the default and drop setting them in the host drivers.
Drivers like iProc which don't support legacy interrupts need to set .map_irq() back to NULL.
Probably a dumb question...
Quoted 8 lines
This patch removed all the ->swizzle_irq users in
drivers/pci/, which is great -- IIUC swizzling is specified by the PCI-to-PCI Bridge Spec, r1.2, sec 9.1, and should not be device-specific. I assume the few remainingarch/users (arm and alpha) are either bugs or workarounds for broken devices.My question is why we still have a few users of ->map_irq: loongson, tegra, iproc. Shouldn't this mapping be described somehow via DT?
Tegra could perhaps be written another way. The mapping is standard, but it's disabling an idle state when PCI interrupts are used. It just needs some way to know if legacy interrupts are being used.
iproc looks pretty special with its bcma bus.
Adding something to DT doesn't really help because we'd still have to support the old way.
Rob
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
Quoted 20 lines · Rob Herring
Quoted 10 lines · Bjorn Helgaas
Quoted 6 lines · Rob Herring
The majority of DT based host drivers use the default .map_irq() and .swizzle_irq() functions, so let's initialize the function pointers to the default and drop setting them in the host drivers.
Drivers like iProc which don't support legacy interrupts need to set .map_irq() back to NULL.
Probably a dumb question...
Quoted 8 lines
This patch removed all the ->swizzle_irq users in
drivers/pci/, which is great -- IIUC swizzling is specified by the PCI-to-PCI Bridge Spec, r1.2, sec 9.1, and should not be device-specific. I assume the few remainingarch/users (arm and alpha) are either bugs or workarounds for broken devices.My question is why we still have a few users of ->map_irq: loongson, tegra, iproc. Shouldn't this mapping be described somehow via DT?
Quoted 8 lines
Tegra could perhaps be written another way. The mapping is standard, but it's disabling an idle state when PCI interrupts are used. It just needs some way to know if legacy interrupts are being used.
iproc looks pretty special with its bcma bus.
Adding something to DT doesn't really help because we'd still have to support the old way.
I guess my underlying question is whether new drivers should ever use ->swizzle_irq() and ->map_irq(). I'm hoping the answer is "no".
If we need them for pre-DT systems or things with incomplete DTs in the field, I guess we have to live with that.
All ACPI really gives you is the _PRT, and I'm not sure that's expressive enough to describe platforms that need these things, so maybe this will eventually solve itself.
Bjorn
Re: [PATCH 19/19] PCI: Set bridge map_irq and swizzle_irq to default functions
In reply to Bjorn HelgaasQuoted 5 lines · Bjorn Helgaas
This patch removed all the ->swizzle_irq users in
drivers/pci/, which is great -- IIUC swizzling is specified by the PCI-to-PCI Bridge Spec, r1.2, sec 9.1, and should not be device-specific. I assume the few remainingarch/users (arm and alpha) are either bugs or workarounds for broken devices.
I skimmed over the Alpha stuff and it seems to mostly care about setting
the slot value returned differently and defers to `pci_common_swizzle' for actual pin determination. This could be moderately easy to sort out.
One exception is `takara_swizzle' which looks incomplete to me; as this
is a PICMG device[1] someone would have to fill in the missing details as AFAICT the PICMG connector is supposed to provide all the INT# A-D lines and then routing is done on the backplane using binding defined by PICMG.
According to DEC documentation there's an alternative interrupt routing
mode available too, using a external interrupt controller FPGA placed on the backplane[2], where no swizzling is done and instead each of the four INT# lines across all the PCI slots, up to 16, provided by a backplane is individually routed to 64 inputs of the interrupt controller.
There is a paper by DEC available online[3] that could help filling in
the missing details for either mode, especially someone who has access to such a system and could verify it in reality.
References:
[1] "DIGITAL 21164 PICMG SBC, User Information for the EBM21 and EBM23", V1.0, Digital Equipment Corporation, June 1997, Part Number:
EK-A0937-UG. A01
[2] "DIGITAL Modular Computing Components, OEM Information for DMCC Backplanes", Version 4.1, Compaq Computer Corporation, January 1999, Order Number: EK-A0929-TM. C01
[3] Ross L. Armstrong, "PCI Interrupt Controller for Industry Standard PCI-ISA Bus Architecture using PCI-to-PCI Bridge Technology", Digital Equipment Corporation (Scotland) Ltd., 1996
FWIW,
Maciej
Quoted 74 lines · Rob Herring
Here's another round PCI host bridge clean-ups. This one aims to reduce the amount of duplication in host probe functions by providing more default initialization of the
pci_host_bridge. With the prior clean-ups, it's now possible to alloc and initialize thepci_host_bridgestruct from DT in one step.Patches 2 and 3 drop some
pci_host_bridgeinit. Patches 4-11 clean-up handling of root bus number and bus ranges. Patches 12 and 13 are cleanups for Cadence driver. Patches 14 and 15 are clean-ups for rCar driver. Patch 16 makes missing non-prefetchable region just a warning instead of an error in order to work with rcar-gen2. Patch 17 converts rcar-gen2 to not use the arm32 specific PCI setup. Patch 18 updates how the DT resource parsing is done for all the controller drivers. Any other new controller drivers will need updating. Patch 19 moves the default IRQ mapping to the bridge init core code.This is based on my previous series of clean-ups[1].
Compile tested only. Any testing would be appreciated as I don't have any of this h/w (well, I have a rock960c, but have not gotten PCIe to work on it).
Rob
Rob Herring (19):
PCI: versatile: Drop flagPCI_ENABLE_PROC_DOMAINS
PCI: Set default bridge parent device
PCI: Drop unnecessary zeroing of bridge fields
PCI: aardvark: Usepci_is_root_bus()to check if bus is root bus
PCI: designware: Usepci_is_root_bus()to check if bus is root bus
PCI: mobiveil: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx-nwl: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx: Usepci_is_root_bus()to check if bus is root bus
PCI: rockchip: Usepci_is_root_bus()to check if bus is root bus
PCI: rcar: Usepci_is_root_bus()to check if bus is root bus
PCI: Move setting pci_host_bridge.busnr out of host drivers
PCI: cadence: Use bridge resources for outbound window setup
PCI: cadence: Remove private bus number and range storage
PCI: rcar: Usedevm_pci_alloc_host_bridge()
PCI: rcar: Use struct pci_host_bridge.windows list directly
PCI: of: Reduce missing non-prefetchable memory region to a warning
PCI: rcar-gen2: Convert to use modern host bridge probe functions
PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()
PCI: Set bridgemap_irqandswizzle_irqto default functions.../pci/controller/cadence/pcie-cadence-ep.c | 6 +- .../controller/cadence/pcie-cadence-host.c | 65 +++---- drivers/pci/controller/cadence/pcie-cadence.c | 9 +- drivers/pci/controller/cadence/pcie-cadence.h | 8 +- drivers/pci/controller/dwc/pci-imx6.c | 2 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-host.c | 28 +-- drivers/pci/controller/dwc/pcie-designware.h | 2 - .../controller/mobiveil/pcie-mobiveil-host.c | 21 +-- .../pci/controller/mobiveil/pcie-mobiveil.h | 1 - drivers/pci/controller/pci-aardvark.c | 25 +-- drivers/pci/controller/pci-ftpci100.c | 10 -- drivers/pci/controller/pci-host-common.c | 17 +- drivers/pci/controller/pci-loongson.c | 8 - drivers/pci/controller/pci-mvebu.c | 4 - drivers/pci/controller/pci-rcar-gen2.c | 162 +++++------------- drivers/pci/controller/pci-tegra.c | 10 -- drivers/pci/controller/pci-v3-semi.c | 12 -- drivers/pci/controller/pci-versatile.c | 13 +- drivers/pci/controller/pci-xgene.c | 9 - drivers/pci/controller/pcie-altera.c | 10 -- drivers/pci/controller/pcie-brcmstb.c | 9 - drivers/pci/controller/pcie-iproc-platform.c | 10 +- drivers/pci/controller/pcie-iproc.c | 3 - drivers/pci/controller/pcie-mediatek.c | 16 -- drivers/pci/controller/pcie-rcar-host.c | 73 +------- drivers/pci/controller/pcie-rockchip-host.c | 24 +--
Quoted 8 lines
drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 20 +-- drivers/pci/controller/pcie-xilinx.c | 22 +-- drivers/pci/of.c | 45 +++-- drivers/pci/pci.h | 8 + drivers/pci/probe.c | 7 + include/linux/pci.h | 12 -- 34 files changed, 160 insertions(+), 516 deletions(-)
Beautiful, thanks for doing all this!
Lorenzo Pieralisi
AppliedQuoted 74 lines · Rob Herring
Here's another round PCI host bridge clean-ups. This one aims to reduce the amount of duplication in host probe functions by providing more default initialization of the
pci_host_bridge. With the prior clean-ups, it's now possible to alloc and initialize thepci_host_bridgestruct from DT in one step.Patches 2 and 3 drop some
pci_host_bridgeinit. Patches 4-11 clean-up handling of root bus number and bus ranges. Patches 12 and 13 are cleanups for Cadence driver. Patches 14 and 15 are clean-ups for rCar driver. Patch 16 makes missing non-prefetchable region just a warning instead of an error in order to work with rcar-gen2. Patch 17 converts rcar-gen2 to not use the arm32 specific PCI setup. Patch 18 updates how the DT resource parsing is done for all the controller drivers. Any other new controller drivers will need updating. Patch 19 moves the default IRQ mapping to the bridge init core code.This is based on my previous series of clean-ups[1].
Compile tested only. Any testing would be appreciated as I don't have any of this h/w (well, I have a rock960c, but have not gotten PCIe to work on it).
Rob
Rob Herring (19):
PCI: versatile: Drop flagPCI_ENABLE_PROC_DOMAINS
PCI: Set default bridge parent device
PCI: Drop unnecessary zeroing of bridge fields
PCI: aardvark: Usepci_is_root_bus()to check if bus is root bus
PCI: designware: Usepci_is_root_bus()to check if bus is root bus
PCI: mobiveil: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx-nwl: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx: Usepci_is_root_bus()to check if bus is root bus
PCI: rockchip: Usepci_is_root_bus()to check if bus is root bus
PCI: rcar: Usepci_is_root_bus()to check if bus is root bus
PCI: Move setting pci_host_bridge.busnr out of host drivers
PCI: cadence: Use bridge resources for outbound window setup
PCI: cadence: Remove private bus number and range storage
PCI: rcar: Usedevm_pci_alloc_host_bridge()
PCI: rcar: Use struct pci_host_bridge.windows list directly
PCI: of: Reduce missing non-prefetchable memory region to a warning
PCI: rcar-gen2: Convert to use modern host bridge probe functions
PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()
PCI: Set bridgemap_irqandswizzle_irqto default functions.../pci/controller/cadence/pcie-cadence-ep.c | 6 +- .../controller/cadence/pcie-cadence-host.c | 65 +++---- drivers/pci/controller/cadence/pcie-cadence.c | 9 +- drivers/pci/controller/cadence/pcie-cadence.h | 8 +- drivers/pci/controller/dwc/pci-imx6.c | 2 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-host.c | 28 +-- drivers/pci/controller/dwc/pcie-designware.h | 2 - .../controller/mobiveil/pcie-mobiveil-host.c | 21 +-- .../pci/controller/mobiveil/pcie-mobiveil.h | 1 - drivers/pci/controller/pci-aardvark.c | 25 +-- drivers/pci/controller/pci-ftpci100.c | 10 -- drivers/pci/controller/pci-host-common.c | 17 +- drivers/pci/controller/pci-loongson.c | 8 - drivers/pci/controller/pci-mvebu.c | 4 - drivers/pci/controller/pci-rcar-gen2.c | 162 +++++------------- drivers/pci/controller/pci-tegra.c | 10 -- drivers/pci/controller/pci-v3-semi.c | 12 -- drivers/pci/controller/pci-versatile.c | 13 +- drivers/pci/controller/pci-xgene.c | 9 - drivers/pci/controller/pcie-altera.c | 10 -- drivers/pci/controller/pcie-brcmstb.c | 9 - drivers/pci/controller/pcie-iproc-platform.c | 10 +- drivers/pci/controller/pcie-iproc.c | 3 - drivers/pci/controller/pcie-mediatek.c | 16 -- drivers/pci/controller/pcie-rcar-host.c | 73 +------- drivers/pci/controller/pcie-rockchip-host.c | 24 +--
Quoted 8 lines
drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 20 +-- drivers/pci/controller/pcie-xilinx.c | 22 +-- drivers/pci/of.c | 45 +++-- drivers/pci/pci.h | 8 + drivers/pci/probe.c | 7 + include/linux/pci.h | 12 -- 34 files changed, 160 insertions(+), 516 deletions(-)
Applied to pci/misc with Bjorn's ACK - I had to tweak:
https://patchwork.kernel.org/patch/11677011
Hopefully I have not messed it up.
Thanks,
Lorenzo
[+cc Kishon, -cc non Cadence folks]
Quoted 84 lines · Lorenzo Pieralisi
Quoted 74 lines · Rob Herring
Here's another round PCI host bridge clean-ups. This one aims to reduce the amount of duplication in host probe functions by providing more default initialization of the
pci_host_bridge. With the prior clean-ups, it's now possible to alloc and initialize thepci_host_bridgestruct from DT in one step.Patches 2 and 3 drop some
pci_host_bridgeinit. Patches 4-11 clean-up handling of root bus number and bus ranges. Patches 12 and 13 are cleanups for Cadence driver. Patches 14 and 15 are clean-ups for rCar driver. Patch 16 makes missing non-prefetchable region just a warning instead of an error in order to work with rcar-gen2. Patch 17 converts rcar-gen2 to not use the arm32 specific PCI setup. Patch 18 updates how the DT resource parsing is done for all the controller drivers. Any other new controller drivers will need updating. Patch 19 moves the default IRQ mapping to the bridge init core code.This is based on my previous series of clean-ups[1].
Compile tested only. Any testing would be appreciated as I don't have any of this h/w (well, I have a rock960c, but have not gotten PCIe to work on it).
Rob
[1] https://lore.kernel.org/linux-pci/[email protected]/
Rob Herring (19):
PCI: versatile: Drop flagPCI_ENABLE_PROC_DOMAINS
PCI: Set default bridge parent device
PCI: Drop unnecessary zeroing of bridge fields
PCI: aardvark: Usepci_is_root_bus()to check if bus is root bus
PCI: designware: Usepci_is_root_bus()to check if bus is root bus
PCI: mobiveil: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx-nwl: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx: Usepci_is_root_bus()to check if bus is root bus
PCI: rockchip: Usepci_is_root_bus()to check if bus is root bus
PCI: rcar: Usepci_is_root_bus()to check if bus is root bus
PCI: Move setting pci_host_bridge.busnr out of host drivers
PCI: cadence: Use bridge resources for outbound window setup
PCI: cadence: Remove private bus number and range storage
PCI: rcar: Usedevm_pci_alloc_host_bridge()
PCI: rcar: Use struct pci_host_bridge.windows list directly
PCI: of: Reduce missing non-prefetchable memory region to a warning
PCI: rcar-gen2: Convert to use modern host bridge probe functions
PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()
PCI: Set bridgemap_irqandswizzle_irqto default functions.../pci/controller/cadence/pcie-cadence-ep.c | 6 +- .../controller/cadence/pcie-cadence-host.c | 65 +++---- drivers/pci/controller/cadence/pcie-cadence.c | 9 +- drivers/pci/controller/cadence/pcie-cadence.h | 8 +- drivers/pci/controller/dwc/pci-imx6.c | 2 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-host.c | 28 +-- drivers/pci/controller/dwc/pcie-designware.h | 2 - .../controller/mobiveil/pcie-mobiveil-host.c | 21 +-- .../pci/controller/mobiveil/pcie-mobiveil.h | 1 - drivers/pci/controller/pci-aardvark.c | 25 +-- drivers/pci/controller/pci-ftpci100.c | 10 -- drivers/pci/controller/pci-host-common.c | 17 +- drivers/pci/controller/pci-loongson.c | 8 - drivers/pci/controller/pci-mvebu.c | 4 - drivers/pci/controller/pci-rcar-gen2.c | 162 +++++------------- drivers/pci/controller/pci-tegra.c | 10 -- drivers/pci/controller/pci-v3-semi.c | 12 -- drivers/pci/controller/pci-versatile.c | 13 +- drivers/pci/controller/pci-xgene.c | 9 - drivers/pci/controller/pcie-altera.c | 10 -- drivers/pci/controller/pcie-brcmstb.c | 9 - drivers/pci/controller/pcie-iproc-platform.c | 10 +- drivers/pci/controller/pcie-iproc.c | 3 - drivers/pci/controller/pcie-mediatek.c | 16 -- drivers/pci/controller/pcie-rcar-host.c | 73 +------- drivers/pci/controller/pcie-rockchip-host.c | 24 +--Quoted 8 lines
drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 20 +-- drivers/pci/controller/pcie-xilinx.c | 22 +-- drivers/pci/of.c | 45 +++-- drivers/pci/pci.h | 8 + drivers/pci/probe.c | 7 + include/linux/pci.h | 12 -- 34 files changed, 160 insertions(+), 516 deletions(-)
Quoted 3 lines
Applied to pci/misc with Bjorn's ACK - I had to tweak:
There are significant conflicts between this series and Kishon's TI J721E work on Lorenzo's pci/cadence branch.
This series on pci/misc touches many drivers, so I'll merge it last. It wasn't obvious to me how to resolve some of the conflicts, so I dropped pci/misc from my merge today.
Any chance you could rebase this on top of Lorenzo's pci/cadence branch, Rob? I think it would probably merge cleanly then.
Bjorn
Rob Herring
maintainerQuoted 95 lines · Bjorn Helgaas
[+cc Kishon, -cc non Cadence folks]
Quoted 84 lines · Lorenzo Pieralisi
Quoted 74 lines · Rob Herring
Here's another round PCI host bridge clean-ups. This one aims to reduce the amount of duplication in host probe functions by providing more default initialization of the
pci_host_bridge. With the prior clean-ups, it's now possible to alloc and initialize thepci_host_bridgestruct from DT in one step.Patches 2 and 3 drop some
pci_host_bridgeinit. Patches 4-11 clean-up handling of root bus number and bus ranges. Patches 12 and 13 are cleanups for Cadence driver. Patches 14 and 15 are clean-ups for rCar driver. Patch 16 makes missing non-prefetchable region just a warning instead of an error in order to work with rcar-gen2. Patch 17 converts rcar-gen2 to not use the arm32 specific PCI setup. Patch 18 updates how the DT resource parsing is done for all the controller drivers. Any other new controller drivers will need updating. Patch 19 moves the default IRQ mapping to the bridge init core code.This is based on my previous series of clean-ups[1].
Compile tested only. Any testing would be appreciated as I don't have any of this h/w (well, I have a rock960c, but have not gotten PCIe to work on it).
Rob
[1] https://lore.kernel.org/linux-pci/[email protected]/
Rob Herring (19):
PCI: versatile: Drop flagPCI_ENABLE_PROC_DOMAINS
PCI: Set default bridge parent device
PCI: Drop unnecessary zeroing of bridge fields
PCI: aardvark: Usepci_is_root_bus()to check if bus is root bus
PCI: designware: Usepci_is_root_bus()to check if bus is root bus
PCI: mobiveil: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx-nwl: Usepci_is_root_bus()to check if bus is root bus
PCI: xilinx: Usepci_is_root_bus()to check if bus is root bus
PCI: rockchip: Usepci_is_root_bus()to check if bus is root bus
PCI: rcar: Usepci_is_root_bus()to check if bus is root bus
PCI: Move setting pci_host_bridge.busnr out of host drivers
PCI: cadence: Use bridge resources for outbound window setup
PCI: cadence: Remove private bus number and range storage
PCI: rcar: Usedevm_pci_alloc_host_bridge()
PCI: rcar: Use struct pci_host_bridge.windows list directly
PCI: of: Reduce missing non-prefetchable memory region to a warning
PCI: rcar-gen2: Convert to use modern host bridge probe functions
PCI: Move DT resource setup intodevm_pci_alloc_host_bridge()
PCI: Set bridgemap_irqandswizzle_irqto default functions.../pci/controller/cadence/pcie-cadence-ep.c | 6 +- .../controller/cadence/pcie-cadence-host.c | 65 +++---- drivers/pci/controller/cadence/pcie-cadence.c | 9 +- drivers/pci/controller/cadence/pcie-cadence.h | 8 +- drivers/pci/controller/dwc/pci-imx6.c | 2 +- drivers/pci/controller/dwc/pci-keystone.c | 4 +- .../pci/controller/dwc/pcie-designware-host.c | 28 +-- drivers/pci/controller/dwc/pcie-designware.h | 2 - .../controller/mobiveil/pcie-mobiveil-host.c | 21 +-- .../pci/controller/mobiveil/pcie-mobiveil.h | 1 - drivers/pci/controller/pci-aardvark.c | 25 +-- drivers/pci/controller/pci-ftpci100.c | 10 -- drivers/pci/controller/pci-host-common.c | 17 +- drivers/pci/controller/pci-loongson.c | 8 - drivers/pci/controller/pci-mvebu.c | 4 - drivers/pci/controller/pci-rcar-gen2.c | 162 +++++------------- drivers/pci/controller/pci-tegra.c | 10 -- drivers/pci/controller/pci-v3-semi.c | 12 -- drivers/pci/controller/pci-versatile.c | 13 +- drivers/pci/controller/pci-xgene.c | 9 - drivers/pci/controller/pcie-altera.c | 10 -- drivers/pci/controller/pcie-brcmstb.c | 9 - drivers/pci/controller/pcie-iproc-platform.c | 10 +- drivers/pci/controller/pcie-iproc.c | 3 - drivers/pci/controller/pcie-mediatek.c | 16 -- drivers/pci/controller/pcie-rcar-host.c | 73 +------- drivers/pci/controller/pcie-rockchip-host.c | 24 +--Quoted 8 lines
drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 20 +-- drivers/pci/controller/pcie-xilinx.c | 22 +-- drivers/pci/of.c | 45 +++-- drivers/pci/pci.h | 8 + drivers/pci/probe.c | 7 + include/linux/pci.h | 12 -- 34 files changed, 160 insertions(+), 516 deletions(-)Quoted 3 lines
Applied to pci/misc with Bjorn's ACK - I had to tweak:
There are significant conflicts between this series and Kishon's TI J721E work on Lorenzo's pci/cadence branch.
Quoted 6 lines
This series on pci/misc touches many drivers, so I'll merge it last. It wasn't obvious to me how to resolve some of the conflicts, so I dropped pci/misc from my merge today.
Any chance you could rebase this on top of Lorenzo's pci/cadence branch, Rob? I think it would probably merge cleanly then.
Here's a branch with pci/misc and pci/cadence merged:
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git pci-merge
Rob