From patchwork Tue Sep 30 00:51:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 437 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193519; bh=fcFtDHJfe3ScVjJZ1zCf4jEe6oVyd4al2w33W6vtauY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=K+M2/bX7iy5h1Co2j+we5gWAzi8cHWWn2Uxj9ACbtN0kxifxQDghFgr1hBa+vMQSV jKsYYNAZ350twgfaUpDz2+PpWt0WL6pQvAPE9FfSqLPo2nN18llActfrCC4vevTSsp 2K9WEBFj54UT7jIWV81kje3WQNyblTpM47MZ82FdIMQ8cwfkRHzQL5h6kq+9ZF30bZ e8e+Z42WRvJzPw2Bczc8h4NHU0PKPn1Chg7Pn3py09JfJyF1kXxpkl31rGkX/ePQ/n EBBIEaib1tPUyqHKBT/b75tbCN1RB5oDfp56CAA/+iJnXq42vb2Z2tvVZHvQnpRwTK Et3p/HZq2PZLg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E0AFF67E59 for ; Mon, 29 Sep 2025 18:51:59 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kQrv4q7_GXND for ; Mon, 29 Sep 2025 18:51:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193519; bh=fcFtDHJfe3ScVjJZ1zCf4jEe6oVyd4al2w33W6vtauY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=K+M2/bX7iy5h1Co2j+we5gWAzi8cHWWn2Uxj9ACbtN0kxifxQDghFgr1hBa+vMQSV jKsYYNAZ350twgfaUpDz2+PpWt0WL6pQvAPE9FfSqLPo2nN18llActfrCC4vevTSsp 2K9WEBFj54UT7jIWV81kje3WQNyblTpM47MZ82FdIMQ8cwfkRHzQL5h6kq+9ZF30bZ e8e+Z42WRvJzPw2Bczc8h4NHU0PKPn1Chg7Pn3py09JfJyF1kXxpkl31rGkX/ePQ/n EBBIEaib1tPUyqHKBT/b75tbCN1RB5oDfp56CAA/+iJnXq42vb2Z2tvVZHvQnpRwTK Et3p/HZq2PZLg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CDB9967E31 for ; Mon, 29 Sep 2025 18:51:59 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193517; bh=cJr9l31rZth5Wrxy/sQERz7LpqR45zrNllcoxcP4N+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WEh9/UJjAnLNX+2DWMalyzPkH+haJJwFgA18Ut7Wv3bO+ci9eBPkdNgDzwU1oTpbc x/NpWbXBganEcFEM+wUfc7iTEljj48hAvIgTrj5pd9W+Qk91kBW+XLN7PGSzTNQpNU R6k1UkNt8woAUpWdcw57ppR59Bw3l9C3Lh+8Uk0YHdPCY6ZH+UvmdEklg3+YSNSsqA lS25Mw5qKLjfDz9kkqWrzz2fBVTR5swtoGuJgiuFK22bE1NwjPxD4KYOldqzhIvb9a 9GUxLfE+RRRLqCTKVH3HUUGmKR8NG8IRUFp6S1khvZ3Aco3eiUn4cSXU/wfjNVeXVi +Uql7CvGq5ICg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 950AF67E31; Mon, 29 Sep 2025 18:51:57 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Y799treW4bKo; Mon, 29 Sep 2025 18:51:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193511; bh=L62AoTGO/sOCrND7Vn2KpckP153LhSDirWlSIrIHfDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oLWcr3EtjKzDF84Riv5DzVEdWwj5ygSjCh4bk3m1ItmjpqJo380juHUGNFPzmZsVJ yzgJQ8u6jhZf6IVEOpq2PDxHjtcpDjzqTYwdt2pFrjjENVSyQyLRlek+pvzR5/rHUo wJ4EkYh2B/U57sPk5qv3J5eyBDZhZx7/PdDii3jb1QdUTE0hjsHFafJBU9EbOk7FWO 63C6npeqJzrVq9Bw17sErGXEwo2X/QWgH2LVeSiXPk8yhcB5GelhGtVMhHCMRjqfnt ikFH25MFQZTHauScsOvWa1SYlFyHyn3YaNMxsTX8AEhqYn6fUlJj6If2uTpljLFOIu 3tyyolgMdeUDw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7B62B67B49; Mon, 29 Sep 2025 18:51:51 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:17 -0600 Message-ID: <20250930005137.3650600-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BCXGPPD5NZUIXNT45KEQZRYR4HUDNZPP X-Message-ID-Hash: BCXGPPD5NZUIXNT45KEQZRYR4HUDNZPP X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/15] boot: Improve comments related to global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a few comments about global bootmeths and first_glob_method Fix a broken line in bootmeth_setup_iter_order() while we are here. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- boot/bootflow.c | 3 ++- boot/bootmeth-uclass.c | 4 ++-- include/bootflow.h | 3 ++- test/boot/bootflow.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index c8391641001..de1f0c99916 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -150,7 +150,7 @@ static void bootflow_iter_set_dev(struct bootflow_iter *iter, if (dev) printf("Scanning bootdev '%s':\n", dev->name); else if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && - ucp->flags & BOOTMETHF_GLOBAL) + ucp->flags & BOOTMETHF_GLOBAL) printf("Scanning global bootmeth '%s':\n", iter->method->name); else @@ -347,6 +347,7 @@ static int bootflow_check(struct bootflow_iter *iter, struct bootflow *bflow) struct udevice *dev; int ret; + /* handle global bootmeths if needed */ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global) { bootflow_iter_set_dev(iter, NULL, 0); ret = bootmeth_get_bootflow(iter->method, bflow); diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 8c191082cf3..152c334f205 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -147,8 +147,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global) bool is_global; ucp = dev_get_uclass_plat(dev); - is_global = ucp->flags & - BOOTMETHF_GLOBAL; + is_global = ucp->flags & BOOTMETHF_GLOBAL; if (is_global) { iter->first_glob_method = i; break; @@ -193,6 +192,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global) if (!count) return log_msg_ret("count2", -ENOENT); + /* start with the global bootmeths */ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && include_global && iter->first_glob_method != -1 && iter->first_glob_method != count) { iter->cur_method = iter->first_glob_method; diff --git a/include/bootflow.h b/include/bootflow.h index 284c23c59dd..4d1f888a5a8 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -263,7 +263,8 @@ enum bootflow_meth_flags_t { * @cur_label: Current label being processed * @num_methods: Number of bootmeth devices in @method_order * @cur_method: Current method number, an index into @method_order - * @first_glob_method: First global method, if any, else -1 + * @first_glob_method: Index of first global method within @method_order[], if + * any, else -1 * @cur_prio: Current priority being scanned * @method_order: List of bootmeth devices to use, in order. The normal methods * appear first, then the global ones, if any diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 14e3326a08f..be85032985d 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -439,7 +439,7 @@ static int bootflow_system(struct unit_test_state *uts) ut_assertok(device_probe(dev)); sandbox_set_fake_efi_mgr_dev(dev, true); - /* We should get a single 'bootmgr' method right at the end */ + /* We should get a single 'bootmgr' method at the start */ bootstd_clear_glob(); ut_assertok(run_command("bootflow scan -lH", 0)); ut_assert_skip_to_line( From patchwork Tue Sep 30 00:51:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 438 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193522; bh=00RsA9gGB21v1zKsKm+0lAwbX3nFBDtcG9LQM6D4hy8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pu03bSAurRw2o6e6O3NR6lCK1yHGDwjNwDijJVTCPxcRZz8wIHqzyx9PvlM1lAm9P wIg5PpjbNl1ceRsoAcjeYtfoHw0frU+iDIhVTRKXq63a4JKj/JZs2vBfx1SHGi1o5e ideMeMDW9WfaNDMUGr/DwZ3JbeO5fSFWiHRyxjvBANDKNQczOL7A2rlHwEYzKOnWfT eMH3Re/07vDDXLCFdbgFuUIazQ3xSIYQTWBU3zm80KAiBx/V0bd2QngUMWxr11+06h DcOBwDwmIo5ptE55UQQlqwwQWePzQ5hmy3Id57BgVgShtqhjttcRIGxF/0XSBqCsgH /TRstm0b/Ma6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5948B67E31 for ; Mon, 29 Sep 2025 18:52:02 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id pwj3uCVqNF7D for ; Mon, 29 Sep 2025 18:52:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193520; bh=00RsA9gGB21v1zKsKm+0lAwbX3nFBDtcG9LQM6D4hy8=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=WPwFUSA1gIt9rw/rIvs/v9otsI/N8cc5ZP3+s/2KVPv11t9nXNtzxKbJ2iySu4vk8 JcYAoUcPVQkslUTPOIY6egKBcul1Rq2MbQJsxNRY8JE5B7oJTArqq426CQ/TPP62zE SRjPcEWoOVjyZ70aTul07K5rI5QvdYzt/SDAOtknMWJvJATP5Jb43sg81y9zGdZVIU CIlJA8WdvJXbX9+mMWDbNpQyDwny4mVkc1+ZeB+a6pIcput/wyaeuw/cMh3nbjjgEG OjsrzErYOIcmLRzVNRFOowaBm5dInXgrrxz/g0JRI3LuEozCNUIE+EPt2Sb4UmYFtl zidD6+skrUS8g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 53CA067B49 for ; Mon, 29 Sep 2025 18:52:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193517; bh=bzoXOM9TN+Gh3wkMy5BjvzyEri2lEYdKuATB4fS0JHA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wKUDTnJVH3+URSMOWj2t38dKvRwdiEpxLoWr0xo0JIOfIrDfMeezG/4/WLgbGQGOC aCmTr9OimfimjpHrOeqENM4mdsz4Vr6uDmJZVrypxwOdQkSn4mzK4en0NG+9iGBqe3 ecfIgUooU39/+Kcx1HUAKHlsNt81pOTYr2rjwBxz87sRraSSfrB8zlDDXd2/IUVPk7 BpeTlGEKP+XASYK6HjNjgO7W4OuB5dAMoXvUn4IX/A0mydf3TG9Zsr9HQi8RtHj3pP J0/gTCFe/G8493Ju2yrMJ2+86MZhjmYazXtvNK2YgBrApeQzhn8TRe2EKOzFM/KNmf bP7YdRBgHFaPA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D48ED67B49; Mon, 29 Sep 2025 18:51:57 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id UAPKUhuHQp3A; Mon, 29 Sep 2025 18:51:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193516; bh=fwtFAU+w970g4ZTpqcrmeJA6RhlHKlCzOn1n8cUGJ/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6sRf0cBduZK8WNbDdCQBoCXrOxz8rD9N6sIn1c0bkRCJ67u6c9XLmpHM2GJ7e4vq yk4uXbs6QZVGNQUXjYXLE6EKsaM+5C0chY0BanTnSu/viRC4OjGz87t0KpTw2vcSTI ehP25i0ha2x+UOKO7gxgM4zm28txOtky3qDpi4n/rdHy3Gpqw8XrvvKqbo8+5WwQ6L s2Buu+rgLnAivHgyawXmm+nGFjbdiCHt3QUQ8ZV8GWGVLSi5TWTJkqaVHEyGK08Xen uleEw4cmUR63HlvBzda9h27gyye0u2xrLTdshmcWtovOgIx6nN+ymQDq4PaW8G4U6E FiOD8ovIju+rw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1943367E03; Mon, 29 Sep 2025 18:51:56 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:18 -0600 Message-ID: <20250930005137.3650600-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 2ULCGRDZHDK6D5FINXUL7SWOB2X5NU5C X-Message-ID-Hash: 2ULCGRDZHDK6D5FINXUL7SWOB2X5NU5C X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/15] boot: Add more debugging to iter_incr() List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass This function is the core of the bootstd iteration. Add some debugging for the decisions it makes along the way, to make it easier to track what is going on. Signed-off-by: Simon Glass --- boot/bootflow.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index de1f0c99916..79be94960e7 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -195,14 +195,19 @@ static int iter_incr(struct bootflow_iter *iter) log_debug("entry: err=%d\n", iter->err); global = iter->doing_global; - if (iter->err == BF_NO_MORE_DEVICES) + if (iter->err == BF_NO_MORE_DEVICES) { + log_debug("-> err: no more devices1\n"); return BF_NO_MORE_DEVICES; + } /* Get the next boothmethod */ if (++iter->cur_method < iter->num_methods) { iter->method = iter->method_order[iter->cur_method]; + log_debug("-> next method '%s'\n", iter->method->name); return 0; } + log_debug("! no more methods: cur_method %d num_methods %d\n", + iter->cur_method, iter->num_methods); /* * If we have finished scanning the global bootmeths, start the @@ -219,8 +224,10 @@ static int iter_incr(struct bootflow_iter *iter) inc_dev = false; } - if (iter->flags & BOOTFLOWIF_SINGLE_PARTITION) + if (iter->flags & BOOTFLOWIF_SINGLE_PARTITION) { + log_debug("-> single partition: no more devices\n"); return BF_NO_MORE_DEVICES; + } /* No more bootmeths; start at the first one, and... */ iter->cur_method = 0; @@ -228,11 +235,15 @@ static int iter_incr(struct bootflow_iter *iter) if (iter->err != BF_NO_MORE_PARTS) { /* ...select next partition */ - if (++iter->part <= iter->max_part) + if (++iter->part <= iter->max_part) { + log_debug("-> next partition %d max %d\n", iter->part, + iter->max_part); return 0; + } } /* No more partitions; start at the first one and... */ + log_debug("! no more partitions\n"); iter->part = 0; /* @@ -328,8 +339,13 @@ static int iter_incr(struct bootflow_iter *iter) } /* if there are no more bootdevs, give up */ - if (ret) + if (ret) { + log_debug("-> no more bootdevs\n"); return log_msg_ret("incr", BF_NO_MORE_DEVICES); + } + + log_debug("-> bootdev '%s' method '%s'\n", dev->name, + iter->method->name); return 0; } From patchwork Tue Sep 30 00:51:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 439 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193526; bh=d29xyp4OXC4RCHpLXV7hXtPWqIzRVBMjzD7Et2+ZXFY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FufA123zacwTuj9j8GMfLGz6UCC5JOErBcLWOOLTcFkEcBPRWpulk7mFAgLxmOWdC Fg4VwQ0HI4AFH02xmJCsajAxKw4KpQf8auSmTcxFbhYZzhIBJPV0KuMaga8h5SwJgS 9U8yWSj5JeCnkzyZGdfGg1BhADoRhDgoeL5FezEWlmtNq/rO6LtPSUUjUNIUVOlMOZ gqATOWoSY2pQuNuTM+EaFJhVx9lGPZStaI2guWbdbj7PQhUqwWIMB1iWpAn7MHDpPn PQ/MTDDLCjCAyOqNSZ58nFNU8yJXli5N6jVPn4YZJ4AT9ZM62bGmoEZfuhd6vCK4Gv QkmGpHS3c9d9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C477067E59 for ; Mon, 29 Sep 2025 18:52:06 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BdEq0X4LviTP for ; Mon, 29 Sep 2025 18:52:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193526; bh=d29xyp4OXC4RCHpLXV7hXtPWqIzRVBMjzD7Et2+ZXFY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FufA123zacwTuj9j8GMfLGz6UCC5JOErBcLWOOLTcFkEcBPRWpulk7mFAgLxmOWdC Fg4VwQ0HI4AFH02xmJCsajAxKw4KpQf8auSmTcxFbhYZzhIBJPV0KuMaga8h5SwJgS 9U8yWSj5JeCnkzyZGdfGg1BhADoRhDgoeL5FezEWlmtNq/rO6LtPSUUjUNIUVOlMOZ gqATOWoSY2pQuNuTM+EaFJhVx9lGPZStaI2guWbdbj7PQhUqwWIMB1iWpAn7MHDpPn PQ/MTDDLCjCAyOqNSZ58nFNU8yJXli5N6jVPn4YZJ4AT9ZM62bGmoEZfuhd6vCK4Gv QkmGpHS3c9d9g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B3EC967E31 for ; Mon, 29 Sep 2025 18:52:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193524; bh=xA9OksOm/NcRzfjWkTZMUEAgSxOcq39Pl7iHlZCvpbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhFFOe5iN/aqD4FnecnvdeaqRic4+njbdEs3pq8Ocqqw3BegIiBPdVvzBBNSw4p6B eBeciFU6TKOgamNIpyR2pOS2dtNYcZTzKv2Z1PUiqrr+Fx5ElUVm8TXM7XJQvrVhEl BPAyiNKBszwxjVI11Fr1gg49xsmsZsWOqF9IJjR1FuOjocKlT69dsVIgy1IfiVqbQ5 lkuZ/G5YOcfV1Kvm7VGs0u16zMHaP0Ko1TZFLZQFPGiLzKelx1EA4iUn8yt6JTwA5r ed/j1eGxdgeco2NwlLWU0fDAkekZfcM1QhBfgaEzJGj9U9sER3vBra3RxUoY0GproL AawBTDaLZcOsQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B4FDA67E31; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id q5oxYdythcYf; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193518; bh=6lk/OL7wYytGEai8f222pjYKuErwtiHhlOuTOSOTzrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoVrISP0Jq8EERm8qws1Kcf7zAV+lw9O/quwUankEnCCLrOrILRiv5bPJOiJS9xQp Hs7BEd1IR8zrttCKrTCngH23V0X7wG7LENaX0tGgJg2BaB3OWc69xC6Pmh2V0gMbmH qt5gOU8xwbJ5tsWOO7mjMJJ8qOSIwVwchCI6nLSxfTRoW1EMYuouILOTww72yWZpgH YQxm5/YdfmtCcN0RJZ/+KknfMMfLFqqb+bKtTL8S2aslpy5hik2453mnI0Z50C/NTl rbTEYPubIpMiLXUjTE4Drtxlc3WGBA/IvdSekpydHgxWyHNK2Z4Cp3He3rqFKAs5Lq XO6c0VwNAoqNg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 245D967E03; Mon, 29 Sep 2025 18:51:58 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:19 -0600 Message-ID: <20250930005137.3650600-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TDUZXWCVUUIZE4V5BX6XCCLC35RKR6RU X-Message-ID-Hash: TDUZXWCVUUIZE4V5BX6XCCLC35RKR6RU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/15] boot: Move showing of bootflows out of the command List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass It is helpful in tests to be able to show the bootflow that is being examined. Move show_bootflow() into boot/ and rename it. Signed-off-by: Simon Glass --- boot/bootflow.c | 55 +++++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 68 ++-------------------------------------------- include/bootflow.h | 9 ++++++ 3 files changed, 67 insertions(+), 65 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 79be94960e7..4e646202f3d 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -56,6 +56,61 @@ const char *bootflow_state_get_name(enum bootflow_state_t state) return bootflow_state[state]; } +/** + * report_bootflow_err() - Report where a bootflow failed + * + * When a bootflow does not make it to the 'loaded' state, something went wrong. + * Print a helpful message if there is an error + * + * @bflow: Bootflow to process + * @err: Error code (0 if none) + */ +static void report_bootflow_err(struct bootflow *bflow, int err) +{ + if (!err) + return; + + /* Indent out to 'Method' */ + printf(" ** "); + + switch (bflow->state) { + case BOOTFLOWST_BASE: + printf("No media/partition found"); + break; + case BOOTFLOWST_MEDIA: + printf("No partition found"); + break; + case BOOTFLOWST_PART: + printf("No filesystem found"); + break; + case BOOTFLOWST_FS: + printf("File not found"); + break; + case BOOTFLOWST_FILE: + printf("File cannot be loaded"); + break; + case BOOTFLOWST_READY: + printf("Ready"); + break; + case BOOTFLOWST_COUNT: + break; + } + + printf(", err=%dE\n", err); +} + +void bootflow_show(int index, struct bootflow *bflow, bool errors) +{ + const char *name = bootflow_guess_label(bflow); + + printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, + bflow->method ? bflow->method->name : "(none)", + bootflow_state_get_name(bflow->state), name, bflow->part, + bflow->name, bflow->fname ?: ""); + if (errors) + report_bootflow_err(bflow, bflow->err); +} + int bootflow_first_glob(struct bootflow **bflowp) { struct bootstd_priv *std; diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 33ed9a1cd73..c9f36a364dd 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -18,68 +18,6 @@ #include #include -/** - * report_bootflow_err() - Report where a bootflow failed - * - * When a bootflow does not make it to the 'loaded' state, something went wrong. - * Print a helpful message if there is an error - * - * @bflow: Bootflow to process - * @err: Error code (0 if none) - */ -static void report_bootflow_err(struct bootflow *bflow, int err) -{ - if (!err) - return; - - /* Indent out to 'Method' */ - printf(" ** "); - - switch (bflow->state) { - case BOOTFLOWST_BASE: - printf("No media/partition found"); - break; - case BOOTFLOWST_MEDIA: - printf("No partition found"); - break; - case BOOTFLOWST_PART: - printf("No filesystem found"); - break; - case BOOTFLOWST_FS: - printf("File not found"); - break; - case BOOTFLOWST_FILE: - printf("File cannot be loaded"); - break; - case BOOTFLOWST_READY: - printf("Ready"); - break; - case BOOTFLOWST_COUNT: - break; - } - - printf(", err=%dE\n", err); -} - -/** - * show_bootflow() - Show the status of a bootflow - * - * @seq: Bootflow index - * @bflow: Bootflow to show - * @errors: True to show the error received, if any - */ -static void show_bootflow(int index, struct bootflow *bflow, bool errors) -{ - const char *name = bootflow_guess_label(bflow); - - printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index, - bflow->method ? bflow->method->name : "(none)", - bootflow_state_get_name(bflow->state), name, bflow->part, - bflow->name, bflow->fname ?: ""); - if (errors) - report_bootflow_err(bflow, bflow->err); -} - static void show_header(void) { printf("Seq Method State Uclass Part Name Filename\n"); @@ -240,7 +178,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } if (list) - show_bootflow(i, &bflow, errors); + bootflow_show(i, &bflow, errors); if (!menu && boot && !bflow.err) bootflow_run_boot(&iter, &bflow); } @@ -298,7 +236,7 @@ static int do_bootflow_list(struct cmd_tbl *cmdtp, int flag, int argc, !ret; ret = bootdev_next_bootflow(&bflow), i++) { num_valid += bflow->state == BOOTFLOWST_READY; - show_bootflow(i, bflow, errors); + bootflow_show(i, bflow, errors); } } else { printf("Showing all bootflows\n"); @@ -307,7 +245,7 @@ static int do_bootflow_list(struct cmd_tbl *cmdtp, int flag, int argc, !ret; ret = bootflow_next_glob(&bflow), i++) { num_valid += bflow->state == BOOTFLOWST_READY; - show_bootflow(i, bflow, errors); + bootflow_show(i, bflow, errors); } } show_footer(i, num_valid); diff --git a/include/bootflow.h b/include/bootflow.h index 4d1f888a5a8..6f53a7d4991 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -740,4 +740,13 @@ int bootflow_menu_poll(struct expo *exp, int *seqp); */ const char *bootflow_guess_label(const struct bootflow *bflow); +/** + * bootflow_show() - Show the status of a bootflow + * + * @seq: Bootflow index + * @bflow: Bootflow to show + * @errors: True to show the error received, if any + */ +void bootflow_show(int index, struct bootflow *bflow, bool errors); + #endif From patchwork Tue Sep 30 00:51:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 440 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193529; bh=+q5D60luvvpUdNRuVgCwMs/BHRYTSXuy+y4NyNYF+U4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=S6Jn+nIdMpJiJIhFYpGw75a0MGRZn+5dvtOI0YOOmVeUyjdSgUR+DtzFYgfza/MbR 11H3pbRUANM+UuClYpl8xICgovJd9SNWsYSTiB9lnPn3kvrWUA2FEtPaEQhBwb+q6o qIytmeAv19IDFJXiE34Ofl+y0tBfuRXn6rT/rqcXnCYQ2EN7aaaYcIVhmb+MJfVzOq wAZClYVPhB7TRrby8sVv2ZS8kuBJTi10H2s54bu5qGg6UaOo5WHEwOyg1MXj1OXeHv ELemQ/cL2yI1fIZcUxp3hZNjuCKkGizDTgq5m7+Z6UYspp4j+XjXIpV9i8XC/cJDMc 62hJnVcDjDRgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3267C67E58 for ; Mon, 29 Sep 2025 18:52:09 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Yeyf6AarbW3N for ; Mon, 29 Sep 2025 18:52:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193527; bh=+q5D60luvvpUdNRuVgCwMs/BHRYTSXuy+y4NyNYF+U4=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=wjywsxd9fsmyJfupLlhAjucIBVY2MOjf5vdH4YFU2CIjP9deeNMEkUX2l+UADIiHv hell0A2HlHEd9fEt7pb8z+HUzKWMTyx+muP/kYqSvYV564gNnRxMw21lJyY4tzTm8f AIhHVJZqAicnUnTlqYYruDrZ/UAEjP76obTZL6GwzcECgFS1Gh+a0kF5QdYGsAiAsX vS7BcK7kqyrHqtI3emSQdSUMl04Ol7cYYQ7y178HdMKOnuNh9OlhwZ364+arQRFUDb jPSJWAzq8Fxtoo+Q6CrtShEMLwtFMNyx8yD7NsR8iUObUIPaOyd9KUeYZuRl2VwTkw UOG9hnZNc5owA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5BD0267E31 for ; Mon, 29 Sep 2025 18:52:07 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193524; bh=fnaE2Mkfp7R6C4jl/Ia/Gdz2unY6ryieVx3BA7M3fHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9SJe0gkDCAEZO9pE3dESyxFLUBxycgBWZ00r/EiBFvSW5u72DvmrmH51BIYevQSJ UZVfovBQCTNtLWkgbPtO6tHj4PRtAplSs7/C/vu1u0K8Ji+SNCawUyqHDSfg9Sw3Ti 2Si1cx2y2W6K1fc2+QeEXGgQ7zszQbo+Q4hNIpPeETXdwTiCU3iqifP+OTBq9INanf m4hvwJ/LsCEQAS09eYdbcSKYUdzafm+8c2O6p+3QnyiAe3j7bJ1mk5hwmUFLhKeU4q l5tk7WMlldWX7A/k9NHuTuQRzQ8L+cGKayFROOJyqQdTjgi+A77MLl7Vwp/W9MWkEU EuPkb2qSbsEOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BE5A767E03; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 2srPisFW8rWt; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193523; bh=gbXQhbC8CnvNMbDQwm7n6+vAP5FODcnYEoYlHkQzTXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v9qI02ek4wAxYS/RsrIFefv6hci/vTurGabHerYKYV4kFnIJ414zKMLLfrHdroGgU vVItNHKqKp82LokQi7aT6vQyFfv0kI69XPfAF8AQyM+4eJNjVHYzYG5Zr/fXtXaQiR 3YM4Mug6/FX06FBwD3jK9dvQNsh63Hnqb7vc/rQiyUcRyPS6wJDzZK1ZbgvoqZo+4x 5drM9sPlSg1ICcGRTs2luQVjLcBdUF+w2gMc/EWKrW/3/hGBztv+qbnp8wqhuNCxzv qDhjQCaRoKjRddpvLl9OYezroMZXXRt4RmrUOB29nyQMEQFNZFUxVqTd7UmhPoKMjl M/uxFT3fJN2Ig== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BF25C67E5D; Mon, 29 Sep 2025 18:52:02 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:20 -0600 Message-ID: <20250930005137.3650600-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6BSH4OFOJHM3GNGI3ZLJXULOWHONUHGE X-Message-ID-Hash: 6BSH4OFOJHM3GNGI3ZLJXULOWHONUHGE X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/15] boot: Add a new test for global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass These have different behaviour from normal bootmeths and we are about to enhance it. So add a test and also an extra check in bootflow_iter() Signed-off-by: Simon Glass --- test/boot/bootflow.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index be85032985d..69a965dfa4b 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -313,6 +313,8 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(0, iter.max_part); ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); + ut_assert(!iter.doing_global); + ut_asserteq(-1, iter.first_glob_method); /* * This shows MEDIA even though there is none, since in @@ -426,6 +428,49 @@ static int bootflow_iter(struct unit_test_state *uts) BOOTSTD_TEST(bootflow_iter, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); #if defined(CONFIG_SANDBOX) && defined(CONFIG_BOOTMETH_GLOBAL) + +/* Check iterating through available bootflows to test global bootmeths */ +static int bootflow_iter_glob(struct unit_test_state *uts) +{ + struct bootflow_iter iter; + struct bootflow bflow; + + bootstd_clear_glob(); + + /* we should get the global bootmeth initially */ + ut_asserteq(-EINVAL, + bootflow_scan_first(NULL, NULL, &iter, BOOTFLOWIF_ALL | + BOOTFLOWIF_SHOW, &bflow)); + bootflow_show(0, &bflow, true); + ut_asserteq(4, iter.num_methods); + ut_assert(iter.doing_global); + ut_asserteq(3, iter.first_glob_method); + + ut_asserteq(3, iter.cur_method); + ut_asserteq(0, iter.part); + ut_asserteq(0, iter.max_part); + ut_asserteq_str("firmware0", iter.method->name); + ut_asserteq(0, bflow.err); + bootflow_free(&bflow); + + /* next we should get the first non-global bootmeth */ + ut_asserteq(-EPROTONOSUPPORT, bootflow_scan_next(&iter, &bflow)); + + /* at this point the global bootmeths are stranded above num_methods */ + ut_asserteq(3, iter.num_methods); + ut_asserteq(3, iter.first_glob_method); + ut_assert(!iter.doing_global); + + ut_asserteq(0, iter.cur_method); + ut_asserteq(0, iter.part); + ut_asserteq(0, iter.max_part); + ut_asserteq_str("extlinux", iter.method->name); + ut_asserteq(0, bflow.err); + + return 0; +} +BOOTSTD_TEST(bootflow_iter_glob, UTF_DM | UTF_SCAN_FDT); + /* Check using the system bootdev */ static int bootflow_system(struct unit_test_state *uts) { From patchwork Tue Sep 30 00:51:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 442 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193536; bh=nUnuQkweADJ2xdjPDsjxrzQ0noYj45fpl1BlrKIgJlw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LjJa6UemWx5LJtirqOuy72lKYF3AG4OOmX+c7SxRFWBI3M3gS6UgohQ7P1wzZlI6q Mcv0Cg55V9uCmuZIjNOqdy52RXsgC46gen51Aezsg9OJNMz9u2QaWnrWv4kQLMpSoI z0Tk/uwOGtOwnImqd1EsotzOrULk7L+TBw9RfSWgPcBBxIbnTQKzcc0QD+TZsBQqSO 5h4XG0O/7I7xZFt/1c1Pzblre21WxTy0jvLfZUoeKDAWfXHquTqD8Ab+5gJOqPjR3h mPqy9OJQjnOUqFyE+XU9WHr9w2C6tZ6+lWaET4RlA3bJLVzydtiesx33wTrL5gAGLF LdV5WUwwZTSdQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 71E3D67E74 for ; Mon, 29 Sep 2025 18:52:16 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2RhF0HUP0zbd for ; Mon, 29 Sep 2025 18:52:16 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193534; bh=nUnuQkweADJ2xdjPDsjxrzQ0noYj45fpl1BlrKIgJlw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Pd+7tgLwxbofT2y3/S0seNcgfFIsTnqRfe2sQoyxo6XViRThuPQPkS+zkiOJEJv/R HWfAdMGtMECLr/jdCbpTC29M8TA9t5CP1TWG9smOa8+g3BfbkjIrIkFve3gdS4sDWk S1uWMx0REjwyLW466bO4mBH9nfB3iGlOCKQ2rL7o6sRYxawQm1wc612dSV3qxUVs4z ELN4efB/35M0IRkOkeZR64g9vpIAvMqSvJBKuAeQZXA7eEPaxLweRQXb6EcKwB122E He8E+v6e5aYA3RJ5pMnxm24KR+BQz/lHyyYI14pppaHVYiNwwz4iJtuFmEjNn/whaB pu8KhJeLBvKYQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7045567E57 for ; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193531; bh=s964LfQ17sNehmyc5aNNBfEUPqLupQhkulQkXwo07Nc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OBkFQo9S4fUTJGf+p0kiHh8Ykndoyj6T5iwpLqIB42CQZLmp6mobfgegazFqJmmDd cAEkEMgcv7MifGWOjCeNy3O6jZzzAkki1DjX6Qmtcfw1jgrhO5fwVLkjO/PBLs19QT xLDyOz0VX/JB7mt4OyphP07te7iC4KD1Lnn7yNBsn2o5c0LubHO4KXe8AxtrHN37BZ ErYXCpMovp4BZYg3vYs/eYcZbqT+bOXGOI1rVVXbKeaGHv/eTpOjstz0MJg8tVXL8y 6QDLhdZFG/y18+aqKpKk7FiSObQfT/mugAgqwulQKXijnZ3x84KOv/OHJgGiQpJUIe xmWuQU05bhESw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7690D67E31; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id wOC2MqvGyZ7v; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193523; bh=rG+3HMPBhRS5z/Sh4kvEjZvN2eHJ4L7I6d5f8vo46uc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mNcmIopBZyaoAP7VIPeSUZQgUTdFmlDP01sfryB1h/hLI2HFci+ztv8sxzBeUPWGO +ndEg6HvxRREzt6/S7w2efWVbnSUvwE9903HkQHFVZ+Ywb90UKoMcypNYNvvelrLd6 bX2ODn9GCBimUO86xIidCJ7hqRSrVIvhicYed1UoZFU/7rQyvJADtZnFYqQOqfjDxD tip8MlcOlSq2olvYSuSVstS8XG2KRxzaw3x26n7A4MM8g6lxjEcbzApmLisXPvBFLM jiBkIC5RMgZdNmLZ7y8TAcg1cz0Eid4c/rqZJCtM+bhlVitboJ+NodcqfGcngUVnaG BQpqlhP2x2Q2g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 93F7D67B49; Mon, 29 Sep 2025 18:52:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:21 -0600 Message-ID: <20250930005137.3650600-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AJBRORDIA35ZXGC3SW6S6QIW2VOPS263 X-Message-ID-Hash: AJBRORDIA35ZXGC3SW6S6QIW2VOPS263 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/15] boot: Update first_glob_method when dropping a bootmeth List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass For now we only support dropping non-global bootmeths from the iteration. Update first_glob_method in that case and add a few checks that things are correct. Signed-off-by: Simon Glass --- boot/bootflow.c | 6 ++++++ test/boot/bootflow.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index 4e646202f3d..efe8aea765d 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -167,11 +167,17 @@ int bootflow_iter_drop_bootmeth(struct bootflow_iter *iter, iter->method_order[iter->cur_method] != bmeth) return -EINVAL; + log_debug("Dropping bootmeth '%s'\n", bmeth->name); + memmove(&iter->method_order[iter->cur_method], &iter->method_order[iter->cur_method + 1], (iter->num_methods - iter->cur_method - 1) * sizeof(void *)); iter->num_methods--; + if (iter->first_glob_method > 0) { + iter->first_glob_method--; + log_debug("first_glob_method %d\n", iter->first_glob_method); + } return 0; } diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 69a965dfa4b..7748a5ad534 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -521,7 +521,11 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* Try to boot the bootmgr flow, which will fail */ console_record_reset_enable(); ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); + + /* at this point the global bootmeths are stranded above num_methods */ ut_asserteq(4, iter.num_methods); + ut_assert(!iter.doing_global); + ut_asserteq(4, iter.first_glob_method); ut_asserteq_str("sandbox", iter.method->name); ut_assertok(inject_response(uts)); ut_asserteq(-ENOTSUPP, bootflow_run_boot(&iter, &bflow)); @@ -531,9 +535,13 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* Check that the sandbox bootmeth has been removed */ ut_asserteq(3, iter.num_methods); + for (i = 0; i < iter.num_methods; i++) ut_assert(strcmp("sandbox", iter.method_order[i]->name)); + /* the first global bootmeth is now down one place in the list */ + ut_asserteq(3, iter.first_glob_method); + return 0; } BOOTSTD_TEST(bootflow_iter_disable, UTF_DM | UTF_SCAN_FDT | UTF_CONSOLE); From patchwork Tue Sep 30 00:51:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 441 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193534; bh=bOiwz8cWht8R8j7By4jpeiyRz+Zm9wabdicsT3Enooc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=m4VVzTF+pU5VOR8uD6j/qLR1kIBbrl45fj4jCqD8HQ9SZ3IbMpfbLtA5MAXUnZsAg qm2zTStqVVAWcoQ3CXt2t8fBghCHeXXEDnmcgsSbGYfUb6Qh0W5G0zk5VffPQq3PWd skdvC7ocYxuFy3Yi4thYyCeih8pz1UwlcfmnU4Jh0ZNvivBGdWhVMzpKh7z+g25bZ5 UPPPAbDLURDVr3hHZ2BLawPlGehEaC5Yvz/ibPlUCCHbWVExlehbYAvGy7TLe/bQfr q7Jm5ffGsXgeXGCeP3eE+JKX6aMN1kRAWCS6CzK10GioJqsBv6fp4ohumermOJxsS4 vKQdbYeV6hb2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0EED367E59 for ; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id apchU5P1CVAx for ; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193533; bh=bOiwz8cWht8R8j7By4jpeiyRz+Zm9wabdicsT3Enooc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cJJ3LqNtACMqsB+6B9sXzPgdU+8oPhkCGz1Fd7bIv9Hw0v18/AQB3bUsRN6gmPDp2 gcU7poQSWExDxP6yOVIoH07KseuxDT4NQ2/5Bb9nzvh4y4SUZE23L0bMSQa4aPxGrS Oyt5ffZk58ekCn6lFTxzJs3I0GcQRjQ2NJ0n8lIc8qdPt0zxnP9h5Oi9/LjxMOM2VV nxM1tP5Il4sR5IvYS0qTZV/xdUXCj8aVe0v0jNhewX7Q65B07blFKzhSxad9lliHYT VQPVUdqiE1i8vTr1xairBMvUfq6NWWhyRDxw5fb+VW1UhOuj+nrPenOuhNOhFVqpgM tOv3hpFBJMQog== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F215067E31 for ; Mon, 29 Sep 2025 18:52:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193531; bh=M0CI2aAeqRLe6kDzWHmuYMUOS94aLb9IrcLYp3SJXxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVjHMpkP7UDB7l9WJPLZ322I8HaVMkPrKB1zHF6qxqRXajKXum+nhe9xCdrTwPm/1 94RgHBj9Ug+LlqddogStkT7ah1Kp6CQ5Tbe3R9s9sjTrihja+oW2p4ng4MMBJQO705 uD5C8kvD6/Cw+z3X088cxscY9G0jn5ot8JtRAdB5Dn52C3ga0v4n2yf43ZY/BV3osT PNwr34hCedOGdQ0X5cDg5sDgmEXq79L05NrJeb344RfwdhcNiSqjn8SR6pnT6P4yDq uUNHbXSmtZbkmkmGP8GsTJb6PJYCDRuPePs5WQB721oY6pnek9QunBnqTMerjvTbDU 51B3n/VG9DTXw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7692C67E57; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id lDY2uMY2Kzcb; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193528; bh=HIWiRA9chOokrUqb+3hfbruNw6Wm94a5qFZdkAXsFoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oCep1eA4DVnZb2Z7HMq45SQ6rooMUh6gf7tABpdSQ2ubiqdH+aSreYF2Zr1Lsg351 5s9tGddcGXvCv0OJhyVZhCfZ0bYaiOVY5mlParV75hODtqn41Kf/NabcaLjBzTAXAj L9HEUBQ6qn+6EqOepmPxfIb70ef4n3SrMB1MGWZAZGUrsFI5kZ0o1LEF/RD4t6nn9f LzFKd7e4YhO09iB9H2FOiqIGtJ4L9qQ+wUeQ1N3oPiB6BdYO1OeyUsMozQ3n80fo2e yL6MkZqokqPE9/HSOUTzFcod7E1svlc4HDayEqz0C8dHdR8UvjwEfZO5dYwE0gKtE+ is1W7U7y42+Rw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 34C9E67E00; Mon, 29 Sep 2025 18:52:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:22 -0600 Message-ID: <20250930005137.3650600-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XICTB64POEOLFWQM25YNROUFSN7OHYDQ X-Message-ID-Hash: XICTB64POEOLFWQM25YNROUFSN7OHYDQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/15] boot: Add a flag for whether there are global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The current 'doing_global' refers to being in the state of processing global bootmeths. Since global bootmeths are currently used once at the start, it becomes false once the last global bootmeth has been used. In preparation for allowing bootmeths to run at other points in the bootstd interation, add a new 'have_global' flag which tracks whether there are any global bootmeths in the method_order[] list. It is set up when iteration starts. Unlike doing_global which resets back to false after the global bootmeths have been handled, once have_global is set to true, it remains true for the entire iteration process. This provides a quick check as to whether global-bootmeth processing is needed. Signed-off-by: Simon Glass --- boot/bootmeth-uclass.c | 1 + include/bootflow.h | 2 ++ test/boot/bootflow.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 152c334f205..0147b97fcb0 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -197,6 +197,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global) iter->first_glob_method != -1 && iter->first_glob_method != count) { iter->cur_method = iter->first_glob_method; iter->doing_global = true; + iter->have_global = true; } iter->method_order = order; iter->num_methods = count; diff --git a/include/bootflow.h b/include/bootflow.h index 6f53a7d4991..0805d10e197 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -268,6 +268,7 @@ enum bootflow_meth_flags_t { * @cur_prio: Current priority being scanned * @method_order: List of bootmeth devices to use, in order. The normal methods * appear first, then the global ones, if any + * @have_global: true if we have global bootmeths in @method_order[] * @doing_global: true if we are iterating through the global bootmeths (which * happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev @@ -291,6 +292,7 @@ struct bootflow_iter { int first_glob_method; enum bootdev_prio_t cur_prio; struct udevice **method_order; + bool have_global; bool doing_global; int method_flags; }; diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 7748a5ad534..a18afad0f72 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -314,6 +314,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); ut_assert(!iter.doing_global); + ut_assert(!iter.have_global); ut_asserteq(-1, iter.first_glob_method); /* @@ -444,6 +445,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts) bootflow_show(0, &bflow, true); ut_asserteq(4, iter.num_methods); ut_assert(iter.doing_global); + ut_assert(iter.have_global); ut_asserteq(3, iter.first_glob_method); ut_asserteq(3, iter.cur_method); @@ -460,6 +462,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts) ut_asserteq(3, iter.num_methods); ut_asserteq(3, iter.first_glob_method); ut_assert(!iter.doing_global); + ut_assert(iter.have_global); ut_asserteq(0, iter.cur_method); ut_asserteq(0, iter.part); @@ -525,6 +528,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* at this point the global bootmeths are stranded above num_methods */ ut_asserteq(4, iter.num_methods); ut_assert(!iter.doing_global); + ut_assert(iter.have_global); ut_asserteq(4, iter.first_glob_method); ut_asserteq_str("sandbox", iter.method->name); ut_assertok(inject_response(uts)); From patchwork Tue Sep 30 00:51:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 444 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193543; bh=3VuwlgfmUISs48eVCBzyC+EkYZMHXEkRQK3n2z7ZO0w=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=VcHDqP8pN2MNwaFyWQT3PwJoqS4kRycQFP93FVvGjnhXvC5P7QiwfiRIvT3I3vtO8 jnnz/ixLs96jr7gArVbES1GDCDrDaT7aIFA29OlUGo8pSwlNbkXag8S0Fw9/1+cd3S 41T9ussV/3MwK6Hj3OmolLVJQvBlTPU45GcC5sznAn/2zyrS5g+01rUjVRWdiiSPvI /pd24KSSLVoJlUaNMMjOvQmKoWQ8WmfiIr6/k2Yqvoxt5mN5nT7F78jw0Ih7naJqzQ zk67WdszNRkRvkZWuVLkkMApv03mlE5sujlIjGkhtf8cEhAokKxQqL5oYsX6OgMffV yg0w9PWP33mFQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ECFC267E80 for ; Mon, 29 Sep 2025 18:52:23 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KVPpVeDZ3EP3 for ; Mon, 29 Sep 2025 18:52:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=3VuwlgfmUISs48eVCBzyC+EkYZMHXEkRQK3n2z7ZO0w=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=T2NwFdqMtn120nmQff0j4YN3wYBPgcAuOJqNZNqwHvng/mQyN8ozXLILPe2Ka1d9X rObAou4RAp5vKAlF3G/WvJQ4Y8CeRDBd6rXpi1rHSm4npxb8RWDwbJ8kZIKiSW1w/C BZ0YFOk85yk6lsUcI9nHdkTJE7BE2w9DAsWhov2C5/NM0kwqkeSVtncTePaXtit0aF y7Z/oVi9j+sYYcXuBcauERySrh6Pj2E5OhNVRWcLr27iK7t14UWxO8Xqr2mJI2emCY eyRIDSbMtn58qrRMHac1OBxE4fCtxdj1vFO9Q8/SdmU7hFTHASGeue3GwdwAH41+uh 9aCb5k9r1Fksg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E968967E59 for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193538; bh=54FAyOOnZGhiA/DW2vIRg2gZCFm3znHo6IBECYPbxc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eNlMQlFF24UikBueCXBq3VJxjiaWBzPAvYPaSvNFY/Kktc6XIrgSUFtLG0lX0TTQE xvdb1GY+B1P1m4ecn8hQw3/V92O2tYGe1MuWDChIaKPhWCgwuhvAGxhwaqlAipq4jZ MSoOkaNQFx+vJzCcDw05yeP8q0IQl8k3fHcH7wftjFdawh4IV8FyezGIaBEJldehrG F0/IG0w/zDQXEpzeBonfrKLaWwOmz7QOub3oHAulxECZRETQiXkCDqu+3KRlY6lcD/ IkwSUu60TH3XJqJftjWISa9oWWXMS5DT3LRdvJu4nJk9H3WvEoqL57g/DDaNIVzy5b ++CLXY/PatzNg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D4FA867E31; Mon, 29 Sep 2025 18:52:18 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id gYnNII7NO8Px; Mon, 29 Sep 2025 18:52:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193530; bh=LgYW+dZp4dpcUU4pxFrVJXM94yrcCpMmNnNU6PUBUbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qU0bWUhcb4XDqX6Q6JHsP7Eu6YZyf/LQ10kPslQzTplT67iBGbBCQVPyYgTVaPd1t z5IQgXTBvqcDbp2jr+AfY6glvRkEJ7PEOfj0EYqAKkeD7BBbahdNUL/QrvuXFmn20H 3DondGF695VaSd4pz9BMmwzux3dUJk0hyuSpyDVMLPb1+QwzCwe02jybSudVBHUCQC oErNIxf6Fv/4nzW54l1ly/Lgn7QmjCdsHbYkZb+WGoJX9tHklNCPlLL7fZLrdlhaKZ AY+CmvYPci3Q1HUTzn4xCC4dzi64a4L6nc1sUtEOCkFEvkh2vYmPySFeNJ9g6buOFa eqLaZeZmtRBYA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 476D967E03; Mon, 29 Sep 2025 18:52:10 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:23 -0600 Message-ID: <20250930005137.3650600-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: AZ722RBFMCYFCUT5Z3K7NBEZT2L2VFHC X-Message-ID-Hash: AZ722RBFMCYFCUT5Z3K7NBEZT2L2VFHC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 07/15] boot: Keep track of which bootmeths have been used List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add a bitfield which tracks when bootmeths have been used. This will be needed when global bootmeths can be used later in the iteration. Fix a missing bootflow_free() while here. Signed-off-by: Simon Glass --- boot/bootflow.c | 13 +++++++++++++ boot/bootmeth-uclass.c | 10 ++++++++++ include/bootflow.h | 8 ++++++++ test/boot/bootflow.c | 8 ++++++++ 4 files changed, 39 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index efe8aea765d..6f5876548b2 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -18,6 +18,10 @@ #include #include +/* ensure BOOTMETH_MAX_COUNT fits in method_flags field */ +static_assert(BOOTMETH_MAX_COUNT <= + (sizeof(((struct bootflow_iter *)NULL)->method_flags) * 8)); + /* error codes used to signal running out of things */ enum { BF_NO_MORE_PARTS = -ESHUTDOWN, @@ -491,6 +495,10 @@ int bootflow_scan_first(struct udevice *dev, const char *label, bootflow_iter_set_dev(iter, dev, method_flags); } + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) { + iter->methods_done |= BIT(iter->cur_method); + log_debug("methods_done now %x\n", iter->cur_method); + } ret = bootflow_check(iter, bflow); if (ret) { log_debug("check - ret=%d\n", ret); @@ -518,6 +526,11 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) return log_msg_ret("done", ret); if (!ret) { + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL)) { + iter->methods_done |= BIT(iter->cur_method); + log_debug("methods_done now %x\n", + iter->cur_method); + } ret = bootflow_check(iter, bflow); log_debug("check - ret=%d\n", ret); if (!ret) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 0147b97fcb0..d71e4f001f1 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -199,6 +199,16 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global) iter->doing_global = true; iter->have_global = true; } + + /* + * check we don't exceed the maximum bits in methods_done when tracking + * which global bootmeths have run + */ + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && count > BOOTMETH_MAX_COUNT) { + free(order); + return log_msg_ret("tmb", -ENOSPC); + } + iter->method_order = order; iter->num_methods = count; diff --git a/include/bootflow.h b/include/bootflow.h index 0805d10e197..051158780e6 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -12,6 +12,7 @@ #include #include #include +#include struct bootstd_priv; struct expo; @@ -226,6 +227,10 @@ enum bootflow_meth_flags_t { BOOTFLOW_METHF_SINGLE_UCLASS = 1 << 3, }; +enum { + BOOTMETH_MAX_COUNT = 32, +}; + /** * struct bootflow_iter - state for iterating through bootflows * @@ -273,6 +278,8 @@ enum bootflow_meth_flags_t { * happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev * (enum bootflow_meth_flags_t) + * @methods_done: indicates which methods have been processed, one bit for + * each method in @method_order[] */ struct bootflow_iter { int flags; @@ -295,6 +302,7 @@ struct bootflow_iter { bool have_global; bool doing_global; int method_flags; + uint methods_done; }; /** diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index a18afad0f72..af7f7391160 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -316,6 +316,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_assert(!iter.doing_global); ut_assert(!iter.have_global); ut_asserteq(-1, iter.first_glob_method); + ut_asserteq(BIT(0), iter.methods_done); /* * This shows MEDIA even though there is none, since in @@ -324,6 +325,7 @@ static int bootflow_iter(struct unit_test_state *uts) * know. */ ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + bootflow_free(&bflow); ut_asserteq(-EPROTONOSUPPORT, bootflow_scan_next(&iter, &bflow)); ut_asserteq(3, iter.num_methods); @@ -333,6 +335,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("efi", iter.method->name); ut_asserteq(0, bflow.err); ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BIT(0) | BIT(1), iter.methods_done); bootflow_free(&bflow); /* now the VBE boothmeth */ @@ -344,6 +347,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("vbe", iter.method->name); ut_asserteq(0, bflow.err); ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BIT(0) | BIT(1) | BIT(2), iter.methods_done); bootflow_free(&bflow); /* The next device is mmc1.bootdev - at first we use the whole device */ @@ -355,6 +359,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BIT(0) | BIT(1) | BIT(2), iter.methods_done); bootflow_free(&bflow); ut_asserteq(-ENOENT, bootflow_scan_next(&iter, &bflow)); @@ -365,6 +370,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("efi", iter.method->name); ut_asserteq(0, bflow.err); ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BIT(0) | BIT(1) | BIT(2), iter.methods_done); bootflow_free(&bflow); /* now the VBE boothmeth */ @@ -376,6 +382,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("vbe", iter.method->name); ut_asserteq(0, bflow.err); ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BIT(0) | BIT(1) | BIT(2), iter.methods_done); bootflow_free(&bflow); /* Then move to partition 1 where we find something */ @@ -418,6 +425,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); ut_asserteq(BOOTFLOWST_MEDIA, bflow.state); + ut_asserteq(BIT(0) | BIT(1) | BIT(2), iter.methods_done); bootflow_free(&bflow); bootflow_iter_uninit(&iter); From patchwork Tue Sep 30 00:51:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 443 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=3hUfdFjTeMvoFKaIfatcJKgsZl57S7yxxzYD5jSFv5I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BE/FEtxImfMO0e3IrwfIFe2exw6REniWTFekcTwhy5Kf5Uw3da7IsqnTGto/Tk1c5 LMQ+I6p4h8Se8j06qZqpeeLzt7AeBNTQZORDZiIc3DauvgOg8EoMi22koU0JtRfcRI dJ2xiY6r992SaEVh0RXIpjQ/HibkSVVhw7bXC4VEUmbgnjVBSfp9UvosZVE+sihph1 Lm3kY8GRbt2lkkRDBwxsJ5Y2ctxzaJ1SR+08lvehumC8hPIPewqnSH6t4kHl/BXSqK SRv1VuFpGoUylRluRjvH/T6p+IuaQiLqwHFUW5g7Kg80xxq2TqxCoy55vy0rJt/kdJ sO56kQuJS5yag== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3209F67E31 for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4xXWyeF0KcNe for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=3hUfdFjTeMvoFKaIfatcJKgsZl57S7yxxzYD5jSFv5I=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BE/FEtxImfMO0e3IrwfIFe2exw6REniWTFekcTwhy5Kf5Uw3da7IsqnTGto/Tk1c5 LMQ+I6p4h8Se8j06qZqpeeLzt7AeBNTQZORDZiIc3DauvgOg8EoMi22koU0JtRfcRI dJ2xiY6r992SaEVh0RXIpjQ/HibkSVVhw7bXC4VEUmbgnjVBSfp9UvosZVE+sihph1 Lm3kY8GRbt2lkkRDBwxsJ5Y2ctxzaJ1SR+08lvehumC8hPIPewqnSH6t4kHl/BXSqK SRv1VuFpGoUylRluRjvH/T6p+IuaQiLqwHFUW5g7Kg80xxq2TqxCoy55vy0rJt/kdJ sO56kQuJS5yag== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2035B67E03 for ; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193538; bh=8n8ZPmZdBJxJvKR7sR8bMH7mB2i8kpC6J3tPH/DKpt8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DiMK5pIUXeZlmXbkrGxcu6JOwM6vvZZ3fmLDsS0cShSYOR0CXO2VhuGFbJkqDS4K9 ogyL+qqhiM9tExD+OJKaUru72np06UnoL/YZWC3SSKnFuwYe4HE41ZG2XGaxVeSOVv /6e0NjDlcNmEk4noBqtuLqvjXL29fEq7pZux05H4ALYJQq2bsYUaPJIl2Xg+H3Ljt9 gBk2dkoY9ZED8JUvMfp2Ih6Qw8jQ2vieQFAvfGW+5J1WYr2R3FBjUjTvsQTaeld3z+ 1lzvcteQotFGHWfsfnAPachEk0fb4ZnM7LZyYhPmTglZdnI3jLN9oM9SonDZtm2MiG anXC46Rhby3qQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D2EBB67E15; Mon, 29 Sep 2025 18:52:18 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id qYoy__TqMv69; Mon, 29 Sep 2025 18:52:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193535; bh=+zFH0FxvOIUcLqkv4lR/8h80mBVBdEbdq9ZjLShIkN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dox273xZoqg4CHQEmeVK0g0DUO/0sDYpFJVYDe6iEgqBXiEeGsCfvecaBdrFPcSei s2NfRpLsA+Ui1fVoz9BDyNzxDWblGLKMAFe4yj1srJZZ7K6fkJQPvFCFdqfLH4j/zs HZ/meFybUpbKX7j39UWiqQM4gUWFsOnX4wrp0CqFJ9T3sNJgRb0NxNj5fk6vKI4kRT MrPr+CW/Wg75zsOvHVSKz9z5cELKSDA6lpT6GbIZ0d7VfxXQDD9O26ozY81KA+5Y7u 214rjlFeahHoZjm3hb8KNZazVjqB1xe5bqFRi/iWG5mEeox/aB7EBZ/VtDhzPhxPhi 3o3+U4vY2nFbg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E632667E5B; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:24 -0600 Message-ID: <20250930005137.3650600-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: QM4SDVH5GZYIX77XTNP7BMCUII6PKR4T X-Message-ID-Hash: QM4SDVH5GZYIX77XTNP7BMCUII6PKR4T X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 08/15] boot: Move preparing bootdev into a function List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The code at the end of iter_inc() is already somewhat tortuous. Before making it worse, move it into a function. Signed-off-by: Simon Glass --- boot/bootflow.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 6f5876548b2..a91d76c6baf 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -245,6 +245,32 @@ static void scan_next_in_uclass(struct udevice **devp) *devp = dev; } +/** + * prepare_bootdev() - Get ready to use a bootdev + * + * @iter: Bootflow iterator being used + * @dev: UCLASS_BOOTDEV device to use + * @method_flags: Method flag for the bootdev + * Return 0 if OK, -ve if the bootdev failed to probe + */ +static int prepare_bootdev(struct bootflow_iter *iter, struct udevice *dev, + int method_flags) +{ + int ret; + + /* + * Probe the bootdev. This does not probe any attached block device, + * since they are siblings + */ + ret = device_probe(dev); + log_debug("probe %s %d\n", dev->name, ret); + if (ret) + return log_msg_ret("probe", ret); + bootflow_iter_set_dev(iter, dev, method_flags); + + return 0; +} + /** * iter_incr() - Move to the next item (method, part, bootdev) * @@ -389,18 +415,10 @@ static int iter_incr(struct bootflow_iter *iter) } log_debug("ret=%d, dev=%p %s\n", ret, dev, dev ? dev->name : "none"); - if (ret) { + if (ret) bootflow_iter_set_dev(iter, NULL, 0); - } else { - /* - * Probe the bootdev. This does not probe any attached - * block device, since they are siblings - */ - ret = device_probe(dev); - log_debug("probe %s %d\n", dev->name, ret); - if (!log_msg_ret("probe", ret)) - bootflow_iter_set_dev(iter, dev, method_flags); - } + else + ret = prepare_bootdev(iter, dev, method_flags); } /* if there are no more bootdevs, give up */ From patchwork Tue Sep 30 00:51:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 445 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193544; bh=0MwrCvZShBFk6jR7/Y4yXP7o/1cbryBPQFKRNIdp5rw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RJEEOr0sHwLORZqmXhOuBZMw5nb5AGi2ZhCm3ZZ5UCOrpkymQ8s2CZxDSnvQioKOK yBsdEDP+GWQCNs1Oj6rS+P/vUlPFWv5bi15ivqlbmFJ+Jkn69vNTt2NkW0CyXjNLWW CZ9pNRqIr/077WL2EmdJz0pKWJrOa/Bn1jl+oZdQJp43iK36e4bsZneQYQD48EQOzG +vpROq48LYwUh2wlUhZ9NUB+MTHiUG7t2u/1/j0YtWRkpkh1ciPw871P5OcaQh3NF7 NsG2oX2p+ukpiSeX7jL7uH6fhmSoKTxL7SWEQRnslpNfLwdH9j73Es9iIckkna4UdN PI16qvqakoIag== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4F45767B49 for ; Mon, 29 Sep 2025 18:52:24 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id YSV0ts9Ulqer for ; Mon, 29 Sep 2025 18:52:24 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193543; bh=0MwrCvZShBFk6jR7/Y4yXP7o/1cbryBPQFKRNIdp5rw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=vOrSdiHnYYJ5T26SqJNgadHljLFD31Ao7IDB6MBYxGyuaBVb2kEiIfIk3RVyWCdVt IUzjNUHRBCg/xtOTHiAoaMi8NFeppxsP5UsTtkeifQkSlL+gUItG+NoD7TVIFq3SFO ZVn3SPtUyQlEu1/QZtQSF4FHCgMaDsb5nUxeUBIvA31FZ9q2p4ueMFdHDg6SvcpGcQ YONozefy+ou1YQLT+GjDfkbg68y1vivK6slMkIZeWmKP/vvS805lJf8Z3IgLeLw4qo f5BF5ArVsREtHLQj02opuPdnuB0x5pLORI2vV9efeAITVQCpl+W3B1XirtRnXBaTS9 RO0v+cPbITTjg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4FA7C67E58 for ; Mon, 29 Sep 2025 18:52:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=vQinVZCCMnRhJJQuOm4AdRaAcoQpB1zbCVHGom4bOLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HZV9bW91pc6LbP1nvB04oEg1qXzv/TEqtXL7zymFl+GJMwePBa0ou4Rh20+A4EOfk fr3m7DQ+Qdey2og5gmv7QauWjUP9TEZum8IHiVlOzd6EFcoNcWIzPo7bqRhiaykcmv LbjOwCsOEDwbEgeh/klTDHGdSfAZI6oxJAH3qnT+OQnl79IcIb6yDO2SQCRdkvjmb4 bC2iHXN63lDN9IaSD8NRx2pMI3kYZ8wopXnE3LijBbT4aU0GhIY7r8/7ifsyfGpyCa 3Igut6KfEkE1HtG9RrR8h/UW5A7YYU2hYW5etnB81OuORY7rWkESESs52/hVS4nk5P nPF1S4hsDOhyA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3786667E03; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id g7LuNzMDVb1m; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193537; bh=aso+vnYCqItWVL5dpKnfPdEiJAuMJ9XGVySDednTpRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ptf35RnVJ+BE0z8unnQVZDUsvp5LB1t+r1a/sgNXN2KopkgMkRx70L5ODys42bb8m 2ba2SiPI9ujSXZV6N2MGbd14tP5GoeAYp+M8DxvteK2VJKWz7YhjWREbnk98xYPvN4 JDQkwmFRQEf/31XPEkjLvWlUs7BFwvctUXIlSVHzyud6Nonlps99PD8bzGGV4VMS/R jdwA6Wp8ZKeHhonnrc7AJGVqRl+rNShJF/wFobivVn+MJSpc/UMSRDC0p1qKsmx1jY AP5uIa5KYTLDOREN8TurTiSvHCP5n3F7+KKfDvmoSZuYUTRt3Q9TfTI2+Rjxp4C3lC bQh98R0mu182Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D75BA67E59; Mon, 29 Sep 2025 18:52:16 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:25 -0600 Message-ID: <20250930005137.3650600-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: HSFORPN3Z3E3DLMLGOTDKIMGKOBE6KJQ X-Message-ID-Hash: HSFORPN3Z3E3DLMLGOTDKIMGKOBE6KJQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/15] boot: Support rescanning the global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add the logic to scan through the global bootmeths for every new bootdev, in preparation for allowing global bootmeths to select where in the hunter ordering they go. Use a new bootmeth_glob_allowed() function to check if a bootmeth is allowed, ensuring that each can run at most once. For now this has no actual effect, since the global bootmeths are unconditionally processed at the start, with iter->methods_done being updated to include all of them. Therefore when scanning again, no unprocessed global bootmeths will be found. Signed-off-by: Simon Glass --- boot/bootflow.c | 90 ++++++++++++++++++++++++++++++++++++++++++++-- include/bootflow.h | 5 +++ 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index a91d76c6baf..51e6ad6dd86 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -245,19 +245,81 @@ static void scan_next_in_uclass(struct udevice **devp) *devp = dev; } +/** + * bootmeth_glob_allowed() - Check if a global bootmeth is usable at this point + * + * @iter: Bootflow iterator being used + * Return: true if the global bootmeth has not already been used + */ +static bool bootmeth_glob_allowed(struct bootflow_iter *iter, int meth_seq) +{ + struct udevice *meth = iter->method_order[meth_seq]; + bool done = iter->methods_done & BIT(meth_seq); + + log_debug("considering glob '%s': done %d\n", meth->name, done); + + /* if this one has already been used, try the next */ + if (done) + return false; + + return true; +} + +/** + * next_glob_bootmeth() - Find the next global bootmeth to use + * + * Scans the global bootmeths to find the first unused one whose priority has + * been reached. If found, iter->cur_method and iter->method are set up and + * doing_global is set to true + * + * @iter: Bootflow iterator being used + * Return 0 if found, -ENOENT if no more global bootmeths are available + */ +static int next_glob_bootmeth(struct bootflow_iter *iter) +{ + log_debug("rescan global bootmeths have_global %d\n", + iter->have_global); + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->have_global) { + int i; + + /* rescan the global bootmeths */ + log_debug("first_glob_method %d num_methods %d methods_done %x\n", + iter->first_glob_method, iter->num_methods, + iter->methods_done); + for (i = iter->first_glob_method; i < iter->num_methods; i++) { + if (bootmeth_glob_allowed(iter, i)) { + iter->cur_method = i; + iter->method = iter->method_order[i]; + iter->doing_global = true; + iter->dev = NULL; + return 0; + } + } + } + + return -ENOENT; +} + /** * prepare_bootdev() - Get ready to use a bootdev * * @iter: Bootflow iterator being used * @dev: UCLASS_BOOTDEV device to use * @method_flags: Method flag for the bootdev + * @check_global: true to check global bootmeths before processing @dev * Return 0 if OK, -ve if the bootdev failed to probe */ static int prepare_bootdev(struct bootflow_iter *iter, struct udevice *dev, - int method_flags) + int method_flags, bool check_global) { int ret; + if (check_global && !next_glob_bootmeth(iter)) { + iter->pending_bootdev = dev; + iter->pending_method_flags = method_flags; + return 0; + } + /* * Probe the bootdev. This does not probe any attached block device, * since they are siblings @@ -308,6 +370,30 @@ static int iter_incr(struct bootflow_iter *iter) iter->num_methods = iter->first_glob_method; iter->doing_global = false; + /* + * we've come to the end, so see if we should use a pending + * bootdev from when we decided to rescan the global bootmeths + */ + if (iter->pending_bootdev) { + int meth_flags = iter->pending_method_flags; + + dev = iter->pending_bootdev; + iter->pending_bootdev = NULL; + iter->pending_method_flags = 0; + + ret = prepare_bootdev(iter, dev, meth_flags, false); + if (ret) + return log_msg_ret("ipb", ret); + + iter->cur_method = 0; + iter->method = iter->method_order[iter->cur_method]; + + log_debug("-> using pending bootdev '%s' method '%s'\n", + dev->name, iter->method->name); + + return 0; + } + /* * Don't move to the next dev as we haven't tried this * one yet! @@ -418,7 +504,7 @@ static int iter_incr(struct bootflow_iter *iter) if (ret) bootflow_iter_set_dev(iter, NULL, 0); else - ret = prepare_bootdev(iter, dev, method_flags); + ret = prepare_bootdev(iter, dev, method_flags, true); } /* if there are no more bootdevs, give up */ diff --git a/include/bootflow.h b/include/bootflow.h index 051158780e6..5ef0f4b61d3 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -280,6 +280,9 @@ enum { * (enum bootflow_meth_flags_t) * @methods_done: indicates which methods have been processed, one bit for * each method in @method_order[] + * @pending_bootdev: if non-NULL, bootdev which will be used when the global + * bootmeths are done + * @pending_method_flags: method flags which will be used with @pending_bootdev */ struct bootflow_iter { int flags; @@ -303,6 +306,8 @@ struct bootflow_iter { bool doing_global; int method_flags; uint methods_done; + struct udevice *pending_bootdev; + int pending_method_flags; }; /** From patchwork Tue Sep 30 00:51:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 446 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193548; bh=jD7lceN8BHLZuVDOf1Nj7HXUcKXwZyqVV4+3VgbeB+o=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eApj057/Lc38ZIEBAfAj4NNvzbOBc0qQSVeYJTgZrJZb5Apfd7nZK9gI5pKshx1Uw makfqV+yZkI5K4f2EsHT1jVW0Ya6EOv3h+GTBGt3Sg89Ceqr5Rg9LkNgfqDBSfPIfJ 4RwIj39rgGpSxnd15WNvuVZWPChvQqyIVEhQcWNa+b10mgzz2AEZ1OgNro2r8rZY0j ze/9gGnid7Pu4cxoQlvIOb1lFf5uFS1/OYJDbqFuKeP7bQooT/ig2T8cOs0yi4HOK7 RLBZgChaiTv6WiFDO05+dOlI68PLIMD/d8+njAVumi3jOIxIz15QIlO0DZJUnk8pcX 8Ipt+m1Nd0o3Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F2A7C67E5B for ; Mon, 29 Sep 2025 18:52:28 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 2D-2JcZ5jdcv for ; Mon, 29 Sep 2025 18:52:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193548; bh=jD7lceN8BHLZuVDOf1Nj7HXUcKXwZyqVV4+3VgbeB+o=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eApj057/Lc38ZIEBAfAj4NNvzbOBc0qQSVeYJTgZrJZb5Apfd7nZK9gI5pKshx1Uw makfqV+yZkI5K4f2EsHT1jVW0Ya6EOv3h+GTBGt3Sg89Ceqr5Rg9LkNgfqDBSfPIfJ 4RwIj39rgGpSxnd15WNvuVZWPChvQqyIVEhQcWNa+b10mgzz2AEZ1OgNro2r8rZY0j ze/9gGnid7Pu4cxoQlvIOb1lFf5uFS1/OYJDbqFuKeP7bQooT/ig2T8cOs0yi4HOK7 RLBZgChaiTv6WiFDO05+dOlI68PLIMD/d8+njAVumi3jOIxIz15QIlO0DZJUnk8pcX 8Ipt+m1Nd0o3Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E1A5767E58 for ; Mon, 29 Sep 2025 18:52:28 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193546; bh=krZaiCTYpJCX38LorIpMPlhm07DI+0A7hl/ixa54i64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fB7nm4yk8t32hS7D+AVhtEIDWH3cVog3EL844ya9BTPs4OHYKPcmFnx9wqZ269Ru3 CS0IAyJ7JuFlH6oWVfiA9GERBunSuJH0s87tG3CSk0H5oJflNRk5NH/Hp7AsHrn6wW D/h5dJxqh0osyzT/feCohrq3a+mZNNLtMzuSxBaZVM4xBkzrW1d2Cr2x7m3Hs0oOZr KnbEZc6J1Ok8nYDEAoD7EIk117/+YsQ4oX6HBcEzcJXiXSS/EHxaoCOvujPwSIquqW jBj1tXzuYBAW/IUtDRyjo8LZTMeP242OJ8fbP2oX5aMPl3VVRVxhDTGqXSdYQTrNs5 M60VIulu4PaiQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BBF9167B49; Mon, 29 Sep 2025 18:52:26 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 1C2oeVrbroQb; Mon, 29 Sep 2025 18:52:26 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193541; bh=8AynTbhHhZbGBLi29FbpI2I9Jn9F02dGw83Triy9T18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UA7F2g/brgFbfk9s0dlZq9WUGj9q6AjsGO4sj7q14u81jE12Ldh16mkalXv6WJ5bi J4Bytgw+BRCy957CSUNarJfvOse+lx4edZ2qBWSeEJZ02x0B5JAX1jsl0e/bZ+nAVe lJVJHl4C8nyqaZ2YHo7oCIywShvagPyka8/XhHlZroBJGwR/EeDZUZh9W7ekX3KEDg 8kL3mtgv4HSn5t8L3XrMez6Nx04z6uG64JVVdc2a699gAubulzsty0kqadWMoVhQGH h3XlKaRYkfG/iLoVs6QiGytwlynGmcxxflieIPmtg3CPZaIsvnXvmmZZ5oqxVy6DpS OPgMnkoT3/u3g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 774A267E57; Mon, 29 Sep 2025 18:52:21 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:26 -0600 Message-ID: <20250930005137.3650600-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DKQVD7OJLXIMSUQXFDVSJW2YNU2AAJXR X-Message-ID-Hash: DKQVD7OJLXIMSUQXFDVSJW2YNU2AAJXR X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 10/15] boot: Only run global bootmeths once each List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Use the methods_done flags to make sure that each global bootmeth is only used once. For now this has no effect, since they are all processed at the start. Signed-off-by: Simon Glass --- boot/bootflow.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 51e6ad6dd86..d6c396e3087 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -354,7 +354,13 @@ static int iter_incr(struct bootflow_iter *iter) } /* Get the next boothmethod */ - if (++iter->cur_method < iter->num_methods) { + for (iter->cur_method++; iter->cur_method < iter->num_methods; + iter->cur_method++) { + /* loop until we find a global bootmeth we haven't used */ + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global && + !bootmeth_glob_allowed(iter, iter->cur_method)) + continue; + iter->method = iter->method_order[iter->cur_method]; log_debug("-> next method '%s'\n", iter->method->name); return 0; From patchwork Tue Sep 30 00:51:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 447 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193551; bh=7hCjhQMf60w1BTQPeYAMEQhDAnqym6eiuyCIdouxjiY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=g9JjxHeeSWfMRzf8J3lZ+qxu3oFA1Jaz5Pi3cbbftnDno6ATjh5uxbnGw+T5SvBD/ 2kKxYPfTfN6tH9E1yKx7MGdd3m++ho0CyiiOR2MEYG8m/wAuhLY1l3fB1ZKsTsLYg0 ckwr7PqJjeVTxI6xzW+BZ7W49+TgSDwgefzaPTuRRrbJIqBYBnGZRuPOL0pXgEyuLr 56FwoaqyuBPOemG6vWSrFf1DQkm1wxO/QBUmWceOYhCN5Y+LYdEiYDYj9t7pNYzOth ujI2Qt5ATmEbB3u+jGqni8VZ1fuUeEcWPv7yoim/UkxIegi8sGSwQIDWjAELxW0/EH P1eUXPFkIgajA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 688CD67E00 for ; Mon, 29 Sep 2025 18:52:31 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id IXo49FMjcosK for ; Mon, 29 Sep 2025 18:52:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193550; bh=7hCjhQMf60w1BTQPeYAMEQhDAnqym6eiuyCIdouxjiY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=b0EKAmztwRCuA7yM3838MssGur2H2SvhBXsgcPzclozl+BUHRYLQGEMwAV/61xdwS bYKd4E8Jv2jxKcLL46SaDrfcsrp6cq9KPAQ6B/bS4tkvfyVBNhJH2mrcmmrnRXzZXM skNnW51jbty0Rq152lMq32+AQz7RyVpnZXhTZ8EA9HvsUGPeXTTw/b5WHADd1GDAVj AuIRxftNTy+/MFKMSnpGRHVIMh9lVxHl91CZVUDvfg16DCSlQFCs1XC4l1xc9dlnRC 5kI9IgRHMdlPCxhp9xK8aqJVVr2cMOM35Mx6MxtNwjX583LpdFcYhJndbGJBhUb+ub stKmj2wb7P/sQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 530D767E59 for ; Mon, 29 Sep 2025 18:52:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193547; bh=eh0nNHu0D7/ehklZM2spfhYat50pVgW8MSTAdmJRk00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=upsRKS33LECjay3xy9fkZ527rUB3/cDmu0Mm1CcyQQFD/hydiMIjxPz9WiKTqNZOU JbflYrK5YCBbcN5bJLUk9wBzrjD4GigmstPqBHi1L96YC2tPuvbYM1N0aCK3+ylbMG bzjJ+YzdckeKHB68VWZRAiw/3aWIsmwYrOo3yD8q894dUvWouZDkdkTPiCdU8aZYzm uW37vHKMKCtQpN6FG4YwdHnLwGxuKc+nniVUSsOJzDYmgCG9R9p8JIiWIRIeX4ZDJj NPKKDtm4yIWYWLtk2WfLtghDZTPRlX+Jrm87GWZiOeoMJclZHvY+PZ0jH1gHvXyfqL MvyvqRNtvSu4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CA9DF67E00; Mon, 29 Sep 2025 18:52:27 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id teyFL3oBp4ku; Mon, 29 Sep 2025 18:52:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193543; bh=I9B80UpkNtAN+FSL4lBh/oebU7Wj4pay5mMBOtu8Ks4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgejrlhWT9i8NwrkX0Arorjbp5MKL1bHG/0N8X/G+E3wxcY59FmJ/IXtbYP9/ld1N hWU4IaeSUYJ1LxMEV+oIxvCTNKZ2gaZI0o3Sz20+LXrn6z+eF/AnvQGoM4YFV7fEt1 NXHzjz08CIPFh+gwdsIUXm3Zu1aAlGkpityVwa9p108bsVC/foB8aF7q1Bk+fD/Z1M VItLaqR2SXCeovlnhUQFV/XuG4AgIQ+GEKGIEyqafuokjfYsOpgAiD0oQsmfVpf/zP RKE51zt7ckGf4h8lYFlFndgmv529YDXm1SsWD5PgXCnhwJADH96lSNhWBeH69gCzPS kYcGkK9kK/gNg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7FCE967E7D; Mon, 29 Sep 2025 18:52:23 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:27 -0600 Message-ID: <20250930005137.3650600-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3CCEKZO6VRWSDZ5HV2VJ4KGNHW372JC7 X-Message-ID-Hash: 3CCEKZO6VRWSDZ5HV2VJ4KGNHW372JC7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 11/15] boot: Implement a priority for global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Allow bootmeths to select when they want to run, using the bootdev priority. Provide a new bootmeth_glob_allowed() function which checks if a bootmeth is ready to use. Fix a comment in bootflow_system() which is a test for global bootmeths. Signed-off-by: Simon Glass --- boot/bootflow.c | 15 +++++++++++---- include/bootflow.h | 2 +- include/bootmeth.h | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index d6c396e3087..becb2ef109f 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -249,17 +249,24 @@ static void scan_next_in_uclass(struct udevice **devp) * bootmeth_glob_allowed() - Check if a global bootmeth is usable at this point * * @iter: Bootflow iterator being used - * Return: true if the global bootmeth has not already been used + * Return: true if the global bootmeth has a suitable priority and has not + * already been used */ static bool bootmeth_glob_allowed(struct bootflow_iter *iter, int meth_seq) { struct udevice *meth = iter->method_order[meth_seq]; bool done = iter->methods_done & BIT(meth_seq); + struct bootmeth_uc_plat *ucp; - log_debug("considering glob '%s': done %d\n", meth->name, done); + ucp = dev_get_uclass_plat(meth); + log_debug("considering glob '%s': done %d glob_prio %d\n", meth->name, + done, ucp->glob_prio); - /* if this one has already been used, try the next */ - if (done) + /* + * if this one has already been used, or its priority is too low, try + * the next + */ + if (done || ucp->glob_prio > iter->cur_prio) return false; return true; diff --git a/include/bootflow.h b/include/bootflow.h index 5ef0f4b61d3..351a6539978 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -275,7 +275,7 @@ enum { * appear first, then the global ones, if any * @have_global: true if we have global bootmeths in @method_order[] * @doing_global: true if we are iterating through the global bootmeths (which - * happens before the normal ones) + * generally happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev * (enum bootflow_meth_flags_t) * @methods_done: indicates which methods have been processed, one bit for diff --git a/include/bootmeth.h b/include/bootmeth.h index a34bfc91dd5..b5288843d03 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -30,10 +30,14 @@ enum bootmeth_flags { * * @desc: A long description of the bootmeth * @flags: Flags for this bootmeth (enum bootmeth_flags) + * @glob_prio: Priority for this bootmeth. If unset (0) the bootmeth is started + * before all other bootmeths. Otherwise it is started before the iteration + * reaches the given priority. */ struct bootmeth_uc_plat { const char *desc; int flags; + enum bootdev_prio_t glob_prio; }; /** struct bootmeth_ops - Operations for boot methods */ From patchwork Tue Sep 30 00:51:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 448 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193553; bh=Or4rQv8gYhWYv7bVaKk6p0WoSEPOK4yeZM4jhumpPNg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eaFkABg498gaei9Ggd/ZB7MvdYvvsClsBwcdFYbteUbhanGAfFpWHLpPuGbM0BHFM TeCzJSkyYwY4X1x71yR0zeriJ/fAGIp0+rivG+ki+hQMHm0xnKkrsBxmVRFhd8Gf8X oCCaZaIfxDrb6c+4RoSatqHDoM00+1Cr6zCeRC79OZy44adXoxv2O7DArWceovLL8o qaGNJ3OB5YfLwsDNljbZYPDwcBSlJjY2bdtQ5CM6KyrC8O3+NdzdEEyZtpFYguyzzF gkj2qu/cCGOggw7V/a74QwEoL3YDbhqHa56zumixcK5lkxR0H3GJ+R3uynlmXbwWoa NqgFfLsbGS9iQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A51A067E5E for ; Mon, 29 Sep 2025 18:52:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id D10yAT65lpEq for ; Mon, 29 Sep 2025 18:52:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193552; bh=Or4rQv8gYhWYv7bVaKk6p0WoSEPOK4yeZM4jhumpPNg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BEPfuJTB+SJsl4HNQrhIcAvXVTXI9D8x/bhCBY9XnHTU7TnmtKThVJ+vFCAhAXOc7 n+Aj8rptEiylYLc7E6lUhuMMDXDYXVaPwsS/Fra6oogaXA9rQP4TAsWUVOO89DZJC/ erFrsAFsVRYvPDYTyYbwFvxZscKBir48msH4W3kBvXZ8KMliY4DcNGzwN5Su75RNb2 Xj1lPiRKDGxN7hnX4nnYYBXsWs9dbKxLgT37wop51QGAkmJamaQWFYD9K6TrLI0WCg Cjy/ciQtKDC4zKsAXiZc+Ty2qQ90L5UuR/ymPuasICmJ3SNt88nOps19ugaXlVHKgu F8QQAx9vOVpfA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B578767E00 for ; Mon, 29 Sep 2025 18:52:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193551; bh=tdgE5i76CqAX/ZAu+SN7Muus3AGgVIm1gx3icfdp2Kw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXysyiMhpyqvpldUoeshXsHKSZmzr9WFvLVwHUXoW0PCkc+I0qwfGFFQBudMRvXLT iqwJUNScxOTQQQUMH4OOCeX1ynwXirsgsWkfiI3orq6S799rdaFCXKinmPw/Qj/rAl 9cOJXebUZr4oP86jpfoVE16QYV8tt7Vt0LBkILAFfZIPjXUlYT2dN828JM3FOTTeMj BqxUaU3trFDlDtOOOfPqM0QsPRxkYrhKuefuzJTp+5O//x+J2T8eo/W63z5e95pSQv 6j4ruTXBhboCHFi+3h/L93PqFoqZCtJp1F+lz9XD5cB+Lbm3Dw3Dmy3B95Ux5A9289 8dONV79sR1b6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 56B1F67E79; Mon, 29 Sep 2025 18:52:31 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 70h0gRh13ldm; Mon, 29 Sep 2025 18:52:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193548; bh=FY05Z7CrvNLYy09x+88j/4/01SHrEkpRFVVMQ1GLEek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plh6W7OhAAnz6NkJ64jhdS2UYE+eGWHX0id4T49+fC/KoF6VXVmF2EKUZjg282SNW B8yDcbNUmGAh5EwjvLYg3TmbyWDZIvxoNorG4yL0bw3gONVkMPr9aN/r01QD0rRDIp t8GwsT5cuZ28CluOneLVEOjQ9fUBIUkhUYxky9uWD8R4UmIlxj6aSwVUFlXVgfeNkD C3vLwumn5PTCDtiQZkJgEfn01I3kGZlU+RX7VoiTFIIPpOazQXkvrAyJIaMQKvw9ul oJhvWNtJPMOBwfIfrwx5ibQlrH5j9N4ui56rEnibGePEzPceY6E7hv9ZpYDGsRlUQq 5dpDxaVqkrbbA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 13D5D67E04; Mon, 29 Sep 2025 18:52:28 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:28 -0600 Message-ID: <20250930005137.3650600-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZVBT7FHCED3IWNH37TU5XLA3BKS6TQC7 X-Message-ID-Hash: ZVBT7FHCED3IWNH37TU5XLA3BKS6TQC7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/15] boot: Don't change the method count after global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass At present before scanning global bootmeths, the iterator sets the method count to the index of the first global bootmeth. Now that we support scanning the global bootmeths multiple times, we must leave this count alone. Check against have_global and first_glob_method instead. Signed-off-by: Simon Glass --- boot/bootflow.c | 18 ++++++++++++++---- test/boot/bootflow.c | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index becb2ef109f..e58c55ebf19 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -364,9 +364,20 @@ static int iter_incr(struct bootflow_iter *iter) for (iter->cur_method++; iter->cur_method < iter->num_methods; iter->cur_method++) { /* loop until we find a global bootmeth we haven't used */ - if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global && - !bootmeth_glob_allowed(iter, iter->cur_method)) - continue; + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global) { + if (!bootmeth_glob_allowed(iter, iter->cur_method)) + continue; + + iter->method = iter->method_order[iter->cur_method]; + log_debug("-> next global method '%s'\n", + iter->method->name); + return 0; + } + + /* at this point we are only considering non-global bootmeths */ + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->have_global && + iter->cur_method >= iter->first_glob_method) + break; iter->method = iter->method_order[iter->cur_method]; log_debug("-> next method '%s'\n", iter->method->name); @@ -380,7 +391,6 @@ static int iter_incr(struct bootflow_iter *iter) * normal bootdev scan */ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && global) { - iter->num_methods = iter->first_glob_method; iter->doing_global = false; /* diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index af7f7391160..ceab3c453c4 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -467,7 +467,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts) ut_asserteq(-EPROTONOSUPPORT, bootflow_scan_next(&iter, &bflow)); /* at this point the global bootmeths are stranded above num_methods */ - ut_asserteq(3, iter.num_methods); + ut_asserteq(4, iter.num_methods); ut_asserteq(3, iter.first_glob_method); ut_assert(!iter.doing_global); ut_assert(iter.have_global); @@ -534,7 +534,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); /* at this point the global bootmeths are stranded above num_methods */ - ut_asserteq(4, iter.num_methods); + ut_asserteq(5, iter.num_methods); ut_assert(!iter.doing_global); ut_assert(iter.have_global); ut_asserteq(4, iter.first_glob_method); @@ -546,7 +546,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) ut_assert_console_end(); /* Check that the sandbox bootmeth has been removed */ - ut_asserteq(3, iter.num_methods); + ut_asserteq(4, iter.num_methods); for (i = 0; i < iter.num_methods; i++) ut_assert(strcmp("sandbox", iter.method_order[i]->name)); From patchwork Tue Sep 30 00:51:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 449 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193558; bh=fGBb3vIikT2k1C8r1eZ3FiL1/zxMs65XWPFV3uOZaVw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ItjokkK79HZWu9KMwBC0vAVSwGBFeEY6EmFgxT4c1jMJSeWi/XvjTU5k2O0CWHtZ5 DJMYOeJuBubk1oUd8FjQX66/NasWjMfZYqwaPgnT6K/qT9vzEFEFjg4rkH0Nhtbo4g jnPEe6ViefBjJ3zfQ4QtskrY00X3n/Pk4QtPJSEkO4u4pUkhjG7S9IbJ+746wceh8G 36tKLL6KKOrsTnWWJH48NdMB2dxME95jbFPNoy1tUjrsU9JmW5RRl0x26M1H9QA5sD X2D6J6wXfb7aulXXhZRChczlCqwq6o55FfV/+BHySgy8LX1u+NqBzWI398EQkxSbMY EvLgWiAiFg7YA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4A7E567E59 for ; Mon, 29 Sep 2025 18:52:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id xLAHt4Z3SycV for ; Mon, 29 Sep 2025 18:52:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193558; bh=fGBb3vIikT2k1C8r1eZ3FiL1/zxMs65XWPFV3uOZaVw=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=ItjokkK79HZWu9KMwBC0vAVSwGBFeEY6EmFgxT4c1jMJSeWi/XvjTU5k2O0CWHtZ5 DJMYOeJuBubk1oUd8FjQX66/NasWjMfZYqwaPgnT6K/qT9vzEFEFjg4rkH0Nhtbo4g jnPEe6ViefBjJ3zfQ4QtskrY00X3n/Pk4QtPJSEkO4u4pUkhjG7S9IbJ+746wceh8G 36tKLL6KKOrsTnWWJH48NdMB2dxME95jbFPNoy1tUjrsU9JmW5RRl0x26M1H9QA5sD X2D6J6wXfb7aulXXhZRChczlCqwq6o55FfV/+BHySgy8LX1u+NqBzWI398EQkxSbMY EvLgWiAiFg7YA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 38A3367E15 for ; Mon, 29 Sep 2025 18:52:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193555; bh=PEGg5oBRSfxK+6jJfOFk493Ih7AC+0swaLDzqC7p820=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HEvgiCdAIfUPiW6q4WxF3hUsic7MG4zSsrQ4fO4La1snBhT9NJiB1C3ZVHk4H42VH +FeBQs6yLmP5PIchACKw9++pnoCHRoIA4wg8JDW/cGDUhjqrN+pDiaiXMvsIKYb7Rn tG4ei59ebF0qJ9h2WYGznYcCawnjdQncS4bU3ACDCE8ynTisUQVegMDwPw5UdgjWvs LGp7RHMB1Gi+ZChBrPHdB+MGMgn6XnMo188xGUrEH37x9rMBM9Dx6RugoDmJy44mqA yImzHjkhS74fNetw6f3cilnHWwyrmc25haPcR58awd1feZ7nYxnpJTQ4kQf37blv4A uaGg5s61dzeWg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EE08367E00; Mon, 29 Sep 2025 18:52:35 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id fF8ivq3JykDT; Mon, 29 Sep 2025 18:52:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193550; bh=hBAtCZjGiLmmuwQZIQOCItInlO/9wMLYpnh87bWEmJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gpKCQnXmr720DJB01V7xKUTo5mK+UaNeGYh/YH545iy6ptrCGgtLtmQ8k7IAuFzLH XHa5LSoHuAg1c1Zs+xyViKhvEddwXqpXsj3YViib684TJOak1lcAetHTKi6EinE4pZ TY3Y98gSsnyTxviBw2OeN94ke2Zc24e342hfo9S5k71MzMGkQOYQtpevHWbz9H2M5u yMN5BWOWr9KogyNgutt2Q3d9V3bzsueU98SWoRkTCSFCkJRn2Rj9agYCquam96OGMP GsvjzCj6UtDb+dECoBjkp/ePv9MnGwquzcH70Pe+QbHKHyF5cJzZ043hjeYV5a3Q9E ZR9Tj0nLTKsYw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 182F767B49; Mon, 29 Sep 2025 18:52:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:29 -0600 Message-ID: <20250930005137.3650600-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BWV5HPSHLJH6BO6LXZ24IKYVS7JVYRCC X-Message-ID-Hash: BWV5HPSHLJH6BO6LXZ24IKYVS7JVYRCC X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 13/15] boot: Run global bootmeths after all bootdevs are exhausted List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass When there are no more bootdevs we should still go through the global bootmeths, since some may not have yet been used, if their priority has not yet come up. Add a final check for this at the end of the iterator. Signed-off-by: Simon Glass --- boot/bootflow.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index e58c55ebf19..9769a8a5f74 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -417,6 +417,18 @@ static int iter_incr(struct bootflow_iter *iter) return 0; } + /* if this was the final global bootmeth check, we are done */ + if (iter->cur_prio == BOOTDEVP_COUNT) { + log_debug("-> done global bootmeths\n"); + + /* print the same message as bootflow_iter_set_dev() */ + if ((iter->flags & (BOOTFLOWIF_SHOW | + BOOTFLOWIF_SINGLE_DEV)) == + BOOTFLOWIF_SHOW) + printf("No more bootdevs\n"); + return BF_NO_MORE_DEVICES; + } + /* * Don't move to the next dev as we haven't tried this * one yet! @@ -530,6 +542,17 @@ static int iter_incr(struct bootflow_iter *iter) ret = prepare_bootdev(iter, dev, method_flags, true); } + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && ret) { + log_debug("no more bootdevs, trying global\n"); + + /* allow global bootmeths with any priority */ + iter->cur_prio = BOOTDEVP_COUNT; + if (!next_glob_bootmeth(iter)) { + log_debug("-> next method '%s'\n", iter->method->name); + return 0; + } + } + /* if there are no more bootdevs, give up */ if (ret) { log_debug("-> no more bootdevs\n"); From patchwork Tue Sep 30 00:51:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 450 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193558; bh=jp5yni8uEDuBk2Efu0gWtS9RRrE7QsRFN596F3COZZQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=e+TR1NxSgTLTLy3JY+sb7AQOmuBf2xLGiKo2IeREYOO/zwOdE9IJ3w5D44h+HoOyL mju2nPCRJI0F3fJSfB+fyYox+VJyo7npOVCP+FMkLGmrTjwGW2B2Efe6tdizLni88u noZU+2vRLGxHueCBoirbzLBi1Kxlm9M3fZT7aIi/1lVLml9oO6vh+tD8LsJdEZNXHp 8kYBd2DZNFegq4zgPJ1CbqLWggIel3Jiss7D2QbTesa5cMnHmIX5Jj8AswkU9DTUo5 MR5Cpgrpfcg/V+74O8ZP98RkHeY36XoSlTAL2gr2eBfGPNJrPcCRsj1LEgAQRVzCiK maJ0E2Tvcfm0g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B8B4967E57 for ; Mon, 29 Sep 2025 18:52:38 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 4LjPfiqhppwU for ; Mon, 29 Sep 2025 18:52:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193558; bh=jp5yni8uEDuBk2Efu0gWtS9RRrE7QsRFN596F3COZZQ=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=e+TR1NxSgTLTLy3JY+sb7AQOmuBf2xLGiKo2IeREYOO/zwOdE9IJ3w5D44h+HoOyL mju2nPCRJI0F3fJSfB+fyYox+VJyo7npOVCP+FMkLGmrTjwGW2B2Efe6tdizLni88u noZU+2vRLGxHueCBoirbzLBi1Kxlm9M3fZT7aIi/1lVLml9oO6vh+tD8LsJdEZNXHp 8kYBd2DZNFegq4zgPJ1CbqLWggIel3Jiss7D2QbTesa5cMnHmIX5Jj8AswkU9DTUo5 MR5Cpgrpfcg/V+74O8ZP98RkHeY36XoSlTAL2gr2eBfGPNJrPcCRsj1LEgAQRVzCiK maJ0E2Tvcfm0g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A899B67B49 for ; Mon, 29 Sep 2025 18:52:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193556; bh=kDZmp1WMxsV7qfVNuG2Vdz5HB5X0GRcekAfG3ziJj6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RNlk3R+kLJSjsdVGKU09lvbfLx2F4VF7sAtQSkBbW8sPaNxd0n4wzkvmcKT0XI6Nl J+DlBpdcPyOL8c5bQ+o8EfP9oTlzBGuWUEGqM2kUS4C3N6h7URjAB+uU8yHeLZUpL6 vA6MbEkc84W+V7bR6U98xj2aBIQ1dvGYsdJwzz9oTPSGo5CXUuSpYRXpdwJGFK+stz Br+2FTemi2vkDVGE1kqZdE/mr2mO4RwqiCY3xRB3vrL328cx4LG7CfybUZsFXsNAFe jpbA3p5nRtKv3Sa9ZJvMPtQb8qU4H+leeqCLFb0ukpkALVJUezEiu/RHncLaFpmphR ozM94YBkyb+QA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6848E67B49; Mon, 29 Sep 2025 18:52:36 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id xUAYF7PEe4mX; Mon, 29 Sep 2025 18:52:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193554; bh=xwwA5HqJBpNleDrNUsQprIEwIlNSzjq7H6cGyW7SIMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TON9tXM4KpDxnmuj76uSxqQoSYPqfFa1Us4az1yGza1SDVF0tCTJ5mHYcZsT2oNw1 myAfpBnCXsE1nqJVu2GeRzy1UPOE4TjMUeGLqR7W29q+u/bdZx1CLGB62wOKx4zfa/ tMSf3BLq4MFIYNafrtRu8kaZ+zNENJLuPP0ZQYP8gGvrcY/XRa6zr0Su0kKWWIEIRk 5ESD7naFxPmLIC6hT5Kc/bO2yLnhAz+MRSXLpTkklbYvORluGucB0aeAlJX7/P+UAr cqTkQsv6Y7Goq7VwGwU1rjkwoGAonWVymDSy3mc4FnZyrWYf5TDylT6bJVFebmTgEt 9aihJ1MgTYTuA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A444C5FE1A; Mon, 29 Sep 2025 18:52:34 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:30 -0600 Message-ID: <20250930005137.3650600-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 24XLNNWZEQHZHMLAMEYZKACQZAOCIN3U X-Message-ID-Hash: 24XLNNWZEQHZHMLAMEYZKACQZAOCIN3U X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 14/15] boot: Run the EFI bootmgr just before network devices List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass At present the EFI bootmgr scans all devices in the system before deciding which one to boot. Ideally it would use the bootstd iterator for this, but in the meantime, give it a lower priority, so it runs just before the network devices. Signed-off-by: Simon Glass --- boot/bootmeth_efi_mgr.c | 1 + test/boot/bootflow.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index 5e83d1da103..917cec2fe64 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -98,6 +98,7 @@ static int bootmeth_efi_mgr_bind(struct udevice *dev) plat->desc = "EFI bootmgr flow"; plat->flags = BOOTMETHF_GLOBAL; + plat->glob_prio = BOOTDEVP_6_NET_BASE; return 0; } diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index ceab3c453c4..65e2b5b5c9d 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -495,11 +495,11 @@ static int bootflow_system(struct unit_test_state *uts) ut_assertok(device_probe(dev)); sandbox_set_fake_efi_mgr_dev(dev, true); - /* We should get a single 'bootmgr' method at the start */ + /* We should get a single 'bootmgr' method at the end */ bootstd_clear_glob(); ut_assertok(run_command("bootflow scan -lH", 0)); ut_assert_skip_to_line( - " 0 efi_mgr ready (none) 0 "); + " 1 efi_mgr ready (none) 0 "); ut_assert_skip_to_line("No more bootdevs"); ut_assert_skip_to_line("(2 bootflows, 2 valid)"); ut_assert_console_end(); From patchwork Tue Sep 30 00:51:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 451 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193563; bh=Su6xXjAHKkxnkP2koUV3MiB96Q11AkyHnzty1jYz2Os=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=iEDQxbcA/TsV0dTTfJyQPd+Go2A2HFccFjFuWQWj86RY7SGeuP/L124skuA+hNxRB bb0eNsnsAw9DxCCGJVruTgya9/0f69wpwQ47AHuUvz5M0q9MttGpUTMwsnh1KYigi3 wIhptIdYOR+QNOSAXRb1ay1OtwLjYU0AqztBEAfBGQlu17Cp3m6avGDvFoqv7KIwrM K7emHW/els55ZM9ti19/Ji37GcFqIXOOcGSw/VmJ6+DO9y67vlw/DLlcATvSRnwD6o gCzLTHOtDWglL4kvmH+yD5enOKDo6DjykzZNw/Y6Gav0HSmZGylQM6KZlWY0q+poSJ HdJWRLhCv+52Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 65A5B67B49 for ; Mon, 29 Sep 2025 18:52:43 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id HGY52dOowOJ3 for ; Mon, 29 Sep 2025 18:52:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193563; bh=Su6xXjAHKkxnkP2koUV3MiB96Q11AkyHnzty1jYz2Os=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=iEDQxbcA/TsV0dTTfJyQPd+Go2A2HFccFjFuWQWj86RY7SGeuP/L124skuA+hNxRB bb0eNsnsAw9DxCCGJVruTgya9/0f69wpwQ47AHuUvz5M0q9MttGpUTMwsnh1KYigi3 wIhptIdYOR+QNOSAXRb1ay1OtwLjYU0AqztBEAfBGQlu17Cp3m6avGDvFoqv7KIwrM K7emHW/els55ZM9ti19/Ji37GcFqIXOOcGSw/VmJ6+DO9y67vlw/DLlcATvSRnwD6o gCzLTHOtDWglL4kvmH+yD5enOKDo6DjykzZNw/Y6Gav0HSmZGylQM6KZlWY0q+poSJ HdJWRLhCv+52Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 537D767E00 for ; Mon, 29 Sep 2025 18:52:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193561; bh=ucf7UGWOAeVEFhPNX2lEaLsyIM3T351wjNPu9lwKfrw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MPiBEbC1qE4KkIYRVF8wJG55rb9khAurYMfkypjUWZvju+B2UFjFhriaq2fVWLspM NjuIzqasyjvETtphXYtaXKcveckGXCmRRRRmLkC/lhs5S5UtWJMb2168XdY4N3kxJW 8vLTwyKYMkhyI2HkpFHHMNCapoSQGVSnUc0C1Ir5IgvPfVuvEEEBeQWL7LiBbDtySQ 31Xy7G3GxCTkLNd66hVVdzsTfmrCQ6+Q/EEgdnsbaX/q2oOnhKm5Yp0tmnSATv9tFK PfzhM4DI6DXMMHdzsskBzFNVf0pMxvhE7fhBmyC0KJO9YR0e8x3ca0yuQBuP/gKJHB C4BIQbeZL8BCA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2999E67B49; Mon, 29 Sep 2025 18:52:41 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id rOWX1aU3xMBp; Mon, 29 Sep 2025 18:52:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193556; bh=Jj1dEnuPEOoVQSoRUSf/VROoDGooG2bvI+t39SQl0iU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpqdBt55ZX4ikuBNMsm5bnSgJ9mUD9tFpG1igqFPljQ1woWu7TxDdxtmE4UKZCX2n /+y/Bl90OSbvtpTaMGg2TIYmqSPUMbRIUMXnCCx7aqjj3VpSl/WbTL1e8bcEAiZOAj LO6svfr4oOFLT8G++eoAFGjY6HUTN2vap8GLwWpFf9Kd7BVy2t4XZSfSEInRvSenac k8yfOhBC77i/GIdq88DIEq5Ll/qUvL4G/VHHR8UPI+ToXX5mcbriwJW1/QbXz5yKMg OKrMSKrXZnakRlsL3BxRn23XOD3iiBn/JfYV+5vB6V4N4keId7thS+YSWfKeZ3eRnk AH/x5D4hxanmg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AA50C5FE1A; Mon, 29 Sep 2025 18:52:36 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:31 -0600 Message-ID: <20250930005137.3650600-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: O5QN3RBJWS3CI2LNJ642NWKHJ7ZOJC4A X-Message-ID-Hash: O5QN3RBJWS3CI2LNJ642NWKHJ7ZOJC4A X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/15] boot: doc: Update for new global-bootmeth features List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Provide some developer documentation on the priority feature for global bootmeths. Signed-off-by: Simon Glass --- doc/develop/bootstd/overview.rst | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst index ca76bad7bca..4c924e2eb21 100644 --- a/doc/develop/bootstd/overview.rst +++ b/doc/develop/bootstd/overview.rst @@ -133,7 +133,8 @@ which scans for available bootflows, optionally listing each find it finds (-l) and trying to boot it (-b). When global bootmeths are available, these are typically checked before the -above bootdev scanning. +above bootdev scanning, but it is possible provide a priority to make them +run later, by setting the glob_prio field in the driver's bind() method. Controlling ordering @@ -614,9 +615,9 @@ simply copied into the iterator. Either way, the `method_order` array it set up, along with `num_methods`. Note that global bootmeths are always put at the end of the ordering. If any are -present, `cur_method` is set to the first one, so that global bootmeths are done -first. Once all have been used, these bootmeths are dropped from the iteration. -When there are no global bootmeths, `cur_method` is set to 0. +present, `cur_method` is set to the first one, so that global bootmeths are +processed first, so long as their priority allows it. Bootstd keeps track of +which global bootmeths have been used, to make sure they are only used once. At this point the iterator is ready to use, with the first bootmeth selected. Most of the other fields are 0. This means that the current partition @@ -719,6 +720,23 @@ When it sees `BF_NO_MORE_DEVICES` it knows that there is nothing more it can do so it should immediately return. The caller of `iter_incr()` is responsible for updating the `err` field, based on the return value it sees. +Global bootmeths can have a non-zero priority, which indicates where in the +iteration sequence they should run. Each time a new bootdev is produced by a +hunter, all of the global bootmeths are first checked to see if they should run +before this new bootdev. For example, if the bootdev was produced by a hunter +with priority BOOTDEVP_6_NET_BASE, then a quick check is made for global +bootmeths with that priority or less. If there are any, they run before the new +bootdev is processed. + +Assuming they are enabled and the iteration sequence runs right to the end, all +global bootmeths will be used. This is handled by a special case at the end of +iter_incr(), where it processes amy so-far-unused global bootmeths. + +Of course if a specific bootmeth ordering is provided, then this overrides the +default ordering. Global bootmeths must be listed at the end, reflecting their +hybrid nature (they are bootmeths but operate on the system as a whole, not on +a particular bootdev). + The above describes the iteration process at a high level. It is basically a very simple increment function with a checker called `bootflow_check()` that checks the result of each iteration generated, to determine whether it can