diff mbox series

[v2,01/38] pci: fsl_pci_init: Dynamically allocate the PCI regions

Message ID 1613663886-83811-2-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series ppc: qemu: Convert qemu-ppce500 to driver model and enable additional driver support | expand

Commit Message

Bin Meng Feb. 18, 2021, 3:57 p.m. UTC
Commit e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
changes 'struct pci_controller'.regions from pre-allocated array of
regions to dynamically allocated, which unfortunately broken lots of
boards that still use the non-DM PCI driver.

This patch changes the non-DM fsl_pci_init driver to dynamically
allocate the regions, just like what's done in the pci uclass driver.

Fixes: e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>

---

Changes in v2:
- drop the revert patch of commit e002474158d1
- new patch: pci: fsl_pci_init: Dynamically allocate the PCI regions

 drivers/pci/fsl_pci_init.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Glass Feb. 20, 2021, 11:54 a.m. UTC | #1
Hi Bin,

On Thu, 18 Feb 2021 at 08:58, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Commit e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
> changes 'struct pci_controller'.regions from pre-allocated array of
> regions to dynamically allocated, which unfortunately broken lots of
> boards that still use the non-DM PCI driver.
>
> This patch changes the non-DM fsl_pci_init driver to dynamically
> allocate the regions, just like what's done in the pci uclass driver.
>
> Fixes: e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
>
> ---
>
> Changes in v2:
> - drop the revert patch of commit e002474158d1
> - new patch: pci: fsl_pci_init: Dynamically allocate the PCI regions
>
>  drivers/pci/fsl_pci_init.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

But I think it would be better to disable PCI on these devices
(Kconfig depends on BROKEN) until the maintainer converts it to DM.
Tom Rini Feb. 20, 2021, 1:57 p.m. UTC | #2
On Sat, Feb 20, 2021 at 04:54:50AM -0700, Simon Glass wrote:
> Hi Bin,
> 
> On Thu, 18 Feb 2021 at 08:58, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Commit e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
> > changes 'struct pci_controller'.regions from pre-allocated array of
> > regions to dynamically allocated, which unfortunately broken lots of
> > boards that still use the non-DM PCI driver.
> >
> > This patch changes the non-DM fsl_pci_init driver to dynamically
> > allocate the regions, just like what's done in the pci uclass driver.
> >
> > Fixes: e002474158d1 ("pci: pci-uclass: Dynamically allocate the PCI regions")
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> >
> > ---
> >
> > Changes in v2:
> > - drop the revert patch of commit e002474158d1
> > - new patch: pci: fsl_pci_init: Dynamically allocate the PCI regions
> >
> >  drivers/pci/fsl_pci_init.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> But I think it would be better to disable PCI on these devices
> (Kconfig depends on BROKEN) until the maintainer converts it to DM.

I don't think that will work here and I suspect disabling PCI will lead
to a ton of other build problems.  I'm going to try and finish up a
branch that removes all of the DM_MMC fail to convert boards (which has
a lot of overlap with other fail to converts) and then we can see what's
missing still for DM_PCI and some others.
diff mbox series

Patch

diff --git a/drivers/pci/fsl_pci_init.c b/drivers/pci/fsl_pci_init.c
index e72a60c..fc3327e 100644
--- a/drivers/pci/fsl_pci_init.c
+++ b/drivers/pci/fsl_pci_init.c
@@ -32,6 +32,8 @@  DECLARE_GLOBAL_DATA_PTR;
 #include <asm/io.h>
 #include <asm/fsl_pci.h>
 
+#define MAX_PCI_REGIONS 7
+
 #ifndef CONFIG_SYS_PCI_MEMORY_BUS
 #define CONFIG_SYS_PCI_MEMORY_BUS 0
 #endif
@@ -80,6 +82,9 @@  int fsl_setup_hose(struct pci_controller *hose, unsigned long addr)
 	/* Reset hose to make sure its in a clean state */
 	memset(hose, 0, sizeof(struct pci_controller));
 
+	hose->regions = (struct pci_region *)
+		calloc(1, MAX_PCI_REGIONS * sizeof(struct pci_region));
+
 	pci_setup_indirect(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
 
 	return fsl_is_pci_agent(hose);