From abd1e94f70c9a2828d5ebec05013b055fb33c21d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 23 Oct 2023 00:02:10 -0700 Subject: Revert "bootstd: Scan all bootdevs in a boot_targets entry" This commit was intended to allow all bootdevs in each boot_targets entry to be scanned. However it causes bad ordering with bootdevs, e.g. scanning Ethernet bootdevs when it should be keeping to mmc. Revert it so we can try another approach. This reverts commit e824d0d0c219bc6da767f13f90c5b00eefe929f0. Signed-off-by: Simon Glass Tested-by: Ivan T.Ivanov --- test/boot/bootdev.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'test/boot/bootdev.c') diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index c5f14a7a132..6b29213416d 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -221,16 +221,6 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name); bootflow_iter_uninit(&iter); - /* Make sure it scans a bootdevs in each target */ - ut_assertok(env_set("boot_targets", "mmc spi")); - ut_asserteq(0, bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); - ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); - ut_asserteq(3, iter.num_devs); - ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); - ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name); - ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name); - bootflow_iter_uninit(&iter); - return 0; } BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -- cgit v1.2.3 From 7ae83bfaf437320ec6b6e883bd2896fba784fbf9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 23 Oct 2023 00:02:11 -0700 Subject: bootstd: Expand boot-ordering test to include USB Scan the USB bus as well, so we can check that different uclasses work correctly in boot_targets update the function comment with more detail. Signed-off-by: Simon Glass Tested-by: Ivan T.Ivanov --- test/boot/bootdev.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'test/boot/bootdev.c') diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 6b29213416d..7228f545e9e 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -190,12 +190,21 @@ static int bootdev_test_any(struct unit_test_state *uts) BOOTSTD_TEST(bootdev_test_any, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV); -/* Check bootdev ordering with the bootdev-order property */ +/* + * Check bootdev ordering with the bootdev-order property and boot_targets + * environment variable + */ static int bootdev_test_order(struct unit_test_state *uts) { struct bootflow_iter iter; struct bootflow bflow; + test_set_skip_delays(true); + + /* Start up USB which gives us three additional bootdevs */ + usb_started = false; + ut_assertok(run_command("usb start", 0)); + /* * First try the order set by the bootdev-order property * Like all sandbox unit tests this relies on the devicetree setting up @@ -213,12 +222,14 @@ static int bootdev_test_order(struct unit_test_state *uts) bootflow_iter_uninit(&iter); /* Use the environment variable to override it */ - ut_assertok(env_set("boot_targets", "mmc1 mmc2")); + ut_assertok(env_set("boot_targets", "mmc1 mmc2 usb")); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); - ut_asserteq(2, iter.num_devs); + ut_asserteq(3, iter.num_devs); ut_asserteq_str("mmc1.bootdev", iter.dev_used[0]->name); ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name); + ut_asserteq_str("usb_mass_storage.lun0.bootdev", + iter.dev_used[2]->name); bootflow_iter_uninit(&iter); return 0; -- cgit v1.2.3 From 16e19350d91e3c7e916b85b84c0364b20ac193d2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 23 Oct 2023 00:02:12 -0700 Subject: bootstd: Correct logic for single uclass The current logic for "bootflow mmc" is flawed since it checks the uclass of the bootdev instead of its parent, the media device. Correct this and add a test that covers this scenario. Signed-off-by: Simon Glass Tested-by: Ivan T.Ivanov --- test/boot/bootdev.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/boot/bootdev.c') diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 7228f545e9e..63786174805 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -232,6 +232,19 @@ static int bootdev_test_order(struct unit_test_state *uts) iter.dev_used[2]->name); bootflow_iter_uninit(&iter); + /* Try a single uclass */ + ut_assertok(env_set("boot_targets", NULL)); + ut_assertok(bootflow_scan_first(NULL, "mmc", &iter, 0, &bflow)); + ut_asserteq(2, iter.num_devs); + + /* Now scan pass mmc1 and make sure that only mmc0 shows up */ + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(3, iter.num_devs); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); + ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name); + ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name); + bootflow_iter_uninit(&iter); + return 0; } BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -- cgit v1.2.3 From 7a790f018a812b5897fc144c46291de8df633429 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 23 Oct 2023 00:02:13 -0700 Subject: bootstd: Scan all bootdevs in a boot_targets entry (take 2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the boot_targets environment variable is used with the distro-boot scripts, each device is included individually. For example, if there are three mmc devices, then we will have something like: boot_targets="mmc0 mmc1 mmc2" In contrast, standard boot supports specifying just the uclass, i.e.: boot_targets="mmc" The intention is that this should scan all MMC devices, but in fact it currently only scans the first. Update the logic to handle this case, without required BOOTSTD_FULL to be enabled. Signed-off-by: Simon Glass Reported-by: Date Huang Reported-by: Vincent Stehlé Reported-by: Ivan Ivanov Tested-by: Ivan T.Ivanov --- test/boot/bootdev.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'test/boot/bootdev.c') diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 63786174805..0702fccdae6 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -225,7 +225,7 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_assertok(env_set("boot_targets", "mmc1 mmc2 usb")); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); - ut_asserteq(3, iter.num_devs); + ut_asserteq(5, iter.num_devs); ut_asserteq_str("mmc1.bootdev", iter.dev_used[0]->name); ut_asserteq_str("mmc2.bootdev", iter.dev_used[1]->name); ut_asserteq_str("usb_mass_storage.lun0.bootdev", @@ -237,7 +237,20 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_assertok(bootflow_scan_first(NULL, "mmc", &iter, 0, &bflow)); ut_asserteq(2, iter.num_devs); - /* Now scan pass mmc1 and make sure that only mmc0 shows up */ + /* Now scan past mmc1 and make sure that only mmc0 shows up */ + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(3, iter.num_devs); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); + ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name); + ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name); + bootflow_iter_uninit(&iter); + + /* Try a single uclass with boot_targets */ + ut_assertok(env_set("boot_targets", "mmc")); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + ut_asserteq(2, iter.num_devs); + + /* Now scan past mmc1 and make sure that only mmc0 shows up */ ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); ut_asserteq(3, iter.num_devs); ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); @@ -245,6 +258,21 @@ static int bootdev_test_order(struct unit_test_state *uts) ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name); bootflow_iter_uninit(&iter); + /* Try a single uclass with boot_targets */ + ut_assertok(env_set("boot_targets", "mmc usb")); + ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + ut_asserteq(2, iter.num_devs); + + /* Now scan past mmc1 and make sure that the 3 USB devices show up */ + ut_asserteq(-ENODEV, bootflow_scan_next(&iter, &bflow)); + ut_asserteq(6, iter.num_devs); + ut_asserteq_str("mmc2.bootdev", iter.dev_used[0]->name); + ut_asserteq_str("mmc1.bootdev", iter.dev_used[1]->name); + ut_asserteq_str("mmc0.bootdev", iter.dev_used[2]->name); + ut_asserteq_str("usb_mass_storage.lun0.bootdev", + iter.dev_used[3]->name); + bootflow_iter_uninit(&iter); + return 0; } BOOTSTD_TEST(bootdev_test_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT); -- cgit v1.2.3