Skip to contentSkip to conversation

Some cleanup for pcie host drivers

PATCH Superseded Yijing Wang 5 participants 17 messages Apr 28, 2015 – Jun 16, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v11 cover Some cleanup for pcie host drivers

These patches are split out from patchset(patch 5 is new) "Refine PCI scan interfaces and make generic pci host bridge". They are independent of the series, pci_bus_add_devices() has been ripped out from pci_scan_root_bus(), so we could use pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity. Also this is the preparation for the series.

Yijing Wang (5):
PCI: mvebu: Use pci_common_init_dev() to simplify code
PCI: tegra: Remove redundant tegra_pcie_scan_bus()
PCI: designware: Use pci_scan_root_bus() for simplicity
PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

 drivers/pci/host/pci-mvebu.c       |   18 +-----------------
 drivers/pci/host/pci-tegra.c       |   16 ----------------
 drivers/pci/host/pci-xgene.c       |    3 +--
 drivers/pci/host/pcie-designware.c |    4 +---
 drivers/pci/host/pcie-iproc.c      |    5 ++---
 5 files changed, 5 insertions(+), 41 deletions(-)
#1 lore raw

PATCH v11 1/5 PCI: mvebu: Use pci_common_init_dev() to simplify code

Mvebu_pcie_scan_bus() is not necessary, we could use pci_common_init_dev() instead of pci_common_init(), and pass the device pointer as the parent. Then pci_scan_root_bus() will be called to scan the pci busses.

---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)
drivers/pci/host/pci-mvebu.c +1 -17
index 1ab8635..70aa095 100644
@@ -751,21 +751,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -809,12 +794,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
Signature · 1 line
1.7.1
maintainer
#2 lore raw

PATCH v11 1/5 PCI: mvebu: Use pci_common_init_dev() to simplify code

Quoted 10 lines · Yijing Wang

Mvebu_pcie_scan_bus() is not necessary, we could use pci_common_init_dev() instead of pci_common_init(), and pass the device pointer as the parent. Then pci_scan_root_bus() will be called to scan the pci busses.

Thomas, Jason, any input?

Quoted 47 lines
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)
drivers/pci/host/pci-mvebu.c +1 -17
index 1ab8635..70aa095 100644
@@ -751,21 +751,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)
 	return 1;
 }
 
-static struct pci_bus *mvebu_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct mvebu_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(&pcie->pdev->dev, sys->busnr,
-				  &mvebu_pcie_ops, sys, &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
 						 const struct resource *res,
 						 resource_size_t start,
@@ -809,12 +794,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
 	hw.nr_controllers = 1;
 	hw.private_data   = (void **)&pcie;
 	hw.setup          = mvebu_pcie_setup;
-	hw.scan           = mvebu_pcie_scan_bus;
 	hw.map_irq        = of_irq_parse_and_map_pci;
 	hw.ops            = &mvebu_pcie_ops;
 	hw.align_resource = mvebu_pcie_align_resource;
 
-	pci_common_init(&hw);
+	pci_common_init_dev(&pcie->pdev->dev, &hw);
 }
 
 /*
Signature · 1 line
1.7.1
#3 lore raw

PATCH v11 2/5 PCI: tegra: Remove redundant tegra_pcie_scan_bus()

In reply to Yijing Wang

Now pci_scan_root_bus() is almost similar to pci_create_root_bus() + pci_scan_child_bus(). So we could use common pci_scan_root_bus() in pci_common_init_dev() to scan pci busses. tegra_pcie_scan_bus() is redundant, remove it.

CC Thierry Reding <[email protected]>
CC linux-tegra at vger.kernel.org
---
 drivers/pci/host/pci-tegra.c |   16 ----------------
 1 files changed, 0 insertions(+), 16 deletions(-)
drivers/pci/host/pci-tegra.c +0 -16
index 00e9272..10c0571 100644
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 	return irq;
 }
 
-static struct pci_bus *tegra_pcie_scan_bus(int nr, struct pci_sys_data *sys)
-{
-	struct tegra_pcie *pcie = sys_to_pcie(sys);
-	struct pci_bus *bus;
-
-	bus = pci_create_root_bus(pcie->dev, sys->busnr, &tegra_pcie_ops, sys,
-				  &sys->resources);
-	if (!bus)
-		return NULL;
-
-	pci_scan_child_bus(bus);
-
-	return bus;
-}
-
 static irqreturn_t tegra_pcie_isr(int irq, void *arg)
 {
 	const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie)
 	hw.private_data = (void **)&pcie;
 	hw.setup = tegra_pcie_setup;
 	hw.map_irq = tegra_pcie_map_irq;
-	hw.scan = tegra_pcie_scan_bus;
 	hw.ops = &tegra_pcie_ops;
 
 	pci_common_init_dev(pcie->dev, &hw);
Signature · 1 line
1.7.1
#4 lore raw

PATCH v11 3/5 PCI: designware: Use pci_scan_root_bus() for simplicity

In reply to Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Designware added the busn resource to resources list in dw_pcie_setup(). So it should be safe to use pci_scan_root_bus() instead.

CC Mohit Kumar <[email protected]>
CC Jingoo Han <[email protected]>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-designware.c +1 -3
index 2e9f84f..8c80f38 100644
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH v11 3/5 PCI: designware: Use pci_scan_root_bus() for simplicity

Am Dienstag, den 28.04.2015, 15:01 +0800 schrieb Yijing Wang:

Quoted 10 lines

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Designware added the busn resource to resources list in dw_pcie_setup(). So it should be safe to use pci_scan_root_bus() instead.

CC Mohit Kumar <[email protected]>
CC Jingoo Han <[email protected]>
Quoted 23 lines
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-designware.c +1 -3
index 2e9f84f..8c80f38 100644
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
maintainer
#6 lore raw

PATCH v11 3/5 PCI: designware: Use pci_scan_root_bus() for simplicity

In reply to Yijing Wang

[+cc Pratyush]

Quoted 10 lines · Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Designware added the busn resource to resources list in dw_pcie_setup(). So it should be safe to use pci_scan_root_bus() instead.

CC Mohit Kumar <[email protected]>
CC Jingoo Han <[email protected]>

Jingoo, Pratyush?

Quoted 26 lines
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-designware.c +1 -3
index 2e9f84f..8c80f38 100644
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 	struct pcie_port *pp = sys_to_pcie(sys);
 
 	pp->root_bus_nr = sys->busnr;
-	bus = pci_create_root_bus(pp->dev, sys->busnr,
+	bus = pci_scan_root_bus(pp->dev, sys->busnr,
 				  &dw_pcie_ops, sys, &sys->resources);
 	if (!bus)
 		return NULL;
 
-	pci_scan_child_bus(bus);
-
 	if (bus && pp->ops->scan_bus)
 		pp->ops->scan_bus(pp);
 
Signature · 1 line
1.7.1
#7 lore raw

PATCH v11 4/5 PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()

In reply to Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Xgene added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

CC Tanmay Inamdar <[email protected]>
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/host/pci-xgene.c +1 -2
index ee082c0..87e3962 100644
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
Signature · 1 line
1.7.1
maintainer
#8 lore raw

PATCH v11 4/5 PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()

Quoted 9 lines · Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Xgene added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

CC Tanmay Inamdar <[email protected]>

Tanmay, any comments on this?

Quoted 29 lines
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/host/pci-xgene.c +1 -2
index ee082c0..87e3962 100644
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	bus = pci_create_root_bus(&pdev->dev, 0,
+	bus = pci_scan_root_bus(&pdev->dev, 0,
 					&xgene_pcie_ops, port, &res);
 	if (!bus)
 		return -ENOMEM;
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_bus_add_devices(bus);
 
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#9 lore raw

PATCH v11 4/5 PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()

Quoted 8 lines · Bjorn Helgaas
Quoted 7 lines · Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Xgene added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

Quoted 5 lines
Quoted 2 lines
CC Tanmay Inamdar <[email protected]>

Tanmay, any comments on this?

Looks good to me.

Quoted 29 lines
Quoted 29 lines
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/host/pci-xgene.c +1 -3
index ee082c0..87e3962 100644
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
      if (ret)
              return ret;
 
-     bus = pci_create_root_bus(&pdev->dev, 0,
+     bus = pci_scan_root_bus(&pdev->dev, 0,
                                      &xgene_pcie_ops, port, &res);
      if (!bus)
              return -ENOMEM;
 
-     pci_scan_child_bus(bus);
      pci_assign_unassigned_bus_resources(bus);
      pci_bus_add_devices(bus);
 
--

1.7.1

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

maintainer
#10 lore raw

PATCH v11 4/5 PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()

[+cc Duc, Loc]

Quoted 12 lines · Tanmay Inamdar
Quoted 11 lines · Bjorn Helgaas
Quoted 9 lines · Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. Xgene added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

CC Tanmay Inamdar <[email protected]>
Quoted 6 lines
Quoted 2 lines

Tanmay, any comments on this?

Looks good to me.

I had applied this, but dropped it because it conflicted with Duc's MSI patch, which adds a call to xgene_pcie_msi_enable() between pci_create_root_bus() and pci_scan_child_bus().

We should figure out a better way to do this, e.g., with pci_host_bridge_ops, so we can use pci_scan_root_bus() on X-Gene. But we don't have that yet.

Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
---
 drivers/pci/host/pci-xgene.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/host/pci-xgene.c +1 -3
index ee082c0..87e3962 100644
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)
      if (ret)
              return ret;
 
-     bus = pci_create_root_bus(&pdev->dev, 0,
+     bus = pci_scan_root_bus(&pdev->dev, 0,
                                      &xgene_pcie_ops, port, &res);
      if (!bus)
              return -ENOMEM;
 
-     pci_scan_child_bus(bus);
      pci_assign_unassigned_bus_resources(bus);
      pci_bus_add_devices(bus);
 
--

1.7.1

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

#11 lore raw

PATCH v11 5/5 PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

In reply to Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. iproc added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

---
 drivers/pci/host/pcie-iproc.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-iproc.c +2 -3
index 329e1b5..9622ebf 100644
@@ -210,10 +210,10 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	pcie->sysdata.private_data = pcie;
 
-	bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops,
+	bus = pci_scan_root_bus(pcie->dev, 0, &iproc_pcie_ops,
 				  &pcie->sysdata, pcie->resources);
 	if (!bus) {
-		dev_err(pcie->dev, "unable to create PCI root bus\n");
+		dev_err(pcie->dev, "unable to scan PCI root bus\n");
 		ret = -ENOMEM;
 		goto err_power_off_phy;
 	}
@@ -227,7 +227,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	iproc_pcie_enable(pcie);
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
 	pci_bus_add_devices(bus);
Signature · 1 line
1.7.1
maintainer
#12 lore raw

PATCH v11 5/5 PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

Hi Yijing,

Quoted 20 lines · Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. iproc added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

---
 drivers/pci/host/pcie-iproc.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-iproc.c +0 -0
index 329e1b5..9622ebf 100644
@@ -210,10 +210,10 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	pcie->sysdata.private_data = pcie;

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie) · line 219

Quoted 10 lines
drivers/pci/host/pcie-iproc.c +2 -2
 
-	bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops,
+	bus = pci_scan_root_bus(pcie->dev, 0, &iproc_pcie_ops,
 				  &pcie->sysdata, pcie->resources);
 	if (!bus) {
-		dev_err(pcie->dev, "unable to create PCI root bus\n");
+		dev_err(pcie->dev, "unable to scan PCI root bus\n");
 		ret = -ENOMEM;
 		goto err_power_off_phy;
 	}

iproc_pcie_check_link is called here by using the 'bus' structure returned from pci_create_root_bus. In iproc_pcie_check_link, we configure root bus class to PCI_CLASS_BRIDGE_PCI and validate to ensure a stable link between RC and EP can be detected.

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie) · line 228

Quoted 3 lines
drivers/pci/host/pcie-iproc.c +0 -0
@@ -227,7 +227,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	iproc_pcie_enable(pcie);

Here we enable INTx support for our RC controller.

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie) · line 230

Quoted 2 lines
drivers/pci/host/pcie-iproc.c +0 -1
-	pci_scan_child_bus(bus);

Here, if pci_scan_child_bus is moved to before iproc_pcie_check_link, I don't think it would work (although I have not tested this).

An alternative is to use a dummy bus structure to feed into iproc_pcie_check_link, and call iproc_pcie_check_link and iproc_pcie_enable before pci_scan_root_bus. But the reason I put the link check code in between pci_create_root_bus and pci_scan_child_bus was to avoid using a dummy bus structure, :)

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie)

Quoted 4 lines
drivers/pci/host/pcie-iproc.c +0 -0
 	pci_assign_unassigned_bus_resources(bus);
 	pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
 	pci_bus_add_devices(bus);
 

Thanks,

Ray

#13 lore raw

PATCH v11 5/5 PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

Quoted 4 lines
Quoted 4 lines
drivers/pci/host/pcie-iproc.c +0 -0
@@ -210,10 +210,10 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	pcie->sysdata.private_data = pcie;
 
Quoted 14 lines

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie) · line 219

Quoted 9 lines
drivers/pci/host/pcie-iproc.c +2 -2
-	bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops,
+	bus = pci_scan_root_bus(pcie->dev, 0, &iproc_pcie_ops,
 				  &pcie->sysdata, pcie->resources);
 	if (!bus) {
-		dev_err(pcie->dev, "unable to create PCI root bus\n");
+		dev_err(pcie->dev, "unable to scan PCI root bus\n");
 		ret = -ENOMEM;
 		goto err_power_off_phy;
 	}

iproc_pcie_check_link is called here by using the 'bus' structure returned from pci_create_root_bus. In iproc_pcie_check_link, we configure root bus class to PCI_CLASS_BRIDGE_PCI and validate to ensure a stable link between RC and EP can be detected.

Oh, I got it. Thanks for your explanation.

Quoted 13 lines

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie) · line 228

Quoted 4 lines
drivers/pci/host/pcie-iproc.c +0 -0
@@ -227,7 +227,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	iproc_pcie_enable(pcie);

Here we enable INTx support for our RC controller.

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie) · line 230

Quoted 2 lines
drivers/pci/host/pcie-iproc.c +0 -1
-	pci_scan_child_bus(bus);

Here, if pci_scan_child_bus is moved to before iproc_pcie_check_link, I don't think it would work (although I have not tested this).

Quoted 5 lines

An alternative is to use a dummy bus structure to feed into iproc_pcie_check_link, and call iproc_pcie_check_link and iproc_pcie_enable before pci_scan_root_bus. But the reason I put the link check code in between pci_create_root_bus and pci_scan_child_bus was to avoid using a dummy bus structure, :)

Maybe we could refactor this by add a new pci_host_bridge_ops in the later patch.

Quoted 12 lines

drivers/pci/host/pcie-iproc.c int iproc_pcie_setup(struct iproc_pcie *pcie)

Quoted 5 lines
drivers/pci/host/pcie-iproc.c +0 -0
 	pci_assign_unassigned_bus_resources(bus);
 	pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
 	pci_bus_add_devices(bus);
 

Thanks,

Ray

.

Signature · 2 lines
Thanks!
Yijing
#14 lore raw

PATCH v11 5/5 PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

In reply to Yijing Wang

Hi Bjorn, please ignore this patch, it's not correct. I prefer to refactor it by add a new pci_host_bridge_ops in later patch. What do you think about the prior four patches ? I hope they could be merged first, they are independent.

Thanks!
Yijing.

Quoted 39 lines · Yijing Wang

Pci_bus_add_devices() was ripped out of pci_scan_root_bus(). Now pci_scan_root_bus() == pci_create_root_bus() + pci_scan_child_bus() if busn resource is supplied. iproc added the busn resource to resources list
in of_pci_get_host_bridge_resources(). So it should be safe to use pci_scan_root_bus() instead.

---
 drivers/pci/host/pcie-iproc.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-iproc.c +2 -3
index 329e1b5..9622ebf 100644
@@ -210,10 +210,10 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	pcie->sysdata.private_data = pcie;
 
-	bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops,
+	bus = pci_scan_root_bus(pcie->dev, 0, &iproc_pcie_ops,
 				  &pcie->sysdata, pcie->resources);
 	if (!bus) {
-		dev_err(pcie->dev, "unable to create PCI root bus\n");
+		dev_err(pcie->dev, "unable to scan PCI root bus\n");
 		ret = -ENOMEM;
 		goto err_power_off_phy;
 	}
@@ -227,7 +227,6 @@ int iproc_pcie_setup(struct iproc_pcie *pcie)
 
 	iproc_pcie_enable(pcie);
 
-	pci_scan_child_bus(bus);
 	pci_assign_unassigned_bus_resources(bus);
 	pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci);
 	pci_bus_add_devices(bus);
Signature · 2 lines
Thanks!
Yijing
#15 lore raw

v11 cover Some cleanup for pcie host drivers

In reply to Yijing Wang

Hi Bjorn, sorry to bother you, do you have time to look at these patches ?

Quoted 25 lines · Yijing Wang

These patches are split out from patchset(patch 5 is new) "Refine PCI scan interfaces and make generic pci host bridge". They are independent of the series, pci_bus_add_devices() has been ripped out from pci_scan_root_bus(), so we could use pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity. Also this is the preparation for the series.

Yijing Wang (5):
PCI: mvebu: Use pci_common_init_dev() to simplify code
PCI: tegra: Remove redundant tegra_pcie_scan_bus()
PCI: designware: Use pci_scan_root_bus() for simplicity
PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

 drivers/pci/host/pci-mvebu.c       |   18 +-----------------
 drivers/pci/host/pci-tegra.c       |   16 ----------------
 drivers/pci/host/pci-xgene.c       |    3 +--
 drivers/pci/host/pcie-designware.c |    4 +---
 drivers/pci/host/pcie-iproc.c      |    5 ++---
 5 files changed, 5 insertions(+), 41 deletions(-)

.

Signature · 2 lines
Thanks!
Yijing
maintainer Applied
#16 lore raw

v11 cover Some cleanup for pcie host drivers

In reply to Yijing Wang
Quoted 8 lines · Yijing Wang

These patches are split out from patchset(patch 5 is new) "Refine PCI scan interfaces and make generic pci host bridge". They are independent of the series, pci_bus_add_devices() has been ripped out from pci_scan_root_bus(), so we could use pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity. Also this is the preparation for the series.

Quoted 5 lines

Yijing Wang (5):
PCI: mvebu: Use pci_common_init_dev() to simplify code
PCI: tegra: Remove redundant tegra_pcie_scan_bus()
PCI: designware: Use pci_scan_root_bus() for simplicity
PCI: xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()

I applied the four patches above to pci/enumeration for v4.2, thanks.

Quoted 13 lines

PCI: iproc: Use pci_scan_root_bus() instead of pci_create_root_bus()

 drivers/pci/host/pci-mvebu.c       |   18 +-----------------
 drivers/pci/host/pci-tegra.c       |   16 ----------------
 drivers/pci/host/pci-xgene.c       |    3 +--
 drivers/pci/host/pcie-designware.c |    4 +---
 drivers/pci/host/pcie-iproc.c      |    5 ++---
 5 files changed, 5 insertions(+), 41 deletions(-)

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