diff mbox series

[RFC,v1,2/3] nvme: pci: Enable for SPL

Message ID 20220929095639.355675-3-mchitale@ventanamicro.com
State Changes Requested
Delegated to: Simon Glass
Headers show
Series SPL NVMe support | expand

Commit Message

Mayuresh Chitale Sept. 29, 2022, 9:56 a.m. UTC
Build PCI NVMe driver when enabled for SPI and enable dm-pre-reloc for
the driver. Also enable PCI_PNP for SPL which is required to auto
configure the PCIe devices.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 drivers/Makefile         | 2 +-
 drivers/nvme/Makefile    | 2 +-
 drivers/nvme/nvme_pci.c  | 1 +
 drivers/pci/Kconfig      | 7 +++++++
 drivers/pci/pci-uclass.c | 3 ++-
 5 files changed, 12 insertions(+), 3 deletions(-)

Comments

Simon Glass Sept. 29, 2022, 11:55 p.m. UTC | #1
Hi Mayuresh,

On Thu, 29 Sept 2022 at 03:57, Mayuresh Chitale
<mchitale@ventanamicro.com> wrote:
>
> Build PCI NVMe driver when enabled for SPI and enable dm-pre-reloc for
> the driver. Also enable PCI_PNP for SPL which is required to auto
> configure the PCIe devices.
>
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> ---
>  drivers/Makefile         | 2 +-
>  drivers/nvme/Makefile    | 2 +-
>  drivers/nvme/nvme_pci.c  | 1 +
>  drivers/pci/Kconfig      | 7 +++++++
>  drivers/pci/pci-uclass.c | 3 ++-
>  5 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/Makefile b/drivers/Makefile
> index eba9940231..581ae9f819 100644
> --- a/drivers/Makefile
> +++ b/drivers/Makefile
> @@ -34,6 +34,7 @@ obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
>  obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
>  obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
>  obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
> +obj-$(CONFIG_$(SPL_)NVME) += nvme/
>  obj-$(CONFIG_XEN) += xen/
>  obj-$(CONFIG_$(SPL_)FPGA) += fpga/
>
> @@ -86,7 +87,6 @@ obj-y += crypto/
>  obj-$(CONFIG_FASTBOOT) += fastboot/
>  obj-y += misc/
>  obj-$(CONFIG_MMC) += mmc/
> -obj-$(CONFIG_NVME) += nvme/
>  obj-$(CONFIG_PCI_ENDPOINT) += pci_endpoint/
>  obj-y += dfu/
>  obj-$(CONFIG_PCH) += pch/
> diff --git a/drivers/nvme/Makefile b/drivers/nvme/Makefile
> index fa7b619446..fd3e68a91d 100644
> --- a/drivers/nvme/Makefile
> +++ b/drivers/nvme/Makefile
> @@ -4,4 +4,4 @@
>
>  obj-y += nvme-uclass.o nvme.o nvme_show.o
>  obj-$(CONFIG_NVME_APPLE) += nvme_apple.o
> -obj-$(CONFIG_NVME_PCI) += nvme_pci.o
> +obj-$(CONFIG_$(SPL_)NVME_PCI) += nvme_pci.o
> diff --git a/drivers/nvme/nvme_pci.c b/drivers/nvme/nvme_pci.c
> index 36bf9c5ffb..16d8b9fff7 100644
> --- a/drivers/nvme/nvme_pci.c
> +++ b/drivers/nvme/nvme_pci.c
> @@ -39,6 +39,7 @@ U_BOOT_DRIVER(nvme) = {
>         .bind   = nvme_bind,
>         .probe  = nvme_probe,
>         .priv_auto      = sizeof(struct nvme_dev),
> +       .flags  = DM_FLAG_PRE_RELOC,

Why is this here? It is only applicable on some boards.

Instead, add the appropriate tag (e.g. u-boot,dm-spl) to the device node.

>  };
>
>  struct pci_device_id nvme_supported[] = {
> diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
> index 22f4995453..2d4c9f0781 100644
> --- a/drivers/pci/Kconfig
> +++ b/drivers/pci/Kconfig
> @@ -40,6 +40,13 @@ config PCI_PNP
>         help
>           Enable PCI memory and I/O space resource allocation and assignment.
>
> +config SPL_PCI_PNP
> +       bool "Enable Plug & Play support for PCI"
> +       default n
> +       help
> +         Enable PCI memory and I/O space resource allocation and assignment.
> +         This is required to auto configure the enumerated devices.
> +
>  config PCI_REGION_MULTI_ENTRY
>         bool "Enable Multiple entries of region type MEMORY in ranges for PCI"
>         help
> diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> index 16a6a699f9..62d2409a6d 100644
> --- a/drivers/pci/pci-uclass.c
> +++ b/drivers/pci/pci-uclass.c
> @@ -1140,7 +1140,8 @@ static int pci_uclass_post_probe(struct udevice *bus)
>         if (ret)
>                 return log_msg_ret("bind", ret);
>
> -       if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() &&
> +       if ((CONFIG_IS_ENABLED(PCI_PNP) || CONFIG_IS_ENABLED(SPL_PCI_PNP)) &&
> +           ll_boot_init() &&
>             (!hose->skip_auto_config_until_reloc ||
>              (gd->flags & GD_FLG_RELOC))) {
>                 ret = pci_auto_config_devices(bus);
> --
> 2.25.1
>

Regards,
Simon
Mayuresh Chitale Sept. 30, 2022, 4:58 p.m. UTC | #2
Hi Simon,

On Fri, Sep 30, 2022 at 5:26 AM Simon Glass <sjg@chromium.org> wrote:

> Hi Mayuresh,
>
> On Thu, 29 Sept 2022 at 03:57, Mayuresh Chitale
> <mchitale@ventanamicro.com> wrote:
> >
> > Build PCI NVMe driver when enabled for SPI and enable dm-pre-reloc for
> > the driver. Also enable PCI_PNP for SPL which is required to auto
> > configure the PCIe devices.
> >
> > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > ---
> >  drivers/Makefile         | 2 +-
> >  drivers/nvme/Makefile    | 2 +-
> >  drivers/nvme/nvme_pci.c  | 1 +
> >  drivers/pci/Kconfig      | 7 +++++++
> >  drivers/pci/pci-uclass.c | 3 ++-
> >  5 files changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/Makefile b/drivers/Makefile
> > index eba9940231..581ae9f819 100644
> > --- a/drivers/Makefile
> > +++ b/drivers/Makefile
> > @@ -34,6 +34,7 @@ obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
> >  obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
> >  obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
> >  obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
> > +obj-$(CONFIG_$(SPL_)NVME) += nvme/
> >  obj-$(CONFIG_XEN) += xen/
> >  obj-$(CONFIG_$(SPL_)FPGA) += fpga/
> >
> > @@ -86,7 +87,6 @@ obj-y += crypto/
> >  obj-$(CONFIG_FASTBOOT) += fastboot/
> >  obj-y += misc/
> >  obj-$(CONFIG_MMC) += mmc/
> > -obj-$(CONFIG_NVME) += nvme/
> >  obj-$(CONFIG_PCI_ENDPOINT) += pci_endpoint/
> >  obj-y += dfu/
> >  obj-$(CONFIG_PCH) += pch/
> > diff --git a/drivers/nvme/Makefile b/drivers/nvme/Makefile
> > index fa7b619446..fd3e68a91d 100644
> > --- a/drivers/nvme/Makefile
> > +++ b/drivers/nvme/Makefile
> > @@ -4,4 +4,4 @@
> >
> >  obj-y += nvme-uclass.o nvme.o nvme_show.o
> >  obj-$(CONFIG_NVME_APPLE) += nvme_apple.o
> > -obj-$(CONFIG_NVME_PCI) += nvme_pci.o
> > +obj-$(CONFIG_$(SPL_)NVME_PCI) += nvme_pci.o
> > diff --git a/drivers/nvme/nvme_pci.c b/drivers/nvme/nvme_pci.c
> > index 36bf9c5ffb..16d8b9fff7 100644
> > --- a/drivers/nvme/nvme_pci.c
> > +++ b/drivers/nvme/nvme_pci.c
> > @@ -39,6 +39,7 @@ U_BOOT_DRIVER(nvme) = {
> >         .bind   = nvme_bind,
> >         .probe  = nvme_probe,
> >         .priv_auto      = sizeof(struct nvme_dev),
> > +       .flags  = DM_FLAG_PRE_RELOC,
>
> Why is this here? It is only applicable on some boards.
>
> Instead, add the appropriate tag (e.g. u-boot,dm-spl) to the device node.
>

I am not sure how that can be done for PCI devices as those would be probed
at run time. Could you please point to any examples? Also,
the pci_find_and_bind_driver function only checks for this flag in the
drivers when binding the devices

>
> >  };
> >
> >  struct pci_device_id nvme_supported[] = {
> > diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
> > index 22f4995453..2d4c9f0781 100644
> > --- a/drivers/pci/Kconfig
> > +++ b/drivers/pci/Kconfig
> > @@ -40,6 +40,13 @@ config PCI_PNP
> >         help
> >           Enable PCI memory and I/O space resource allocation and
> assignment.
> >
> > +config SPL_PCI_PNP
> > +       bool "Enable Plug & Play support for PCI"
> > +       default n
> > +       help
> > +         Enable PCI memory and I/O space resource allocation and
> assignment.
> > +         This is required to auto configure the enumerated devices.
> > +
> >  config PCI_REGION_MULTI_ENTRY
> >         bool "Enable Multiple entries of region type MEMORY in ranges
> for PCI"
> >         help
> > diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
> > index 16a6a699f9..62d2409a6d 100644
> > --- a/drivers/pci/pci-uclass.c
> > +++ b/drivers/pci/pci-uclass.c
> > @@ -1140,7 +1140,8 @@ static int pci_uclass_post_probe(struct udevice
> *bus)
> >         if (ret)
> >                 return log_msg_ret("bind", ret);
> >
> > -       if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() &&
> > +       if ((CONFIG_IS_ENABLED(PCI_PNP) ||
> CONFIG_IS_ENABLED(SPL_PCI_PNP)) &&
> > +           ll_boot_init() &&
> >             (!hose->skip_auto_config_until_reloc ||
> >              (gd->flags & GD_FLG_RELOC))) {
> >                 ret = pci_auto_config_devices(bus);
> > --
> > 2.25.1
> >
>
> Regards,
> Simon
>
Simon Glass Sept. 30, 2022, 11:49 p.m. UTC | #3
Hi Mayuresh,

On Fri, 30 Sept 2022 at 10:58, Mayuresh Chitale
<mchitale@ventanamicro.com> wrote:
>
> Hi Simon,
>
> On Fri, Sep 30, 2022 at 5:26 AM Simon Glass <sjg@chromium.org> wrote:
>>
>> Hi Mayuresh,
>>
>> On Thu, 29 Sept 2022 at 03:57, Mayuresh Chitale
>> <mchitale@ventanamicro.com> wrote:
>> >
>> > Build PCI NVMe driver when enabled for SPI and enable dm-pre-reloc for
>> > the driver. Also enable PCI_PNP for SPL which is required to auto
>> > configure the PCIe devices.
>> >
>> > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
>> > ---
>> >  drivers/Makefile         | 2 +-
>> >  drivers/nvme/Makefile    | 2 +-
>> >  drivers/nvme/nvme_pci.c  | 1 +
>> >  drivers/pci/Kconfig      | 7 +++++++
>> >  drivers/pci/pci-uclass.c | 3 ++-
>> >  5 files changed, 12 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/drivers/Makefile b/drivers/Makefile
>> > index eba9940231..581ae9f819 100644
>> > --- a/drivers/Makefile
>> > +++ b/drivers/Makefile
>> > @@ -34,6 +34,7 @@ obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
>> >  obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
>> >  obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
>> >  obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
>> > +obj-$(CONFIG_$(SPL_)NVME) += nvme/
>> >  obj-$(CONFIG_XEN) += xen/
>> >  obj-$(CONFIG_$(SPL_)FPGA) += fpga/
>> >
>> > @@ -86,7 +87,6 @@ obj-y += crypto/
>> >  obj-$(CONFIG_FASTBOOT) += fastboot/
>> >  obj-y += misc/
>> >  obj-$(CONFIG_MMC) += mmc/
>> > -obj-$(CONFIG_NVME) += nvme/
>> >  obj-$(CONFIG_PCI_ENDPOINT) += pci_endpoint/
>> >  obj-y += dfu/
>> >  obj-$(CONFIG_PCH) += pch/
>> > diff --git a/drivers/nvme/Makefile b/drivers/nvme/Makefile
>> > index fa7b619446..fd3e68a91d 100644
>> > --- a/drivers/nvme/Makefile
>> > +++ b/drivers/nvme/Makefile
>> > @@ -4,4 +4,4 @@
>> >
>> >  obj-y += nvme-uclass.o nvme.o nvme_show.o
>> >  obj-$(CONFIG_NVME_APPLE) += nvme_apple.o
>> > -obj-$(CONFIG_NVME_PCI) += nvme_pci.o
>> > +obj-$(CONFIG_$(SPL_)NVME_PCI) += nvme_pci.o
>> > diff --git a/drivers/nvme/nvme_pci.c b/drivers/nvme/nvme_pci.c
>> > index 36bf9c5ffb..16d8b9fff7 100644
>> > --- a/drivers/nvme/nvme_pci.c
>> > +++ b/drivers/nvme/nvme_pci.c
>> > @@ -39,6 +39,7 @@ U_BOOT_DRIVER(nvme) = {
>> >         .bind   = nvme_bind,
>> >         .probe  = nvme_probe,
>> >         .priv_auto      = sizeof(struct nvme_dev),
>> > +       .flags  = DM_FLAG_PRE_RELOC,
>>
>> Why is this here? It is only applicable on some boards.
>>
>> Instead, add the appropriate tag (e.g. u-boot,dm-spl) to the device node.
>
>
> I am not sure how that can be done for PCI devices as those would be probed at run time. Could you please point to any examples? Also, the pci_find_and_bind_driver function only checks for this flag in the drivers when binding the devices

See host-bridge@0,0 in chromebook_coral.dts for an example of using
the u-boot,dm-pre-reloc flag. Note that pci_find_and_bind_driver() is
only called if the device tree lacks anything.

Which board is this for?

Regards,
Simon
diff mbox series

Patch

diff --git a/drivers/Makefile b/drivers/Makefile
index eba9940231..581ae9f819 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -34,6 +34,7 @@  obj-$(CONFIG_$(SPL_)DM_MAILBOX) += mailbox/
 obj-$(CONFIG_$(SPL_)REMOTEPROC) += remoteproc/
 obj-$(CONFIG_$(SPL_)SYSINFO) += sysinfo/
 obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
+obj-$(CONFIG_$(SPL_)NVME) += nvme/
 obj-$(CONFIG_XEN) += xen/
 obj-$(CONFIG_$(SPL_)FPGA) += fpga/
 
@@ -86,7 +87,6 @@  obj-y += crypto/
 obj-$(CONFIG_FASTBOOT) += fastboot/
 obj-y += misc/
 obj-$(CONFIG_MMC) += mmc/
-obj-$(CONFIG_NVME) += nvme/
 obj-$(CONFIG_PCI_ENDPOINT) += pci_endpoint/
 obj-y += dfu/
 obj-$(CONFIG_PCH) += pch/
diff --git a/drivers/nvme/Makefile b/drivers/nvme/Makefile
index fa7b619446..fd3e68a91d 100644
--- a/drivers/nvme/Makefile
+++ b/drivers/nvme/Makefile
@@ -4,4 +4,4 @@ 
 
 obj-y += nvme-uclass.o nvme.o nvme_show.o
 obj-$(CONFIG_NVME_APPLE) += nvme_apple.o
-obj-$(CONFIG_NVME_PCI) += nvme_pci.o
+obj-$(CONFIG_$(SPL_)NVME_PCI) += nvme_pci.o
diff --git a/drivers/nvme/nvme_pci.c b/drivers/nvme/nvme_pci.c
index 36bf9c5ffb..16d8b9fff7 100644
--- a/drivers/nvme/nvme_pci.c
+++ b/drivers/nvme/nvme_pci.c
@@ -39,6 +39,7 @@  U_BOOT_DRIVER(nvme) = {
 	.bind	= nvme_bind,
 	.probe	= nvme_probe,
 	.priv_auto	= sizeof(struct nvme_dev),
+	.flags	= DM_FLAG_PRE_RELOC,
 };
 
 struct pci_device_id nvme_supported[] = {
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 22f4995453..2d4c9f0781 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -40,6 +40,13 @@  config PCI_PNP
 	help
 	  Enable PCI memory and I/O space resource allocation and assignment.
 
+config SPL_PCI_PNP
+	bool "Enable Plug & Play support for PCI"
+	default n
+	help
+	  Enable PCI memory and I/O space resource allocation and assignment.
+	  This is required to auto configure the enumerated devices.
+
 config PCI_REGION_MULTI_ENTRY
 	bool "Enable Multiple entries of region type MEMORY in ranges for PCI"
 	help
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 16a6a699f9..62d2409a6d 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1140,7 +1140,8 @@  static int pci_uclass_post_probe(struct udevice *bus)
 	if (ret)
 		return log_msg_ret("bind", ret);
 
-	if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() &&
+	if ((CONFIG_IS_ENABLED(PCI_PNP) || CONFIG_IS_ENABLED(SPL_PCI_PNP)) &&
+	    ll_boot_init() &&
 	    (!hose->skip_auto_config_until_reloc ||
 	     (gd->flags & GD_FLG_RELOC))) {
 		ret = pci_auto_config_devices(bus);