diff mbox

[v2,23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code

Message ID 1421800225-26230-24-git-send-email-wangyijing@huawei.com
State Superseded
Headers show

Commit Message

Yijing Wang Jan. 21, 2015, 12:30 a.m. UTC
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.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
CC: Jason Cooper <jason@lakedaemon.net>
---
 drivers/pci/host/pci-mvebu.c |   18 +-----------------
 1 files changed, 1 insertions(+), 17 deletions(-)

Comments

Thomas Petazzoni Jan. 22, 2015, 5:40 p.m. UTC | #1
Dear Yijing Wang,

On Wed, 21 Jan 2015 08:30:18 +0800, Yijing Wang wrote:
> 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.
> 
> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> CC: Jason Cooper <jason@lakedaemon.net>

While I'm fine with the change to pci_common_init_dev(), I am not so
sure about the removal of mvebu_pcie_scan_bus(). I vaguely remember
that we intentionally did not use the default function for a specific
reason. Of course, this was a long time ago, and I don't remember the
reason. I would have to take a bit of time to 1/ review the archives of
the discussion surrounding the pcie-mvebu driver, and 2/ test your
patch to validate it works fine on HW.

Thanks!

Thomas
Yijing Wang Jan. 23, 2015, 2:11 a.m. UTC | #2
On 2015/1/23 1:40, Thomas Petazzoni wrote:
> Dear Yijing Wang,
> 
> On Wed, 21 Jan 2015 08:30:18 +0800, Yijing Wang wrote:
>> 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.
>>
>> Signed-off-by: Yijing Wang <wangyijing@huawei.com>
>> CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>> CC: Jason Cooper <jason@lakedaemon.net>
> 
> While I'm fine with the change to pci_common_init_dev(), I am not so
> sure about the removal of mvebu_pcie_scan_bus(). I vaguely remember
> that we intentionally did not use the default function for a specific
> reason. Of course, this was a long time ago, and I don't remember the
> reason. I would have to take a bit of time to 1/ review the archives of
> the discussion surrounding the pcie-mvebu driver, and 2/ test your
> patch to validate it works fine on HW.

Hi Thomas, Thanks for your comments and help to test :)

> 
> Thanks!
> 
> Thomas
>
Lorenzo Pieralisi Feb. 16, 2015, 5:46 p.m. UTC | #3
Hi Thomas,

On Thu, Jan 22, 2015 at 05:40:00PM +0000, Thomas Petazzoni wrote:
> Dear Yijing Wang,
> 
> On Wed, 21 Jan 2015 08:30:18 +0800, Yijing Wang wrote:
> > 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.
> > 
> > Signed-off-by: Yijing Wang <wangyijing@huawei.com>
> > CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > CC: Jason Cooper <jason@lakedaemon.net>
> 
> While I'm fine with the change to pci_common_init_dev(), I am not so
> sure about the removal of mvebu_pcie_scan_bus(). I vaguely remember
> that we intentionally did not use the default function for a specific
> reason. Of course, this was a long time ago, and I don't remember the
> reason. I would have to take a bit of time to 1/ review the archives of
> the discussion surrounding the pcie-mvebu driver, and 2/ test your
> patch to validate it works fine on HW.

I guess the reason: by providing the scan pointer to pcibios through
the hw_pci struct you were preventing calling pci_scan_root_bus() in
bios32.c that in turn can add devices before the resources are assigned.

Basically mvebu_pci_scan_bus() was doing what pci_scan_root_bus() does
except for calling pci_bus_add_devices().

Yijing patches remove pci_bus_add_devices() from pci_scan_root_bus() so
his change should be fine and it actually improves the current behaviour
which is quite hard to untangle, and not just on mvebu (I suspect
drivers/pci/host/pcie-xilinx.c can suffer from the same problem).

Lorenzo

> 
> Thanks!
> 
> Thomas
> -- 
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index 1309cfb..d5a2b70 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -750,21 +750,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,
@@ -808,12 +793,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);
 }
 
 /*