public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/4] SPL NVme support
@ 2023-05-02 16:18 Mayuresh Chitale
  2023-05-02 16:18 ` [PATCH v2 1/4] spl: Add Kconfig options for NVME Mayuresh Chitale
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-02 16:18 UTC (permalink / raw)
  To: Bin Meng, Simon Glass
  Cc: Mayuresh Chitale, u-boot, Heinrich Schuchardt, Rick Chen, Leo

This patchset adds support to load images of the SPL's next booting stage from a NVMe device.

Changes in v2:
- Rebase on v2023.07-rc1
- Use uclass ID for blk APIs
- Add support to load FIT images from ext filesystem

Mayuresh Chitale (4):
  spl: Add Kconfig options for NVME
  nvme: pci: Enable for SPL
  spl: Support loading a FIT from ext FS
  common: spl: Add spl NVMe boot support

 arch/riscv/include/asm/spl.h |  1 +
 common/spl/Kconfig           | 30 +++++++++++++++++++++
 common/spl/Makefile          |  1 +
 common/spl/spl_ext.c         | 33 +++++++++++++++++++++++
 common/spl/spl_nvme.c        | 52 ++++++++++++++++++++++++++++++++++++
 drivers/Makefile             |  1 +
 drivers/nvme/Makefile        |  2 +-
 drivers/pci/Kconfig          |  7 +++++
 drivers/pci/pci-uclass.c     |  3 ++-
 9 files changed, 128 insertions(+), 2 deletions(-)
 create mode 100644 common/spl/spl_nvme.c

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/4] spl: Add Kconfig options for NVME
  2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
@ 2023-05-02 16:18 ` Mayuresh Chitale
  2023-05-02 16:19 ` [PATCH v2 2/4] nvme: pci: Enable for SPL Mayuresh Chitale
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-02 16:18 UTC (permalink / raw)
  To: Bin Meng, Simon Glass
  Cc: Mayuresh Chitale, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Add kconfig options to enable NVME and PCI NVMe support in SPL

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 common/spl/Kconfig | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 2c042ad306..a42774c76d 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1263,6 +1263,26 @@ config SPL_SATA_RAW_U_BOOT_SECTOR
 	  Sector on the SATA disk to load U-Boot from, when the SATA disk is being
 	  used in raw mode. Units: SATA disk sectors (1 sector = 512 bytes).
 
+config SPL_NVME
+	bool "NVM Express device support"
+	depends on BLK
+	select HAVE_BLOCK_DEVICE
+	help
+	  This option enables support for NVM Express devices.
+	  It supports basic functions of NVMe (read/write).
+
+config SPL_NVME_PCI
+	bool "NVM Express PCI device support for SPL"
+	depends on SPL_PCI && SPL_NVME
+	help
+	  This option enables support for NVM Express PCI devices.
+	  This allows use of NVMe devices for loading u-boot.
+
+config SPL_NVME_BOOT_DEVICE
+	hex "NVMe boot device number"
+	depends on SPL_NVME
+	default 0x0
+
 config SPL_SERIAL
 	bool "Support serial"
 	select SPL_PRINTF
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/4] nvme: pci: Enable for SPL
  2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
  2023-05-02 16:18 ` [PATCH v2 1/4] spl: Add Kconfig options for NVME Mayuresh Chitale
@ 2023-05-02 16:19 ` Mayuresh Chitale
  2023-05-03  1:28   ` Simon Glass
  2023-05-02 16:19 ` [PATCH v2 3/4] spl: Support loading a FIT from ext FS Mayuresh Chitale
  2023-05-02 16:19 ` [PATCH v2 4/4] common: spl: Add spl NVMe boot support Mayuresh Chitale
  3 siblings, 1 reply; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-02 16:19 UTC (permalink / raw)
  To: Bin Meng, Simon Glass
  Cc: Mayuresh Chitale, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Enable NVME and PCI NVMe drivers for SPL builds. 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         | 1 +
 drivers/nvme/Makefile    | 2 +-
 drivers/pci/Kconfig      | 7 +++++++
 drivers/pci/pci-uclass.c | 3 ++-
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/Makefile b/drivers/Makefile
index 58be410135..dc559ea7f7 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/
 obj-y += bus/
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/pci/Kconfig b/drivers/pci/Kconfig
index ef328d2652..ecab6ddc7e 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 9343cfc62a..dff63a68ce 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.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/4] spl: Support loading a FIT from ext FS
  2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
  2023-05-02 16:18 ` [PATCH v2 1/4] spl: Add Kconfig options for NVME Mayuresh Chitale
  2023-05-02 16:19 ` [PATCH v2 2/4] nvme: pci: Enable for SPL Mayuresh Chitale
@ 2023-05-02 16:19 ` Mayuresh Chitale
  2023-05-02 16:19 ` [PATCH v2 4/4] common: spl: Add spl NVMe boot support Mayuresh Chitale
  3 siblings, 0 replies; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-02 16:19 UTC (permalink / raw)
  To: Bin Meng, Simon Glass
  Cc: Mayuresh Chitale, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Detect a FIT when loading from an ext File system and handle it using
the FIT SPL support.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 common/spl/spl_ext.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c
index 2bf3434439..8593aed069 100644
--- a/common/spl/spl_ext.c
+++ b/common/spl/spl_ext.c
@@ -8,6 +8,26 @@
 #include <ext4fs.h>
 #include <errno.h>
 #include <image.h>
+#include <linux/libfdt.h>
+
+static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset,
+			  ulong size, void *buf)
+{
+	loff_t filelen = (loff_t)load->priv, actlen;
+	char *filename = (char *)load->filename;
+	int ret;
+
+	ret = ext4fs_read(buf, file_offset, filelen, &actlen);
+	if (ret < 0) {
+		if (IS_ENABLED(CONFIG_SPL_LIBCOMMON_SUPPORT)) {
+			printf("%s: error reading image %s, err - %d\n",
+			       __func__, filename, ret);
+		}
+		return ret;
+	}
+
+	return actlen;
+}
 
 int spl_load_image_ext(struct spl_image_info *spl_image,
 		       struct spl_boot_device *bootdev,
@@ -47,6 +67,19 @@ int spl_load_image_ext(struct spl_image_info *spl_image,
 		goto end;
 	}
 
+	if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
+	    image_get_magic(header) == FDT_MAGIC) {
+		struct spl_load_info load;
+
+		debug("Found FIT\n");
+		load.read = spl_fit_read;
+		load.bl_len = 1;
+		load.filename = (void *)filename;
+		load.priv = (void *)filelen;
+
+		return spl_load_simple_fit(spl_image, &load, 0, header);
+	}
+
 	err = spl_parse_image_header(spl_image, bootdev, header);
 	if (err < 0) {
 		puts("spl: ext: failed to parse image header\n");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 4/4] common: spl: Add spl NVMe boot support
  2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
                   ` (2 preceding siblings ...)
  2023-05-02 16:19 ` [PATCH v2 3/4] spl: Support loading a FIT from ext FS Mayuresh Chitale
@ 2023-05-02 16:19 ` Mayuresh Chitale
  2023-05-03  1:28   ` Simon Glass
  3 siblings, 1 reply; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-02 16:19 UTC (permalink / raw)
  To: Bin Meng, Simon Glass
  Cc: Mayuresh Chitale, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Add support to load the next stage image from an NVMe disk which may
be formatted as an EXT or FAT filesystem.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 arch/riscv/include/asm/spl.h |  1 +
 common/spl/Kconfig           | 10 +++++++
 common/spl/Makefile          |  1 +
 common/spl/spl_nvme.c        | 52 ++++++++++++++++++++++++++++++++++++
 4 files changed, 64 insertions(+)
 create mode 100644 common/spl/spl_nvme.c

diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h
index 2898a770ee..9c0bf9755c 100644
--- a/arch/riscv/include/asm/spl.h
+++ b/arch/riscv/include/asm/spl.h
@@ -20,6 +20,7 @@ enum {
 	BOOT_DEVICE_SPI,
 	BOOT_DEVICE_USB,
 	BOOT_DEVICE_SATA,
+	BOOT_DEVICE_NVME,
 	BOOT_DEVICE_I2C,
 	BOOT_DEVICE_BOARD,
 	BOOT_DEVICE_DFU,
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index a42774c76d..021c4997a7 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -1283,6 +1283,16 @@ config SPL_NVME_BOOT_DEVICE
 	depends on SPL_NVME
 	default 0x0
 
+config SYS_NVME_EXT_BOOT_PARTITION
+	hex "NVMe ext boot partition number"
+	depends on SPL_NVME
+	default	0x2
+
+config SYS_NVME_FAT_BOOT_PARTITION
+	hex "NVMe boot partition number"
+	depends on SPL_NVME
+	default	0x1
+
 config SPL_SERIAL
 	bool "Support serial"
 	select SPL_PRINTF
diff --git a/common/spl/Makefile b/common/spl/Makefile
index 13db3df993..4bcc3d7e68 100644
--- a/common/spl/Makefile
+++ b/common/spl/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_$(SPL_TPL_)USB_STORAGE) += spl_usb.o
 obj-$(CONFIG_$(SPL_TPL_)FS_FAT) += spl_fat.o
 obj-$(CONFIG_$(SPL_TPL_)FS_EXT4) += spl_ext.o
 obj-$(CONFIG_$(SPL_TPL_)SATA) += spl_sata.o
+obj-$(CONFIG_$(SPL_TPL_)NVME) += spl_nvme.o
 obj-$(CONFIG_$(SPL_TPL_)SEMIHOSTING) += spl_semihosting.o
 obj-$(CONFIG_$(SPL_TPL_)DFU) += spl_dfu.o
 obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
diff --git a/common/spl/spl_nvme.c b/common/spl/spl_nvme.c
new file mode 100644
index 0000000000..c99e0aefc7
--- /dev/null
+++ b/common/spl/spl_nvme.c
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023
+ * Ventana Micro Systems Inc.
+ *
+ * Derived work from spl_sata.c
+ */
+
+#include <common.h>
+#include <spl.h>
+#include <errno.h>
+#include <fat.h>
+#include <init.h>
+#include <nvme.h>
+
+static int spl_nvme_load_image(struct spl_image_info *spl_image,
+			       struct spl_boot_device *bootdev)
+{
+	int ret;
+	struct blk_desc *blk_desc;
+
+	ret = pci_init();
+	if (ret < 0)
+		goto out;
+
+	ret = nvme_scan_namespace();
+	if (ret < 0)
+		goto out;
+
+	blk_show_device(UCLASS_NVME, CONFIG_SPL_NVME_BOOT_DEVICE);
+	blk_desc = blk_get_devnum_by_uclass_id(UCLASS_NVME,
+					       CONFIG_SPL_NVME_BOOT_DEVICE);
+	if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
+		ret = spl_load_image_ext(spl_image, bootdev, blk_desc,
+					 CONFIG_SYS_NVME_EXT_BOOT_PARTITION,
+					 CONFIG_SPL_PAYLOAD);
+		if (!ret)
+			return ret;
+	}
+
+	if (IS_ENABLED(CONFIG_SPL_FS_FAT))
+		ret = spl_load_image_fat(spl_image, bootdev, blk_desc,
+					 CONFIG_SYS_NVME_FAT_BOOT_PARTITION,
+					 CONFIG_SPL_PAYLOAD);
+	else
+		ret = -ENOSYS;
+
+out:
+	return ret;
+}
+
+SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] nvme: pci: Enable for SPL
  2023-05-02 16:19 ` [PATCH v2 2/4] nvme: pci: Enable for SPL Mayuresh Chitale
@ 2023-05-03  1:28   ` Simon Glass
  2023-05-04  8:27     ` Mayuresh Chitale
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Glass @ 2023-05-03  1:28 UTC (permalink / raw)
  To: Mayuresh Chitale; +Cc: Bin Meng, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Hi Mayuresh,

On Tue, 2 May 2023 at 10:19, Mayuresh Chitale <mchitale@ventanamicro.com> wrote:
>
> Enable NVME and PCI NVMe drivers for SPL builds. 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         | 1 +
>  drivers/nvme/Makefile    | 2 +-
>  drivers/pci/Kconfig      | 7 +++++++
>  drivers/pci/pci-uclass.c | 3 ++-
>  4 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/Makefile b/drivers/Makefile
> index 58be410135..dc559ea7f7 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/
>  obj-y += bus/
> 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/pci/Kconfig b/drivers/pci/Kconfig
> index ef328d2652..ecab6ddc7e 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 9343cfc62a..dff63a68ce 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)) &&

The CONFIG_IS_ENABLED() macro checks SPL_PCI_PNP when used in an SPL
build, so you should not need this change.

> +           ll_boot_init() &&
>             (!hose->skip_auto_config_until_reloc ||
>              (gd->flags & GD_FLG_RELOC))) {
>                 ret = pci_auto_config_devices(bus);
> --
> 2.34.1
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/4] common: spl: Add spl NVMe boot support
  2023-05-02 16:19 ` [PATCH v2 4/4] common: spl: Add spl NVMe boot support Mayuresh Chitale
@ 2023-05-03  1:28   ` Simon Glass
  2023-05-04  8:28     ` Mayuresh Chitale
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Glass @ 2023-05-03  1:28 UTC (permalink / raw)
  To: Mayuresh Chitale; +Cc: Bin Meng, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Hi Mayuresh,

On Tue, 2 May 2023 at 10:19, Mayuresh Chitale <mchitale@ventanamicro.com> wrote:
>
> Add support to load the next stage image from an NVMe disk which may
> be formatted as an EXT or FAT filesystem.
>
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> ---
>  arch/riscv/include/asm/spl.h |  1 +
>  common/spl/Kconfig           | 10 +++++++
>  common/spl/Makefile          |  1 +
>  common/spl/spl_nvme.c        | 52 ++++++++++++++++++++++++++++++++++++
>  4 files changed, 64 insertions(+)
>  create mode 100644 common/spl/spl_nvme.c
>
> diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h
> index 2898a770ee..9c0bf9755c 100644
> --- a/arch/riscv/include/asm/spl.h
> +++ b/arch/riscv/include/asm/spl.h
> @@ -20,6 +20,7 @@ enum {
>         BOOT_DEVICE_SPI,
>         BOOT_DEVICE_USB,
>         BOOT_DEVICE_SATA,
> +       BOOT_DEVICE_NVME,
>         BOOT_DEVICE_I2C,
>         BOOT_DEVICE_BOARD,
>         BOOT_DEVICE_DFU,
> diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> index a42774c76d..021c4997a7 100644
> --- a/common/spl/Kconfig
> +++ b/common/spl/Kconfig
> @@ -1283,6 +1283,16 @@ config SPL_NVME_BOOT_DEVICE
>         depends on SPL_NVME
>         default 0x0
>
> +config SYS_NVME_EXT_BOOT_PARTITION
> +       hex "NVMe ext boot partition number"
> +       depends on SPL_NVME
> +       default 0x2
> +
> +config SYS_NVME_FAT_BOOT_PARTITION
> +       hex "NVMe boot partition number"
> +       depends on SPL_NVME
> +       default 0x1
> +
>  config SPL_SERIAL
>         bool "Support serial"
>         select SPL_PRINTF
> diff --git a/common/spl/Makefile b/common/spl/Makefile
> index 13db3df993..4bcc3d7e68 100644
> --- a/common/spl/Makefile
> +++ b/common/spl/Makefile
> @@ -28,6 +28,7 @@ obj-$(CONFIG_$(SPL_TPL_)USB_STORAGE) += spl_usb.o
>  obj-$(CONFIG_$(SPL_TPL_)FS_FAT) += spl_fat.o
>  obj-$(CONFIG_$(SPL_TPL_)FS_EXT4) += spl_ext.o
>  obj-$(CONFIG_$(SPL_TPL_)SATA) += spl_sata.o
> +obj-$(CONFIG_$(SPL_TPL_)NVME) += spl_nvme.o
>  obj-$(CONFIG_$(SPL_TPL_)SEMIHOSTING) += spl_semihosting.o
>  obj-$(CONFIG_$(SPL_TPL_)DFU) += spl_dfu.o
>  obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
> diff --git a/common/spl/spl_nvme.c b/common/spl/spl_nvme.c
> new file mode 100644
> index 0000000000..c99e0aefc7
> --- /dev/null
> +++ b/common/spl/spl_nvme.c
> @@ -0,0 +1,52 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2023
> + * Ventana Micro Systems Inc.
> + *
> + * Derived work from spl_sata.c
> + */
> +
> +#include <common.h>
> +#include <spl.h>
> +#include <errno.h>
> +#include <fat.h>
> +#include <init.h>
> +#include <nvme.h>
> +
> +static int spl_nvme_load_image(struct spl_image_info *spl_image,
> +                              struct spl_boot_device *bootdev)
> +{
> +       int ret;
> +       struct blk_desc *blk_desc;
> +
> +       ret = pci_init();
> +       if (ret < 0)
> +               goto out;
> +
> +       ret = nvme_scan_namespace();
> +       if (ret < 0)
> +               goto out;
> +
> +       blk_show_device(UCLASS_NVME, CONFIG_SPL_NVME_BOOT_DEVICE);
> +       blk_desc = blk_get_devnum_by_uclass_id(UCLASS_NVME,
> +                                              CONFIG_SPL_NVME_BOOT_DEVICE);
> +       if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
> +               ret = spl_load_image_ext(spl_image, bootdev, blk_desc,
> +                                        CONFIG_SYS_NVME_EXT_BOOT_PARTITION,
> +                                        CONFIG_SPL_PAYLOAD);
> +               if (!ret)
> +                       return ret;
> +       }
> +
> +       if (IS_ENABLED(CONFIG_SPL_FS_FAT))
> +               ret = spl_load_image_fat(spl_image, bootdev, blk_desc,
> +                                        CONFIG_SYS_NVME_FAT_BOOT_PARTITION,
> +                                        CONFIG_SPL_PAYLOAD);
> +       else
> +               ret = -ENOSYS;
> +
> +out:
> +       return ret;
> +}
> +
> +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image);
> --
> 2.34.1
>

All of this code looks generic except:

UCLASS_NVME
CONFIG_SPL_NVME_BOOT_DEVICE
CONFIG_SYS_NVME_EXT_BOOT_PARTITION

so please move the code inside your new function into a generic file
like spl_blk_fs.c or similar and pass these parameters to it. Then we
can use the same function for other device types.

Regards,
SImon

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/4] nvme: pci: Enable for SPL
  2023-05-03  1:28   ` Simon Glass
@ 2023-05-04  8:27     ` Mayuresh Chitale
  0 siblings, 0 replies; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-04  8:27 UTC (permalink / raw)
  To: Simon Glass; +Cc: Bin Meng, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Hi Simon,

On Wed, May 3, 2023 at 6:58 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Mayuresh,
>
> On Tue, 2 May 2023 at 10:19, Mayuresh Chitale <mchitale@ventanamicro.com> wrote:
> >
> > Enable NVME and PCI NVMe drivers for SPL builds. 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         | 1 +
> >  drivers/nvme/Makefile    | 2 +-
> >  drivers/pci/Kconfig      | 7 +++++++
> >  drivers/pci/pci-uclass.c | 3 ++-
> >  4 files changed, 11 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/Makefile b/drivers/Makefile
> > index 58be410135..dc559ea7f7 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/
> >  obj-y += bus/
> > 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/pci/Kconfig b/drivers/pci/Kconfig
> > index ef328d2652..ecab6ddc7e 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 9343cfc62a..dff63a68ce 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)) &&
>
> The CONFIG_IS_ENABLED() macro checks SPL_PCI_PNP when used in an SPL
> build, so you should not need this change.
Ok. Will remove it in the next version.
>
> > +           ll_boot_init() &&
> >             (!hose->skip_auto_config_until_reloc ||
> >              (gd->flags & GD_FLG_RELOC))) {
> >                 ret = pci_auto_config_devices(bus);
> > --
> > 2.34.1
> >
>
> Regards,
> Simon

Thanks,
Mayuresh.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 4/4] common: spl: Add spl NVMe boot support
  2023-05-03  1:28   ` Simon Glass
@ 2023-05-04  8:28     ` Mayuresh Chitale
  0 siblings, 0 replies; 9+ messages in thread
From: Mayuresh Chitale @ 2023-05-04  8:28 UTC (permalink / raw)
  To: Simon Glass; +Cc: Bin Meng, u-boot, Heinrich Schuchardt, Rick Chen, Leo

Hi Simon,

On Wed, May 3, 2023 at 6:58 AM Simon Glass <sjg@chromium.org> wrote:
>
> Hi Mayuresh,
>
> On Tue, 2 May 2023 at 10:19, Mayuresh Chitale <mchitale@ventanamicro.com> wrote:
> >
> > Add support to load the next stage image from an NVMe disk which may
> > be formatted as an EXT or FAT filesystem.
> >
> > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > ---
> >  arch/riscv/include/asm/spl.h |  1 +
> >  common/spl/Kconfig           | 10 +++++++
> >  common/spl/Makefile          |  1 +
> >  common/spl/spl_nvme.c        | 52 ++++++++++++++++++++++++++++++++++++
> >  4 files changed, 64 insertions(+)
> >  create mode 100644 common/spl/spl_nvme.c
> >
> > diff --git a/arch/riscv/include/asm/spl.h b/arch/riscv/include/asm/spl.h
> > index 2898a770ee..9c0bf9755c 100644
> > --- a/arch/riscv/include/asm/spl.h
> > +++ b/arch/riscv/include/asm/spl.h
> > @@ -20,6 +20,7 @@ enum {
> >         BOOT_DEVICE_SPI,
> >         BOOT_DEVICE_USB,
> >         BOOT_DEVICE_SATA,
> > +       BOOT_DEVICE_NVME,
> >         BOOT_DEVICE_I2C,
> >         BOOT_DEVICE_BOARD,
> >         BOOT_DEVICE_DFU,
> > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > index a42774c76d..021c4997a7 100644
> > --- a/common/spl/Kconfig
> > +++ b/common/spl/Kconfig
> > @@ -1283,6 +1283,16 @@ config SPL_NVME_BOOT_DEVICE
> >         depends on SPL_NVME
> >         default 0x0
> >
> > +config SYS_NVME_EXT_BOOT_PARTITION
> > +       hex "NVMe ext boot partition number"
> > +       depends on SPL_NVME
> > +       default 0x2
> > +
> > +config SYS_NVME_FAT_BOOT_PARTITION
> > +       hex "NVMe boot partition number"
> > +       depends on SPL_NVME
> > +       default 0x1
> > +
> >  config SPL_SERIAL
> >         bool "Support serial"
> >         select SPL_PRINTF
> > diff --git a/common/spl/Makefile b/common/spl/Makefile
> > index 13db3df993..4bcc3d7e68 100644
> > --- a/common/spl/Makefile
> > +++ b/common/spl/Makefile
> > @@ -28,6 +28,7 @@ obj-$(CONFIG_$(SPL_TPL_)USB_STORAGE) += spl_usb.o
> >  obj-$(CONFIG_$(SPL_TPL_)FS_FAT) += spl_fat.o
> >  obj-$(CONFIG_$(SPL_TPL_)FS_EXT4) += spl_ext.o
> >  obj-$(CONFIG_$(SPL_TPL_)SATA) += spl_sata.o
> > +obj-$(CONFIG_$(SPL_TPL_)NVME) += spl_nvme.o
> >  obj-$(CONFIG_$(SPL_TPL_)SEMIHOSTING) += spl_semihosting.o
> >  obj-$(CONFIG_$(SPL_TPL_)DFU) += spl_dfu.o
> >  obj-$(CONFIG_$(SPL_TPL_)SPI_LOAD) += spl_spi.o
> > diff --git a/common/spl/spl_nvme.c b/common/spl/spl_nvme.c
> > new file mode 100644
> > index 0000000000..c99e0aefc7
> > --- /dev/null
> > +++ b/common/spl/spl_nvme.c
> > @@ -0,0 +1,52 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright (C) 2023
> > + * Ventana Micro Systems Inc.
> > + *
> > + * Derived work from spl_sata.c
> > + */
> > +
> > +#include <common.h>
> > +#include <spl.h>
> > +#include <errno.h>
> > +#include <fat.h>
> > +#include <init.h>
> > +#include <nvme.h>
> > +
> > +static int spl_nvme_load_image(struct spl_image_info *spl_image,
> > +                              struct spl_boot_device *bootdev)
> > +{
> > +       int ret;
> > +       struct blk_desc *blk_desc;
> > +
> > +       ret = pci_init();
> > +       if (ret < 0)
> > +               goto out;
> > +
> > +       ret = nvme_scan_namespace();
> > +       if (ret < 0)
> > +               goto out;
> > +
> > +       blk_show_device(UCLASS_NVME, CONFIG_SPL_NVME_BOOT_DEVICE);
> > +       blk_desc = blk_get_devnum_by_uclass_id(UCLASS_NVME,
> > +                                              CONFIG_SPL_NVME_BOOT_DEVICE);
> > +       if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
> > +               ret = spl_load_image_ext(spl_image, bootdev, blk_desc,
> > +                                        CONFIG_SYS_NVME_EXT_BOOT_PARTITION,
> > +                                        CONFIG_SPL_PAYLOAD);
> > +               if (!ret)
> > +                       return ret;
> > +       }
> > +
> > +       if (IS_ENABLED(CONFIG_SPL_FS_FAT))
> > +               ret = spl_load_image_fat(spl_image, bootdev, blk_desc,
> > +                                        CONFIG_SYS_NVME_FAT_BOOT_PARTITION,
> > +                                        CONFIG_SPL_PAYLOAD);
> > +       else
> > +               ret = -ENOSYS;
> > +
> > +out:
> > +       return ret;
> > +}
> > +
> > +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image);
> > --
> > 2.34.1
> >
>
> All of this code looks generic except:
>
> UCLASS_NVME
> CONFIG_SPL_NVME_BOOT_DEVICE
> CONFIG_SYS_NVME_EXT_BOOT_PARTITION
> so please move the code inside your new function into a generic file
> like spl_blk_fs.c or similar and pass these parameters to it. Then we
> can use the same function for other device types.
>

Ok. WIll do it in the next version.

> Regards,
> SImon


Thanks,
Mayuresh.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-05-04  8:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-02 16:18 [PATCH v2 0/4] SPL NVme support Mayuresh Chitale
2023-05-02 16:18 ` [PATCH v2 1/4] spl: Add Kconfig options for NVME Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 2/4] nvme: pci: Enable for SPL Mayuresh Chitale
2023-05-03  1:28   ` Simon Glass
2023-05-04  8:27     ` Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 3/4] spl: Support loading a FIT from ext FS Mayuresh Chitale
2023-05-02 16:19 ` [PATCH v2 4/4] common: spl: Add spl NVMe boot support Mayuresh Chitale
2023-05-03  1:28   ` Simon Glass
2023-05-04  8:28     ` Mayuresh Chitale

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox