From 8acfd7ddce409cab5ac3b994faa0ae2c0d38ccf3 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 21 Jul 2023 14:09:43 +0200 Subject: [PATCH 1/5] spl: blk: use CONFIG_SPL_FS_LOAD_PAYLOAD_NAME We should target to unify the code for different block devices in SPL to reduce code size. MMC, USB, SATA, and Semihosting use CONFIG_SPL_FS_LOAD_PAYLOAD_NAME to indicate the filename to load. NVMe uses CONFIG_SPL_PAYLOAD in spl_blk_load_image(). CONFIG_SPL_PAYLOAD is meant to define which binary to integrate into u-boot-with-spl.bin. See commit 7550dbe38b3f ("spl: Add option SPL_PAYLOAD"). Change spl_blk_load_image() to use CONFIG_SPL_FS_LOAD_PAYLOAD_NAME. Fixes: 8ce6a2e17577 ("spl: blk: Support loading images from fs") Signed-off-by: Heinrich Schuchardt Reviewed-by: Mayuresh Chitale --- common/spl/spl_blk_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c index d97adc4d39a..d4161fa850a 100644 --- a/common/spl/spl_blk_fs.c +++ b/common/spl/spl_blk_fs.c @@ -43,7 +43,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, enum uclass_id uclass_id, int devnum, int partnum) { - const char *filename = CONFIG_SPL_PAYLOAD; + const char *filename = CONFIG_SPL_FS_LOAD_PAYLOAD_NAME; struct disk_partition part_info = {}; struct legacy_img_hdr *header; struct blk_desc *blk_desc; From 350635fe837341e7ce7b7b900f18d7d306fdb42e Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 21 Jul 2023 17:37:37 +0200 Subject: [PATCH 2/5] part: check CONFIG_IS_ENABLED(ENV_SUPPORT) In SPL environment variables may not be enabled. Suggested-by: Tom Rini Signed-off-by: Heinrich Schuchardt Reviewed-by: Tom Rini --- disk/part.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/disk/part.c b/disk/part.c index 186ee965006..eec02f58988 100644 --- a/disk/part.c +++ b/disk/part.c @@ -508,9 +508,11 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str, #endif /* If no dev_part_str, use bootdevice environment variable */ - if (!dev_part_str || !strlen(dev_part_str) || - !strcmp(dev_part_str, "-")) - dev_part_str = env_get("bootdevice"); + if (CONFIG_IS_ENABLED(ENV_SUPPORT)) { + if (!dev_part_str || !strlen(dev_part_str) || + !strcmp(dev_part_str, "-")) + dev_part_str = env_get("bootdevice"); + } /* If still no dev_part_str, it's an error */ if (!dev_part_str) { From d62e7b8059847a06bc0f2222643425bff775320b Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 22 Jul 2023 12:45:44 +0200 Subject: [PATCH 3/5] spl: blk: partition numbers are hexadecimal Loading u-boot.itb from device 0x00, partition 0x0f fails with: Trying to boot from NVME Device 0: Vendor: 0x4x Rev: 8.0.50 Prod: nvme-1 Type: Hard Disk Capacity: 3814.6 MB = 3.7 GB (7812500 x 512) ** Invalid partition 21 ** Couldn't find partition nvme 0:15 Like the command line interface fs_det_blk_dev() expects that the device number and the partition number are hexadecimal. Fixes: 8ce6a2e17577 ("spl: blk: Support loading images from fs") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass Reviewed-by: Mayuresh Chitale --- common/spl/spl_blk_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/spl_blk_fs.c b/common/spl/spl_blk_fs.c index d4161fa850a..16ecece7023 100644 --- a/common/spl/spl_blk_fs.c +++ b/common/spl/spl_blk_fs.c @@ -66,7 +66,7 @@ int spl_blk_load_image(struct spl_image_info *spl_image, } dev.ifname = blk_get_uclass_name(uclass_id); - snprintf(dev.dev_part_str, sizeof(dev.dev_part_str) - 1, "%d:%d", + snprintf(dev.dev_part_str, sizeof(dev.dev_part_str) - 1, "%x:%x", devnum, partnum); ret = fs_set_blk_dev(dev.ifname, dev.dev_part_str, FS_TYPE_ANY); if (ret) { From 8d2c311ce64939fe829037e4ef7951c3fafaee06 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 24 Jul 2023 21:27:26 +0200 Subject: [PATCH 4/5] spl: CONFIG_SPL_PCI_PNP should depend on CONFIG_SPL_PCI CONFIG_SPL_PCI_PNP=y without CONFIG_SPL_PCI=y makes no sense. Fixes: 32f5e9e5c1a7 ("nvme: pci: Enable for SPL") Signed-off-by: Heinrich Schuchardt Reviewed-by: Tom Rini --- drivers/pci/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index aca439d9213..93e6f500000 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -41,7 +41,8 @@ config PCI_PNP Enable PCI memory and I/O space resource allocation and assignment. config SPL_PCI_PNP - bool "Enable Plug & Play support for PCI" + bool "Enable Plug & Play support for PCI in SPL" + depends on SPL_PCI help Enable PCI memory and I/O space resource allocation and assignment. From 7d4c8cfe2547596d07c51b2f38cde8d4c75f17fc Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 24 Jul 2023 22:18:41 +0200 Subject: [PATCH 5/5] spl: initialize PCI before booting MMC, SATA, and USB may be using PCI based controllers. Initialize the PCI sub-system before trying to boot. Remove the initialization for NVMe that is now redundant. Signed-off-by: Heinrich Schuchardt Reviewed-by: Tom Rini Reviewed-by: Mayuresh Chitale --- common/spl/spl.c | 7 +++++++ common/spl/spl_nvme.c | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index f09bb977814..0062f3f45d9 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -800,6 +800,13 @@ void board_init_r(gd_t *dummy1, ulong dummy2) IS_ENABLED(CONFIG_SPL_ATF)) dram_init_banksize(); + if (CONFIG_IS_ENABLED(PCI)) { + ret = pci_init(); + if (ret) + puts(SPL_TPL_PROMPT "Cannot initialize PCI\n"); + /* Don't fail. We still can try other boot methods. */ + } + bootcount_inc(); /* Dump driver model states to aid analysis */ diff --git a/common/spl/spl_nvme.c b/common/spl/spl_nvme.c index 2af63f1dc8c..c8774d67ecf 100644 --- a/common/spl/spl_nvme.c +++ b/common/spl/spl_nvme.c @@ -7,7 +7,6 @@ #include #include -#include #include static int spl_nvme_load_image(struct spl_image_info *spl_image, @@ -15,10 +14,6 @@ static int spl_nvme_load_image(struct spl_image_info *spl_image, { int ret; - ret = pci_init(); - if (ret < 0) - return ret; - ret = nvme_scan_namespace(); if (ret < 0) return ret;