PCI controller probe cleanups
Subsystems (21)
Rob Herring
maintainercover PCI controller probe cleanups
I started this on my last series of dma-ranges rework and am just getting back to finishing it. This series simplifies the resource list handling in a couple of drivers and converts almost all the remaining drivers to use pci_host_probe().
The one holdout is Designware. This is due to the .scan_bus() hook which is only used by TI Keystone. I think it could be a fixup instead matching on the root bus id. I'm not sure though. See ks_pcie_v3_65_scan_bus().
Rob
Rob Herring (15):
PCI: cadence: Use struct pci_host_bridge.windows list directly
PCI: mvebu: Use struct pci_host_bridge.windows list directly
PCI: host-common: Use struct pci_host_bridge.windows list directly
PCI: brcmstb: Use pci_host_probe() to register host
PCI: mobiveil: Use pci_host_probe() to register host
PCI: tegra: Use pci_host_probe() to register host
PCI: v3: Use pci_host_probe() to register host
PCI: versatile: Use pci_host_probe() to register host
PCI: xgene: Use pci_host_probe() to register host
PCI: altera: Use pci_host_probe() to register host
PCI: iproc: Use pci_host_probe() to register host
PCI: rcar: Use pci_host_probe() to register host
PCI: rockchip: Use pci_host_probe() to register host
PCI: xilinx-nwl: Use pci_host_probe() to register host
PCI: xilinx: Use pci_host_probe() to register host
.../controller/cadence/pcie-cadence-host.c | 26 ++++---------- .../controller/mobiveil/pcie-mobiveil-host.c | 16 +-------- drivers/pci/controller/pci-host-common.c | 36 ++++++------------- drivers/pci/controller/pci-mvebu.c | 13 +++---- drivers/pci/controller/pci-tegra.c | 11 +----- drivers/pci/controller/pci-v3-semi.c | 13 +------ drivers/pci/controller/pci-versatile.c | 14 +------- drivers/pci/controller/pci-xgene.c | 13 +------ drivers/pci/controller/pcie-altera.c | 17 +-------- drivers/pci/controller/pcie-brcmstb.c | 20 +++-------- drivers/pci/controller/pcie-iproc.c | 18 +++------- drivers/pci/controller/pcie-iproc.h | 2 -- drivers/pci/controller/pcie-rcar-host.c | 18 +--------- drivers/pci/controller/pcie-rockchip-host.c | 18 +++------- drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 14 +------- drivers/pci/controller/pcie-xilinx.c | 13 +------ 17 files changed, 45 insertions(+), 218 deletions(-)
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 1/15 PCI: cadence: Use struct pci_host_bridge.windows list directly
There'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.
--- .../controller/cadence/pcie-cadence-host.c | 26 +++++-------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/pci/controller/cadence/pcie-cadence-host.c +7 -19
@@ -169,14 +169,15 @@ static int cdns_pcie_host_init_address_translation(struct cdns_pcie_rc *rc) }static int cdns_pcie_host_init (struct device *dev, -struct list_head *resources,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, resources,NULL , &bus_range); + err =pci_parse_request_of_pci_ranges (dev, &bridge->windows,NULL , + &bus_range);if (err)return err;
@@ -185,17 +186,9 @@ static int cdns_pcie_host_init(struct device *dev, err =cdns_pcie_host_init_root_port (rc);if (err) - goto err_out; - - err =cdns_pcie_host_init_address_translation (rc); -if (err) - goto err_out; - -return 0 ; +return err; - err_out: -pci_free_resource_list (resources); -return err; +return cdns_pcie_host_init_address_translation (rc); }int cdns_pcie_host_setup (struct cdns_pcie_rc *rc)
@@ -204,7 +197,6 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)struct platform_device *pdev =to_platform_device (dev);struct device_node *np = dev->of_node;struct pci_host_bridge *bridge; -struct list_head resources;struct cdns_pcie *pcie;struct resource *res;int ret;
@@ -248,11 +240,10 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) pcie->mem_res = res; - ret =cdns_pcie_host_init (dev, &resources, rc); + ret =cdns_pcie_host_init (dev, rc);if (ret) goto err_init; -list_splice_init (&resources, &bridge->windows); bridge->dev.parent = dev; bridge->busnr = pcie->bus; bridge->ops = &cdns_pcie_host_ops;
@@ -261,13 +252,10 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) ret =pci_host_probe (bridge);if (ret <0 ) - goto err_host_probe; + goto err_init;return 0 ; - err_host_probe: -pci_free_resource_list (&resources); - err_init:pm_runtime_put_sync (dev);
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 2/15 PCI: mvebu: 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/pci-mvebu.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/pci/controller/pci-mvebu.c +5 -8
@@ -71,7 +71,6 @@ struct mvebu_pcie {struct platform_device *pdev;struct mvebu_pcie_port *ports;struct msi_controller *msi; -struct list_head resources;struct resource io;struct resource realio;struct resource mem;
@@ -961,17 +960,16 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) {struct device *dev = &pcie->pdev->dev;struct device_node *np = dev->of_node; +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (pcie);int ret; -INIT_LIST_HEAD (&pcie->resources); -/* Get the bus range */ ret =of_pci_parse_bus_range (np, &pcie->busn);if (ret) {dev_err (dev,"failed to parse bus-range property: %d\n" , ret);return ret; } -pci_add_resource (&pcie->resources, &pcie->busn); +pci_add_resource (&bridge->windows, &pcie->busn);/* Get the PCIe memory aperture */ mvebu_mbus_get_pcie_mem_aperture (&pcie->mem);
@@ -981,7 +979,7 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) } pcie->mem.name ="PCI MEM" ; -pci_add_resource (&pcie->resources, &pcie->mem); +pci_add_resource (&bridge->windows, &pcie->mem);/* Get the PCIe IO aperture */ mvebu_mbus_get_pcie_io_aperture (&pcie->io);
@@ -994,10 +992,10 @@ static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie) resource_size(&pcie->io) - 1); pcie->realio.name ="PCI I/O" ; -pci_add_resource (&pcie->resources, &pcie->realio); +pci_add_resource (&bridge->windows, &pcie->realio); } -return devm_request_pci_bus_resources (dev, &pcie->resources); +return devm_request_pci_bus_resources (dev, &bridge->windows); }/*
@@ -1118,7 +1116,6 @@ static int mvebu_pcie_probe(struct platform_device *pdev) pcie->nports = i; -list_splice_init (&pcie->resources, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = pcie; bridge->busnr =0 ;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 3/15 PCI: host-common: 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/pci-host-common.c | 36 ++++++++---------------- 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/pci/controller/pci-host-common.c +11 -25
@@ -21,7 +21,7 @@ static void gen_pci_unmap_cfg(void *ptr) }static struct pci_config_window *gen_pci_init (struct device *dev, -struct list_head *resources,const struct pci_ecam_ops *ops) +struct pci_host_bridge *bridge,const struct pci_ecam_ops *ops) {int err;struct resource cfgres;
@@ -29,31 +29,25 @@ static struct pci_config_window *gen_pci_init(struct device *dev,struct pci_config_window *cfg;/* Parse our PCI ranges and request their resources */ - err =pci_parse_request_of_pci_ranges (dev, resources,NULL , &bus_range); + 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" ); - goto err_out; +return ERR_PTR (err); } cfg =pci_ecam_create (dev, &cfgres, bus_range, ops); -if (IS_ERR (cfg)) { - err =PTR_ERR (cfg); - goto err_out; - } +if (IS_ERR (cfg)) +return cfg; err =devm_add_action_or_reset (dev, gen_pci_unmap_cfg, cfg); -if (err) { - goto err_out; - } -return cfg; +if (err) +return ERR_PTR (err); -err_out: -pci_free_resource_list (resources); -return ERR_PTR (err); +return cfg; }int pci_host_common_probe (struct platform_device *pdev)
@@ -61,9 +55,7 @@ int pci_host_common_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct pci_host_bridge *bridge;struct pci_config_window *cfg; -struct list_head resources;const struct pci_ecam_ops *ops; -int ret; ops =of_device_get_match_data (&pdev->dev);if (!ops)
@@ -76,7 +68,7 @@ int pci_host_common_probe(struct platform_device *pdev)of_pci_check_probe_only ();/* Parse and map our Configuration Space windows */ - cfg =gen_pci_init (dev, &resources, ops); + cfg =gen_pci_init (dev, bridge, ops);if (IS_ERR (cfg))return PTR_ERR (cfg);
@@ -84,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 ); -list_splice_init (&resources, &bridge->windows); bridge->dev.parent = dev; bridge->sysdata = cfg; bridge->busnr = cfg->busr.start;
@@ -92,14 +83,9 @@ int pci_host_common_probe(struct platform_device *pdev) bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_host_probe (bridge); -if (ret <0 ) { -pci_free_resource_list (&resources); -return ret; - } -platform_set_drvdata (pdev, bridge->bus); -return 0 ; + +return pci_host_probe (bridge); }EXPORT_SYMBOL_GPL (pci_host_common_probe);
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 4/15 PCI: brcmstb: Use pci_host_probe() to register host
In reply to Rob HerringThe brcmstb host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pcie-brcmstb.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +4 -16
@@ -172,7 +172,6 @@ struct brcm_pcie {struct device *dev;void __iomem *base;struct clk *clk; -struct pci_bus *root_bus;struct device_node *np;bool ssc;int gen;
@@ -919,9 +918,10 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie)static int brcm_pcie_remove (struct platform_device *pdev) {struct brcm_pcie *pcie =platform_get_drvdata (pdev); +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (pcie); -pci_stop_root_bus (pcie->root_bus); -pci_remove_root_bus (pcie->root_bus); +pci_stop_root_bus (bridge->bus); +pci_remove_root_bus (bridge->bus);__brcm_pcie_remove (pcie);return 0 ;
@@ -933,7 +933,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)struct pci_host_bridge *bridge;struct device_node *fw_np;struct brcm_pcie *pcie; -struct pci_bus *child;struct resource *res;int ret;
@@ -1004,20 +1003,9 @@ static int brcm_pcie_probe(struct platform_device *pdev) bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (bridge); -if (ret <0 ) { -dev_err (pcie->dev,"Scanning root bridge failed\n" ); - goto fail; - } - -pci_assign_unassigned_bus_resources (bridge->bus); -list_for_each_entry (child, &bridge->bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bridge->bus);platform_set_drvdata (pdev, pcie); - pcie->root_bus = bridge->bus; -return 0 ; +return pci_host_probe (bridge); fail:__brcm_pcie_remove (pcie);return ret;
Signature · 1 line
2.25.1
Re: [PATCH 04/15] PCI: brcmstb: Use pci_host_probe() to register host
Quoted 8 lines · Rob Herring
The brcmstb host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.Cc Nicolas Saenz Julienne <[email protected]>Signed-off-by Rob Herring <[email protected]>---
Don't know if I'm a little late for this series but:
Regards,
Nicolas
Rob Herring
maintainerPATCH 5/15 PCI: mobiveil: Use pci_host_probe() to register host
In reply to Rob HerringThe mobiveil host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- .../pci/controller/mobiveil/pcie-mobiveil-host.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
drivers/pci/controller/mobiveil/pcie-mobiveil-host.c +1 -15
@@ -569,8 +569,6 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)struct mobiveil_root_port *rp = &pcie->rp;struct pci_host_bridge *bridge = rp->bridge;struct device *dev = &pcie->pdev->dev; -struct pci_bus *bus; -struct pci_bus *child;int ret; ret =mobiveil_pcie_parse_dt (pcie);
@@ -620,17 +618,5 @@ int mobiveil_pcie_host_probe(struct mobiveil_pcie *pcie)return ret; } -/* setup the kernel resources for the newly added PCIe root bus */ - ret =pci_scan_root_bus_bridge (bridge); -if (ret) -return ret; - - bus = bridge->bus; - -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); - -return 0 ; +return pci_host_probe (bridge); }
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 6/15 PCI: tegra: Use pci_host_probe() to register host
In reply to Rob HerringThe tegra host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pci-tegra.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/pci/controller/pci-tegra.c +1 -10
@@ -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 pci_bus *child;struct resource *bus;int err;
@@ -2721,20 +2720,12 @@ static int tegra_pcie_probe(struct platform_device *pdev) host->map_irq = tegra_pcie_map_irq; host->swizzle_irq = pci_common_swizzle; - err =pci_scan_root_bus_bridge (host); + err =pci_host_probe (host);if (err <0 ) {dev_err (dev,"failed to register host: %d\n" , err); goto pm_runtime_put; } -pci_bus_size_bridges (host->bus); -pci_bus_assign_resources (host->bus); - -list_for_each_entry (child, &host->bus->children, node) -pcie_bus_configure_settings (child); - -pci_bus_add_devices (host->bus); -if (IS_ENABLED (CONFIG_DEBUG_FS )) { err =tegra_pcie_debugfs_init (pcie);if (err <0 )
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 7/15 PCI: v3: Use pci_host_probe() to register host
In reply to Rob HerringThe v3 host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pci-v3-semi.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/pci/controller/pci-v3-semi.c +1 -12
@@ -239,7 +239,6 @@ struct v3_pci {struct device *dev;void __iomem *base;void __iomem *config_base; -struct pci_bus *bus;u32 config_mem;u32 non_pre_mem;u32 pre_mem;
@@ -904,17 +903,7 @@ static int v3_pci_probe(struct platform_device *pdev) val |=V3_SYSTEM_M_LOCK ;writew (val, v3->base +V3_SYSTEM ); - ret =pci_scan_root_bus_bridge (host); -if (ret) { -dev_err (dev,"failed to register host: %d\n" , ret); -return ret; - } - v3->bus = host->bus; - -pci_bus_assign_resources (v3->bus); -pci_bus_add_devices (v3->bus); - -return 0 ; +return pci_host_probe (host); }static const struct of_device_id v3_pci_of_match[] = {
Signature · 1 line
2.25.1
Re: [PATCH 07/15] PCI: v3: Use pci_host_probe() to register host
Quoted 5 lines · Rob Herring
The v3 host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.Cc Linus Walleij <[email protected]>Signed-off-by Rob Herring <[email protected]>
Sweet!
Yours,
Linus Walleij
Rob Herring
maintainerPATCH 8/15 PCI: versatile: Use pci_host_probe() to register host
In reply to Rob HerringThe versatile host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pci-versatile.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/pci/controller/pci-versatile.c +1 -13
@@ -70,7 +70,6 @@ static int versatile_pci_probe(struct platform_device *pdev)int ret, i, myslot =-1 , mem =1 ;u32 val;void __iomem *local_pci_cfg_base; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge; bridge =devm_pci_alloc_host_bridge (dev,0 );
@@ -164,18 +163,7 @@ static int versatile_pci_probe(struct platform_device *pdev) bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (bridge); -if (ret <0 ) -return ret; - - bus = bridge->bus; - -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); - -return 0 ; +return pci_host_probe (bridge); }static const struct of_device_id versatile_pci_of_match[] = {
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 9/15 PCI: xgene: Use pci_host_probe() to register host
In reply to Rob HerringThe xgene host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pci-xgene.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/pci/controller/pci-xgene.c +1 -12
@@ -591,7 +591,6 @@ static int xgene_pcie_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device_node *dn = dev->of_node;struct xgene_pcie_port *port; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge;int ret;
@@ -632,17 +631,7 @@ static int xgene_pcie_probe(struct platform_device *pdev) bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (bridge); -if (ret <0 ) -return ret; - - bus = bridge->bus; - -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); -return 0 ; +return pci_host_probe (bridge); }static const struct of_device_id xgene_pcie_match_table[] = {
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 10/15 PCI: altera: Use pci_host_probe() to register host
In reply to Rob HerringThe altera host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
The only difference is pci_assign_unassigned_bus_resources() was called instead of pci_bus_size_bridges() and pci_bus_assign_resources(). This should be the same.
--- drivers/pci/controller/pcie-altera.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
drivers/pci/controller/pcie-altera.c +1 -16
@@ -773,8 +773,6 @@ static int altera_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct altera_pcie *pcie; -struct pci_bus *bus; -struct pci_bus *child;struct pci_host_bridge *bridge;int ret;const struct of_device_id *match;
@@ -825,20 +823,7 @@ static int altera_pcie_probe(struct platform_device *pdev) bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (bridge); -if (ret <0 ) -return ret; - - bus = bridge->bus; - -pci_assign_unassigned_bus_resources (bus); - -/* Configure PCI Express setting. */ -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); - -pci_bus_add_devices (bus); -return ret; +return pci_host_probe (bridge); }static int altera_pcie_remove (struct platform_device *pdev)
Signature · 1 line
2.25.1
RE: [PATCH 10/15] PCI: altera: Use pci_host_probe() to register host
Quoted 18 lines
-----Original Message-----
From: Rob Herring <[email protected]>
Sent: Saturday, May 23, 2020 7:48 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Bjorn Helgaas <[email protected]>; [email protected]; [email protected]; Tan, Ley Foon <[email protected]>; [email protected]
Subject: [PATCH 10/15] PCI: altera: Usepci_host_probe()to register hostThe altera host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.The only difference is
pci_assign_unassigned_bus_resources()was called instead ofpci_bus_size_bridges()andpci_bus_assign_resources(). This should be the same.
Quoted 7 lines
Cc Ley Foon Tan <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/pcie-altera.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
Regards
Ley Foon
Rob Herring
maintainerPATCH 11/15 PCI: iproc: Use pci_host_probe() to register host
In reply to Rob HerringThe iproc host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
The only difference is pci_assign_unassigned_bus_resources() was called instead of pci_bus_size_bridges() and pci_bus_assign_resources(). This should be the same.
--- drivers/pci/controller/pcie-iproc.c | 18 +++++------------- drivers/pci/controller/pcie-iproc.h | 2 -- 2 files changed, 5 insertions(+), 15 deletions(-)
drivers/pci/controller/pcie-iproc.c +5 -13
@@ -1470,7 +1470,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) {struct device *dev;int ret; -struct pci_bus *child;struct pci_host_bridge *host =pci_host_bridge_from_priv (pcie); dev = pcie->dev;
@@ -1531,21 +1530,12 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) host->map_irq = pcie->map_irq; host->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (host); + ret =pci_host_probe (host);if (ret <0 ) {dev_err (dev,"failed to scan host: %d\n" , ret); goto err_power_off_phy; } -pci_assign_unassigned_bus_resources (host->bus); - - pcie->root_bus = host->bus; - -list_for_each_entry (child, &host->bus->children, node) -pcie_bus_configure_settings (child); - -pci_bus_add_devices (host->bus); -return 0 ; err_power_off_phy:
@@ -1558,8 +1548,10 @@ EXPORT_SYMBOL(iproc_pcie_setup);int iproc_pcie_remove (struct iproc_pcie *pcie) { -pci_stop_root_bus (pcie->root_bus); -pci_remove_root_bus (pcie->root_bus); +struct pci_host_bridge *host =pci_host_bridge_from_priv (pcie); + +pci_stop_root_bus (host->bus); +pci_remove_root_bus (host->bus);iproc_pcie_msi_disable (pcie);
drivers/pci/controller/pcie-iproc.h +0 -2
@@ -54,7 +54,6 @@ struct iproc_msi;* @reg_offsets: register offsets * @base: PCIe host controller I/O register base * @base_addr: PCIe host controller register base physical address -* @root_bus: pointer to root bus * @phy: optional PHY device that controls the Serdes * @map_irq: function callback to map interrupts * @ep_is_internal: indicates an internal emulated endpoint device is connected
@@ -85,7 +84,6 @@ struct iproc_pcie {void __iomem *base;phys_addr_t base_addr;struct resource mem; -struct pci_bus *root_bus;struct phy *phy;int (*map_irq)(const struct pci_dev *,u8 ,u8 );bool ep_is_internal;
Signature · 1 line
2.25.1
Re: [PATCH 11/15] PCI: iproc: Use pci_host_probe() to register host
Quoted 7 lines · Rob Herring
The iproc host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.The only difference is
pci_assign_unassigned_bus_resources()was called instead ofpci_bus_size_bridges()andpci_bus_assign_resources(). This should be the same.
Quoted 5 lines
Cc Lorenzo Pieralisi <[email protected]>Cc Ray Jui <[email protected]>Cc Scott Branden <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 73 lines
--- drivers/pci/controller/pcie-iproc.c | 18 +++++------------- drivers/pci/controller/pcie-iproc.h | 2 -- 2 files changed, 5 insertions(+), 15 deletions(-)drivers/pci/controller/pcie-iproc.c +5
-13@@ -1470,7 +1470,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) {struct device *dev;int ret; -struct pci_bus *child;struct pci_host_bridge *host =pci_host_bridge_from_priv (pcie); dev = pcie->dev;@@ -1531,21 +1530,12 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) host->map_irq = pcie->map_irq; host->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (host); + ret =pci_host_probe (host);if (ret <0 ) {dev_err (dev,"failed to scan host: %d\n" , ret); goto err_power_off_phy; } -pci_assign_unassigned_bus_resources (host->bus); - - pcie->root_bus = host->bus; - -list_for_each_entry (child, &host->bus->children, node) -pcie_bus_configure_settings (child); - -pci_bus_add_devices (host->bus); -return 0 ; err_power_off_phy:@@ -1558,8 +1548,10 @@ EXPORT_SYMBOL(iproc_pcie_setup);int iproc_pcie_remove (struct iproc_pcie *pcie) { -pci_stop_root_bus (pcie->root_bus); -pci_remove_root_bus (pcie->root_bus); +struct pci_host_bridge *host =pci_host_bridge_from_priv (pcie); + +pci_stop_root_bus (host->bus); +pci_remove_root_bus (host->bus);iproc_pcie_msi_disable (pcie);drivers/pci/controller/pcie-iproc.h +0
-2@@ -54,7 +54,6 @@ struct iproc_msi;* @reg_offsets: register offsets * @base: PCIe host controller I/O register base * @base_addr: PCIe host controller register base physical address -* @root_bus: pointer to root bus * @phy: optional PHY device that controls the Serdes * @map_irq: function callback to map interrupts * @ep_is_internal: indicates an internal emulated endpoint device is connected @@ -85,7 +84,6 @@ struct iproc_pcie {void __iomem *base;phys_addr_t base_addr;struct resource mem; -struct pci_bus *root_bus;struct phy *phy;int (*map_irq)(const struct pci_dev *,u8 ,u8 );bool ep_is_internal;
Rob Herring
maintainerPATCH 12/15 PCI: rcar: Use pci_host_probe() to register host
In reply to Rob HerringThe rcar host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pcie-rcar-host.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
drivers/pci/controller/pcie-rcar-host.c +1 -17
@@ -330,8 +330,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; -struct pci_bus *bus, *child; -int ret;/* Try setting 5 GT/s link speed */ rcar_pcie_force_speedup (pcie);
@@ -349,21 +347,7 @@ static int rcar_pcie_enable(struct rcar_pcie_host *host)if (IS_ENABLED (CONFIG_PCI_MSI )) bridge->msi = &host->msi.chip; - ret =pci_scan_root_bus_bridge (bridge); -if (ret <0 ) -return ret; - - bus = bridge->bus; - -pci_bus_size_bridges (bus); -pci_bus_assign_resources (bus); - -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); - -pci_bus_add_devices (bus); - -return 0 ; +return pci_host_probe (bridge); }static int phy_wait_for_ack (struct rcar_pcie *pcie)
Signature · 1 line
2.25.1
Re: [PATCH 12/15] PCI: rcar: Use pci_host_probe() to register host
Hi Rob,
Quoted 7 lines · Rob Herring
The rcar host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.Cc Marek Vasut <[email protected]>Cc Yoshihiro Shimoda <[email protected]>Signed-off-by Rob Herring <[email protected]>
Thanks for your patch!
Note that this does have 2 side effects: the "linux,pci-probe-only" DT property and the "pcie_scan_all" kernel command line option are now taken into account.
Regardless:
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
maintainerPATCH 13/15 PCI: rockchip: Use pci_host_probe() to register host
In reply to Rob HerringThe rockchip host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
--- drivers/pci/controller/pcie-rockchip-host.c | 18 ++++-------------- drivers/pci/controller/pcie-rockchip.h | 1 - 2 files changed, 4 insertions(+), 15 deletions(-)
drivers/pci/controller/pcie-rockchip-host.c +4 -14
@@ -949,7 +949,6 @@ static int rockchip_pcie_probe(struct platform_device *pdev) {struct rockchip_pcie *rockchip;struct device *dev = &pdev->dev; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge;struct resource *bus_res;int err;
@@ -1015,20 +1014,10 @@ static int rockchip_pcie_probe(struct platform_device *pdev) bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - err =pci_scan_root_bus_bridge (bridge); + err =pci_host_probe (bridge);if (err <0 ) goto err_remove_irq_domain; - bus = bridge->bus; - - rockchip->root_bus = bus; - -pci_bus_size_bridges (bus); -pci_bus_assign_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); - -pci_bus_add_devices (bus);return 0 ; err_remove_irq_domain:
@@ -1051,9 +1040,10 @@ static int rockchip_pcie_remove(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct rockchip_pcie *rockchip =dev_get_drvdata (dev); +struct pci_host_bridge *bridge =pci_host_bridge_from_priv (rockchip); -pci_stop_root_bus (rockchip->root_bus); -pci_remove_root_bus (rockchip->root_bus); +pci_stop_root_bus (bridge->bus); +pci_remove_root_bus (bridge->bus);irq_domain_remove (rockchip->irq_domain);rockchip_pcie_deinit_phys (rockchip);
drivers/pci/controller/pcie-rockchip.h +0 -1
@@ -303,7 +303,6 @@ struct rockchip_pcie {struct device *dev;struct irq_domain *irq_domain;int offset; -struct pci_bus *root_bus;void __iomem *msg_region;phys_addr_t msg_bus_addr;bool is_rc;
Signature · 1 line
2.25.1
Rob Herring
maintainerPATCH 14/15 PCI: xilinx-nwl: Use pci_host_probe() to register host
In reply to Rob HerringThe xilinx-nwl host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
The only difference is pci_assign_unassigned_bus_resources() was called instead of pci_bus_size_bridges() and pci_bus_assign_resources(). This should be the same.
--- drivers/pci/controller/pcie-xilinx-nwl.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
drivers/pci/controller/pcie-xilinx-nwl.c +1 -13
@@ -817,8 +817,6 @@ static int nwl_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct nwl_pcie *pcie; -struct pci_bus *bus; -struct pci_bus *child;struct pci_host_bridge *bridge;int err;
@@ -871,17 +869,7 @@ static int nwl_pcie_probe(struct platform_device *pdev) } } - err =pci_scan_root_bus_bridge (bridge); -if (err) -return err; - - bus = bridge->bus; - -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); -return 0 ; +return pci_host_probe (bridge); }static struct platform_driver nwl_pcie_driver = {
Signature · 1 line
2.25.1
Re: [PATCH 14/15] PCI: xilinx-nwl: Use pci_host_probe() to register host
Quoted 36 lines · Rob Herring
The xilinx-nwl host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.The only difference is
pci_assign_unassigned_bus_resources()was called instead ofpci_bus_size_bridges()andpci_bus_assign_resources(). This should be the same.Cc Michal Simek <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/pcie-xilinx-nwl.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)drivers/pci/controller/pcie-xilinx-nwl.c +0
-7@@ -817,8 +817,6 @@ static int nwl_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct nwl_pcie *pcie; -struct pci_bus *bus; -struct pci_bus *child;struct pci_host_bridge *bridge;int err;@@ -871,17 +869,7 @@ static int nwl_pcie_probe(struct platform_device *pdev) } } - err =pci_scan_root_bus_bridge (bridge); -if (err) -return err; - - bus = bridge->bus;
drivers/pci/controller/pcie-xilinx-nwl.c static int nwl_pcie_probe(struct platform_device *pdev) · line 875
Quoted 10 lines
drivers/pci/controller/pcie-xilinx-nwl.c +1
-6- -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); -return 0 ; +return pci_host_probe (bridge); }static struct platform_driver nwl_pcie_driver = {
Bharat: Please review.
Thanks,
Michal
Rob Herring
maintainerPATCH 15/15 PCI: xilinx: Use pci_host_probe() to register host
In reply to Rob HerringThe xilinx host driver does the same host registration and bus scanning calls as pci_host_probe, so let's use it instead.
The only difference is pci_assign_unassigned_bus_resources() was called instead of pci_bus_size_bridges() and pci_bus_assign_resources(). This should be the same.
--- drivers/pci/controller/pcie-xilinx.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/pci/controller/pcie-xilinx.c +1 -12
@@ -616,7 +616,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct xilinx_pcie_port *port; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge;int err;
@@ -663,17 +662,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) xilinx_pcie_msi_chip.dev = dev; bridge->msi = &xilinx_pcie_msi_chip;#endif - err =pci_scan_root_bus_bridge (bridge); -if (err <0 ) -return err; - - bus = bridge->bus; - -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); -return 0 ; +return pci_host_probe (bridge); }static const struct of_device_id xilinx_pcie_of_match[] = {
Signature · 1 line
2.25.1
Re: [PATCH 15/15] PCI: xilinx: Use pci_host_probe() to register host
Quoted 35 lines · Rob Herring
The xilinx host driver does the same host registration and bus scanning calls as
pci_host_probe, so let's use it instead.The only difference is
pci_assign_unassigned_bus_resources()was called instead ofpci_bus_size_bridges()andpci_bus_assign_resources(). This should be the same.Cc Michal Simek <[email protected]>Signed-off-by Rob Herring <[email protected]>--- drivers/pci/controller/pcie-xilinx.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/pci/controller/pcie-xilinx.c +0
-6@@ -616,7 +616,6 @@ static int xilinx_pcie_probe(struct platform_device *pdev) {struct device *dev = &pdev->dev;struct xilinx_pcie_port *port; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge;int err;@@ -663,17 +662,7 @@ static int xilinx_pcie_probe(struct platform_device *pdev) xilinx_pcie_msi_chip.dev = dev; bridge->msi = &xilinx_pcie_msi_chip;#endif - err =pci_scan_root_bus_bridge (bridge); -if (err <0 ) -return err; - - bus = bridge->bus;
drivers/pci/controller/pcie-xilinx.c static int xilinx_pcie_probe(struct platform_device *pdev) · line 668
Quoted 10 lines
drivers/pci/controller/pcie-xilinx.c +1
-6- -pci_assign_unassigned_bus_resources (bus); -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); -pci_bus_add_devices (bus); -return 0 ; +return pci_host_probe (bridge); }static const struct of_device_id xilinx_pcie_of_match[] = {
Bharat: Please review.
Thanks,
Michal
Lorenzo Pieralisi
AppliedQuoted 40 lines · Rob Herring
I started this on my last series of dma-ranges rework and am just getting back to finishing it. This series simplifies the resource list handling in a couple of drivers and converts almost all the remaining drivers to use
pci_host_probe().The one holdout is Designware. This is due to the .scan_bus() hook which is only used by TI Keystone. I think it could be a fixup instead matching on the root bus id. I'm not sure though. See
ks_pcie_v3_65_scan_bus().Rob
Rob Herring (15):
PCI: cadence: Use struct pci_host_bridge.windows list directly
PCI: mvebu: Use struct pci_host_bridge.windows list directly
PCI: host-common: Use struct pci_host_bridge.windows list directly
PCI: brcmstb: Usepci_host_probe()to register host
PCI: mobiveil: Usepci_host_probe()to register host
PCI: tegra: Usepci_host_probe()to register host
PCI: v3: Usepci_host_probe()to register host
PCI: versatile: Usepci_host_probe()to register host
PCI: xgene: Usepci_host_probe()to register host
PCI: altera: Usepci_host_probe()to register host
PCI: iproc: Usepci_host_probe()to register host
PCI: rcar: Usepci_host_probe()to register host
PCI: rockchip: Usepci_host_probe()to register host
PCI: xilinx-nwl: Usepci_host_probe()to register host
PCI: xilinx: Usepci_host_probe()to register host.../controller/cadence/pcie-cadence-host.c | 26 ++++---------- .../controller/mobiveil/pcie-mobiveil-host.c | 16 +-------- drivers/pci/controller/pci-host-common.c | 36 ++++++------------- drivers/pci/controller/pci-mvebu.c | 13 +++---- drivers/pci/controller/pci-tegra.c | 11 +----- drivers/pci/controller/pci-v3-semi.c | 13 +------ drivers/pci/controller/pci-versatile.c | 14 +------- drivers/pci/controller/pci-xgene.c | 13 +------ drivers/pci/controller/pcie-altera.c | 17 +-------- drivers/pci/controller/pcie-brcmstb.c | 20 +++--------
Quoted 8 lines
drivers/pci/controller/pcie-iproc.c | 18 +++------- drivers/pci/controller/pcie-iproc.h | 2 -- drivers/pci/controller/pcie-rcar-host.c | 18 +--------- drivers/pci/controller/pcie-rockchip-host.c | 18 +++------- drivers/pci/controller/pcie-rockchip.h | 1 - drivers/pci/controller/pcie-xilinx-nwl.c | 14 +------- drivers/pci/controller/pcie-xilinx.c | 13 +------ 17 files changed, 45 insertions(+), 218 deletions(-)
Applied to pci/misc for v5.9, thanks !
Lorenzo