[PATCH v3 0/5] SPL NVMe support

This patchset adds support to load images of the SPL's next booting stage from a NVMe device.
Changes in v3: - Add generic API to fetch payload from Ext or FAT filesystems - Remove reduntant SPL_PCI_PNP config check
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 (5): spl: Add Kconfig options for NVME spl: blk: Support loading images from fs 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 | 31 +++++++++++++++++++++ common/spl/Makefile | 2 ++ common/spl/spl_blk_fs.c | 54 ++++++++++++++++++++++++++++++++++++ common/spl/spl_ext.c | 33 ++++++++++++++++++++++ common/spl/spl_nvme.c | 34 +++++++++++++++++++++++ drivers/Makefile | 1 + drivers/block/Kconfig | 7 +++++ drivers/nvme/Makefile | 2 +- drivers/pci/Kconfig | 7 +++++ include/spl.h | 3 ++ 11 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 common/spl/spl_blk_fs.c create mode 100644 common/spl/spl_nvme.c

Add kconfig options to enable NVME and PCI NVMe support in SPL
Signed-off-by: Mayuresh Chitale mchitale@ventanamicro.com --- common/spl/Kconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 2c042ad306..515e8f2c66 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1263,6 +1263,27 @@ 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 + select SPL_BLK_FS + 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

On Thu, 4 May 2023 at 03:53, Mayuresh Chitale mchitale@ventanamicro.com wrote:
Add kconfig options to enable NVME and PCI NVMe support in SPL
Signed-off-by: Mayuresh Chitale mchitale@ventanamicro.com
common/spl/Kconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 2c042ad306..515e8f2c66 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1263,6 +1263,27 @@ 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).
Reviewed-by: Simon Glass sjg@chromium.org
+config SPL_NVME
bool "NVM Express device support"
depends on BLK
select HAVE_BLOCK_DEVICE
select SPL_BLK_FS
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

Add a generic API to support loading of SPL payload from EXT or FAT filesystem on a given partition of a block device.
Signed-off-by: Mayuresh Chitale mchitale@ventanamicro.com --- common/spl/Makefile | 1 + common/spl/spl_blk_fs.c | 54 +++++++++++++++++++++++++++++++++++++++++ drivers/block/Kconfig | 7 ++++++ include/spl.h | 3 +++ 4 files changed, 65 insertions(+) create mode 100644 common/spl/spl_blk_fs.c
diff --git a/common/spl/Makefile b/common/spl/Makefile index 13db3df993..5210ad0248 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -10,6 +10,7 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o obj-$(CONFIG_$(SPL_TPL_)BOOTROM_SUPPORT) += spl_bootrom.o obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += spl_fit.o +obj-$(CONFIG_$(SPL_TPL_)BLK_FS) += spl_blk_fs.o obj-$(CONFIG_$(SPL_TPL_)LEGACY_IMAGE_FORMAT) += spl_legacy.o obj-$(CONFIG_$(SPL_TPL_)NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_$(SPL_TPL_)XIP_SUPPORT) += spl_xip.o diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c new file mode 100644 index 0000000000..fb2e8bbea7 --- /dev/null +++ b/common/spl/spl_blk_fs.c @@ -0,0 +1,54 @@ +// 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> + +int spl_blk_load_image(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev, + enum uclass_id uclass_id, int devnum) +{ + int ret = -ENOSYS, part; + struct blk_desc *blk_desc; + + blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum); + if (!blk_desc) + return ret; + + blk_show_device(uclass_id, devnum); + + if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) { + switch (uclass_id) { + case UCLASS_NVME: + part = CONFIG_SYS_NVME_EXT_BOOT_PARTITION; + break; + default: + return ret; + } + ret = spl_load_image_ext(spl_image, bootdev, blk_desc, part, + CONFIG_SPL_PAYLOAD); + if (!ret) + return ret; + } + + if (IS_ENABLED(CONFIG_SPL_FS_FAT)) { + switch (uclass_id) { + case UCLASS_NVME: + part = CONFIG_SYS_NVME_FAT_BOOT_PARTITION; + break; + default: + return ret; + } + ret = spl_load_image_fat(spl_image, bootdev, blk_desc, part, + CONFIG_SPL_PAYLOAD); + if (!ret) + return ret; + } + + return ret; +} diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 5a1aeb3d2b..6baaa6f071 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -107,6 +107,13 @@ config EFI_MEDIA
For sandbox there is a test driver.
+config SPL_BLK_FS + bool "Load images from filesystems on block devices" + depends on SPL_BLK + help + Use generic support to load images from fat/ext filesystems on + different types of block devices such as NVMe. + if EFI_MEDIA
config EFI_MEDIA_SANDBOX diff --git a/include/spl.h b/include/spl.h index 7e0f5ac63b..4546648394 100644 --- a/include/spl.h +++ b/include/spl.h @@ -672,6 +672,9 @@ int spl_load_image_ext(struct spl_image_info *spl_image, int spl_load_image_ext_os(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct blk_desc *block_dev, int partition); +int spl_blk_load_image(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev, + enum uclass_id uclass_id, int devnum);
/** * spl_early_init() - Set up device tree and driver model in SPL if enabled

Hi Mayuresh,
On Thu, 4 May 2023 at 03:53, Mayuresh Chitale mchitale@ventanamicro.com wrote:
Add a generic API to support loading of SPL payload from EXT or FAT filesystem on a given partition of a block device.
Signed-off-by: Mayuresh Chitale mchitale@ventanamicro.com
common/spl/Makefile | 1 + common/spl/spl_blk_fs.c | 54 +++++++++++++++++++++++++++++++++++++++++ drivers/block/Kconfig | 7 ++++++ include/spl.h | 3 +++ 4 files changed, 65 insertions(+) create mode 100644 common/spl/spl_blk_fs.c
diff --git a/common/spl/Makefile b/common/spl/Makefile index 13db3df993..5210ad0248 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -10,6 +10,7 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o obj-$(CONFIG_$(SPL_TPL_)BOOTROM_SUPPORT) += spl_bootrom.o obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += spl_fit.o +obj-$(CONFIG_$(SPL_TPL_)BLK_FS) += spl_blk_fs.o obj-$(CONFIG_$(SPL_TPL_)LEGACY_IMAGE_FORMAT) += spl_legacy.o obj-$(CONFIG_$(SPL_TPL_)NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_$(SPL_TPL_)XIP_SUPPORT) += spl_xip.o diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c new file mode 100644 index 0000000000..fb2e8bbea7 --- /dev/null +++ b/common/spl/spl_blk_fs.c @@ -0,0 +1,54 @@ +// 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>
+int spl_blk_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
enum uclass_id uclass_id, int devnum)
+{
int ret = -ENOSYS, part;
struct blk_desc *blk_desc;
blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
if (!blk_desc)
return ret;
blk_show_device(uclass_id, devnum);
if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
Can you use the fs.h layer so it can work with any FS?
switch (uclass_id) {
case UCLASS_NVME:
part = CONFIG_SYS_NVME_EXT_BOOT_PARTITION;
break;
default:
return ret;
}
ret = spl_load_image_ext(spl_image, bootdev, blk_desc, part,
CONFIG_SPL_PAYLOAD);
if (!ret)
return ret;
}
if (IS_ENABLED(CONFIG_SPL_FS_FAT)) {
switch (uclass_id) {
case UCLASS_NVME:
part = CONFIG_SYS_NVME_FAT_BOOT_PARTITION;
break;
default:
return ret;
}
ret = spl_load_image_fat(spl_image, bootdev, blk_desc, part,
CONFIG_SPL_PAYLOAD);
if (!ret)
return ret;
}
return ret;
+} diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 5a1aeb3d2b..6baaa6f071 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -107,6 +107,13 @@ config EFI_MEDIA
For sandbox there is a test driver.
+config SPL_BLK_FS
bool "Load images from filesystems on block devices"
depends on SPL_BLK
help
Use generic support to load images from fat/ext filesystems on
different types of block devices such as NVMe.
if EFI_MEDIA
config EFI_MEDIA_SANDBOX diff --git a/include/spl.h b/include/spl.h index 7e0f5ac63b..4546648394 100644 --- a/include/spl.h +++ b/include/spl.h @@ -672,6 +672,9 @@ int spl_load_image_ext(struct spl_image_info *spl_image, int spl_load_image_ext_os(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct blk_desc *block_dev, int partition); +int spl_blk_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
enum uclass_id uclass_id, int devnum);
/**
- spl_early_init() - Set up device tree and driver model in SPL if enabled
-- 2.34.1
Regards, Simon

Hi Simon,
On Fri, May 5, 2023 at 6:11 AM Simon Glass sjg@chromium.org wrote:
Hi Mayuresh,
On Thu, 4 May 2023 at 03:53, Mayuresh Chitale mchitale@ventanamicro.com wrote:
Add a generic API to support loading of SPL payload from EXT or FAT filesystem on a given partition of a block device.
Signed-off-by: Mayuresh Chitale mchitale@ventanamicro.com
common/spl/Makefile | 1 + common/spl/spl_blk_fs.c | 54 +++++++++++++++++++++++++++++++++++++++++ drivers/block/Kconfig | 7 ++++++ include/spl.h | 3 +++ 4 files changed, 65 insertions(+) create mode 100644 common/spl/spl_blk_fs.c
diff --git a/common/spl/Makefile b/common/spl/Makefile index 13db3df993..5210ad0248 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -10,6 +10,7 @@ ifdef CONFIG_SPL_BUILD obj-$(CONFIG_$(SPL_TPL_)FRAMEWORK) += spl.o obj-$(CONFIG_$(SPL_TPL_)BOOTROM_SUPPORT) += spl_bootrom.o obj-$(CONFIG_$(SPL_TPL_)LOAD_FIT) += spl_fit.o +obj-$(CONFIG_$(SPL_TPL_)BLK_FS) += spl_blk_fs.o obj-$(CONFIG_$(SPL_TPL_)LEGACY_IMAGE_FORMAT) += spl_legacy.o obj-$(CONFIG_$(SPL_TPL_)NOR_SUPPORT) += spl_nor.o obj-$(CONFIG_$(SPL_TPL_)XIP_SUPPORT) += spl_xip.o diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c new file mode 100644 index 0000000000..fb2e8bbea7 --- /dev/null +++ b/common/spl/spl_blk_fs.c @@ -0,0 +1,54 @@ +// 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>
+int spl_blk_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
enum uclass_id uclass_id, int devnum)
+{
int ret = -ENOSYS, part;
struct blk_desc *blk_desc;
blk_desc = blk_get_devnum_by_uclass_id(uclass_id, devnum);
if (!blk_desc)
return ret;
blk_show_device(uclass_id, devnum);
if (IS_ENABLED(CONFIG_SPL_FS_EXT4)) {
Can you use the fs.h layer so it can work with any FS?
Ok
switch (uclass_id) {
case UCLASS_NVME:
part = CONFIG_SYS_NVME_EXT_BOOT_PARTITION;
break;
default:
return ret;
}
ret = spl_load_image_ext(spl_image, bootdev, blk_desc, part,
CONFIG_SPL_PAYLOAD);
if (!ret)
return ret;
}
if (IS_ENABLED(CONFIG_SPL_FS_FAT)) {
switch (uclass_id) {
case UCLASS_NVME:
part = CONFIG_SYS_NVME_FAT_BOOT_PARTITION;
break;
default:
return ret;
}
ret = spl_load_image_fat(spl_image, bootdev, blk_desc, part,
CONFIG_SPL_PAYLOAD);
if (!ret)
return ret;
}
return ret;
+} diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 5a1aeb3d2b..6baaa6f071 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -107,6 +107,13 @@ config EFI_MEDIA
For sandbox there is a test driver.
+config SPL_BLK_FS
bool "Load images from filesystems on block devices"
depends on SPL_BLK
help
Use generic support to load images from fat/ext filesystems on
different types of block devices such as NVMe.
if EFI_MEDIA
config EFI_MEDIA_SANDBOX diff --git a/include/spl.h b/include/spl.h index 7e0f5ac63b..4546648394 100644 --- a/include/spl.h +++ b/include/spl.h @@ -672,6 +672,9 @@ int spl_load_image_ext(struct spl_image_info *spl_image, int spl_load_image_ext_os(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct blk_desc *block_dev, int partition); +int spl_blk_load_image(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev,
enum uclass_id uclass_id, int devnum);
/**
- spl_early_init() - Set up device tree and driver model in SPL if enabled
-- 2.34.1
Regards, Simon

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 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
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

On Thu, 4 May 2023 at 03:53, 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 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
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
Drop that as the default is n and it confuses people into thinking the default is y....
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 -- 2.34.1
Regards, Simon

On Fri, May 5, 2023 at 6:11 AM Simon Glass sjg@chromium.org wrote:
On Thu, 4 May 2023 at 03:53, 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 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
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
Drop that as the default is n and it confuses people into thinking the default is y....
Ok.
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 -- 2.34.1
Regards, Simon

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 f117c630bf..7b771c41e9 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");

Hi Mayuresh,
On Thu, 4 May 2023 at 03:53, Mayuresh Chitale mchitale@ventanamicro.com wrote:
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 f117c630bf..7b771c41e9 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 you use the fs_...() interface instead, can you make this function generic for all filesystems?
if (ret < 0) {
if (IS_ENABLED(CONFIG_SPL_LIBCOMMON_SUPPORT)) {
printf("%s: error reading image %s, err - %d\n",
__func__, filename, ret);
I could be wrong, but I think printf() is silently dropped if that option is not enabled, so maybe you don't need the if() checK?
}
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,
Really this should not be different from FAT and other filesystems. I'm not sure what is involved in making it common, though.
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
Regards, Simon

On Fri, May 5, 2023 at 6:11 AM Simon Glass sjg@chromium.org wrote:
Hi Mayuresh,
On Thu, 4 May 2023 at 03:53, Mayuresh Chitale mchitale@ventanamicro.com wrote:
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 f117c630bf..7b771c41e9 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 you use the fs_...() interface instead, can you make this function generic for all filesystems?
Ok.
if (ret < 0) {
if (IS_ENABLED(CONFIG_SPL_LIBCOMMON_SUPPORT)) {
printf("%s: error reading image %s, err - %d\n",
__func__, filename, ret);
I could be wrong, but I think printf() is silently dropped if that option is not enabled, so maybe you don't need the if() checK?
}
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,
Really this should not be different from FAT and other filesystems. I'm not sure what is involved in making it common, though.
Yes, it can be made generic.
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
Regards, Simon

On Thu, May 04, 2023 at 03:23:26PM +0530, Mayuresh Chitale wrote:
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 f117c630bf..7b771c41e9 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;
Please build on 32bit platforms such as j721e_evm_r5 as well: +common/spl/spl_ext.c:16:26: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] + 16 | loff_t filelen = (loff_t)load->priv, actlen;

Am 17. Mai 2023 16:41:47 MESZ schrieb Tom Rini trini@konsulko.com:
On Thu, May 04, 2023 at 03:23:26PM +0530, Mayuresh Chitale wrote:
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 f117c630bf..7b771c41e9 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;
The comma seems to be incorrect.
- char *filename = (char *)load->filename;
Please build on 32bit platforms such as j721e_evm_r5 as well: +common/spl/spl_ext.c:16:26: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
- 16 | loff_t filelen = (loff_t)load->priv, actlen;

On Wed, May 17, 2023 at 8:11 PM Tom Rini trini@konsulko.com wrote:
On Thu, May 04, 2023 at 03:23:26PM +0530, Mayuresh Chitale wrote:
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 f117c630bf..7b771c41e9 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;
Please build on 32bit platforms such as j721e_evm_r5 as well: +common/spl/spl_ext.c:16:26: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
- 16 | loff_t filelen = (loff_t)load->priv, actlen;
Ok.
-- Tom

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 | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 46 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 515e8f2c66..6e41ac4e56 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -1284,6 +1284,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 5210ad0248..bad2bbf6cf 100644 --- a/common/spl/Makefile +++ b/common/spl/Makefile @@ -29,6 +29,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..82b2bf3493 --- /dev/null +++ b/common/spl/spl_nvme.c @@ -0,0 +1,34 @@ +// 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; + + ret = pci_init(); + if (ret < 0) + return ret; + + ret = nvme_scan_namespace(); + if (ret < 0) + return ret; + + ret = spl_blk_load_image(spl_image, bootdev, UCLASS_NVME, + CONFIG_SPL_NVME_BOOT_DEVICE); + return ret; +} + +SPL_LOAD_IMAGE_METHOD("NVME", 0, BOOT_DEVICE_NVME, spl_nvme_load_image);

On Thu, 4 May 2023 at 03:53, 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 | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 common/spl/spl_nvme.c
Reviewed-by: Simon Glass sjg@chromium.org
BTW you should also be able to add a test for this using sandbox_spl
participants (4)
-
Heinrich Schuchardt
-
Mayuresh Chitale
-
Simon Glass
-
Tom Rini