From patchwork Tue Sep 30 23:25:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 452 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=1759274792; bh=gVseYYyhukKhoBDHcrOt2Rb/+mT15yA7eIAjSHyO98g=; 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=rO8t1vHpwWcCh77AnbGaBjCz8LWQlKQiW3pE4UXAvksYGirGJwgkrUabQdx92TVBV q+wOrBr6N+a3Uiw2GCvMhpSS1y7+LeR0RPq1UzB8wG6u0PpOE6ei+YNAAcqcyzI00l +SmcxuosT333tWfUNkYbjbeity2IbCIDBXrGQgPoqiVzp4m/93o5LbyBPNloshx7oF cJeV7n98DBwax7p52b9/5UEF0gSPIXlKd8G6SgudsMZBLwkFPjIWmblicux8e2Y/eQ wadFZlEABdA9u6jz/VWpvKiGDEivl2HiI4nYPpwRvEy3n8gdg6buZMx3gpIwS/wnKa rumoYCg5VdtYQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1B1DB67E95 for ; Tue, 30 Sep 2025 17:26:32 -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 HoHTRCHY7tuX for ; Tue, 30 Sep 2025 17:26:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274792; bh=gVseYYyhukKhoBDHcrOt2Rb/+mT15yA7eIAjSHyO98g=; 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=rO8t1vHpwWcCh77AnbGaBjCz8LWQlKQiW3pE4UXAvksYGirGJwgkrUabQdx92TVBV q+wOrBr6N+a3Uiw2GCvMhpSS1y7+LeR0RPq1UzB8wG6u0PpOE6ei+YNAAcqcyzI00l +SmcxuosT333tWfUNkYbjbeity2IbCIDBXrGQgPoqiVzp4m/93o5LbyBPNloshx7oF cJeV7n98DBwax7p52b9/5UEF0gSPIXlKd8G6SgudsMZBLwkFPjIWmblicux8e2Y/eQ wadFZlEABdA9u6jz/VWpvKiGDEivl2HiI4nYPpwRvEy3n8gdg6buZMx3gpIwS/wnKa rumoYCg5VdtYQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0B3EF67E7F for ; Tue, 30 Sep 2025 17:26:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274790; bh=YKzabuh6R8pt1jUWr6+VLx2hT0vGmkxY2whFm9q0Ghc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hzwoP2bwwMTq1+oCotetMaFBDspqKaRDm5WbuwVjW+xYwb3z0Ko8mJ4nqw6lVkHGn 4l8GRgrXvXxhj/64jKdbmPQ5kLWqt7JuUWI2xoaL2lgDKR6Zp8TzItEFTf+Vv1luWs CKQZu5pGQzT2zyH865Lmz1fLXikKrOGFPtZ+/CWvZKLgRU+Ohne8piWB5UGqInCtNO nGiH1LVEg3g0d8ULm2KpV9CXnbvi/tIJlbWcW4Bps6xh9ZpeVAst8MrcU8kCtNTI+5 8njyhQMmgH4+GvsX/j4Lz/CLrlGaeVU4EKAP4eGMc3paWqVr17xO15jC+QxgPfuEXb 36I2TwJG+6zRQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 31DE267E2E; Tue, 30 Sep 2025 17:26:30 -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 Sorh5wpDaAX8; Tue, 30 Sep 2025 17:26:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274786; bh=0hExmZgs+eL/+yGSsNrUaprleGgYIIwpjJifGyZx6lk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VHRtf9oKNpuZn1vYYJDaT2XU6J+XiCwJ9dvhE+1ReZOo/c1ZqdV/K0bsaLD9+J8Pc fUMhbl6lPQWAL8lkrHOQn9mXV6O89jAFU8nzRnJqWUEju6Y82g2bqTsn3QZPe3Hiqf KnnI9Z7tcq/VvGbjKIvK6UqzkpuwIMxcAe7xDiEkh7XHqo4Lhech76rlJnqwt1HkI5 RUabYI8xQJVa6H/LYFfzlk4mVSn7Gd9D5U5R4s3KY+YrFfg6ItpUCCK6ZSkXjHf3wp F/KPS3AxmbWh6mP053v1OjgXuo7PqhwsLdIyA+lJpQwU3gzxrQvlxQchBACUF96d51 +hL0cPxdvUYnQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DC3C367B5E; Tue, 30 Sep 2025 17:26:25 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:38 -0600 Message-ID: <20250930232611.1564850-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZFUFDCPOAQIGUXPNIDSIIG4ZCQJN3BH6 X-Message-ID-Hash: ZFUFDCPOAQIGUXPNIDSIIG4ZCQJN3BH6 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 v2 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 --- (no changes since v1) 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 23:25:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 453 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=1759274794; bh=jxvMI5jcnpU0T32fMv/3W2giO84K8FxwtDjl7dNtrFQ=; 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=qn06F4ABpqlc94L7RP4Wm9+5KcibPUiob+SrTtJlEmXLyTI/M9a+UanHqyHYntCHh BTYcCMXejHl8G8VHGLKx9GP9Z0evQTOzJFKBxWH560prXlfyBIOXO4g9kPxo/I8D/q FHL02Tg4ZRfdf0/+q2kUvfI+d94snxjvcFrHoKQaHjH19HLjcEiGMHpLH/j22aBZXf DuA+RzCNnxdXx7QcrX27mMxbCZ71j2IlUye19X7EdmBJxo8z/ahmiU/f49MoeF9cJS 7Hv4W5G/aokLpHuEJ+iVWgwXCRdXqlyaNCho6HvZhyP4n4fMHBzmVKQGqsoFkiRN4Y YSPakcq9laerQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8571067B5E for ; Tue, 30 Sep 2025 17:26:34 -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 m9wFSNDwGZ2U for ; Tue, 30 Sep 2025 17:26:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274794; bh=jxvMI5jcnpU0T32fMv/3W2giO84K8FxwtDjl7dNtrFQ=; 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=qn06F4ABpqlc94L7RP4Wm9+5KcibPUiob+SrTtJlEmXLyTI/M9a+UanHqyHYntCHh BTYcCMXejHl8G8VHGLKx9GP9Z0evQTOzJFKBxWH560prXlfyBIOXO4g9kPxo/I8D/q FHL02Tg4ZRfdf0/+q2kUvfI+d94snxjvcFrHoKQaHjH19HLjcEiGMHpLH/j22aBZXf DuA+RzCNnxdXx7QcrX27mMxbCZ71j2IlUye19X7EdmBJxo8z/ahmiU/f49MoeF9cJS 7Hv4W5G/aokLpHuEJ+iVWgwXCRdXqlyaNCho6HvZhyP4n4fMHBzmVKQGqsoFkiRN4Y YSPakcq9laerQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 755CD67E2F for ; Tue, 30 Sep 2025 17:26:34 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274792; bh=N+xRwU1dicncZ1noJI6qJSeKvjquE3Cs6bj7dQev2W4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQ7ea0/f67LBgpQ9p+hlazpeQYPYEWVyyzSIXsehq/m5hS+HnMDtztElZUoBfBmmI /Q+CHQDjTPPjcL7o1+D5S0sUMkWmOuNUEyUo4j04AzB4fHj7pDZcLkHJ57SpsdmJse Qdx3Oq3s8y8wXnFEwvy0LAg+TAARMSTfPI6bnEIVOkblGINqioNJC7JwfN3WLJfSg8 XQhOLdnfQGuHL/4k2PDQ0sNZWKRYg1vUrin7EapkCmgCwQWPON5q/5vMqIAU+V9kLs 27UnDZpG9fkWpuhI5B0813V+YjFaeEh4ZZMqJUh9Zn7XTyU+uQXyIxfXpYLg9LE4qD a4BuB7rll6ZXw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3448367E7C; Tue, 30 Sep 2025 17:26:32 -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 4n44AKiy38m0; Tue, 30 Sep 2025 17:26:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274790; bh=dVlZMLrIzutOX8S/RIDUbSBzIO4+ErFOZxSYRtH3ras=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bAkwgDGDgZldWiGg7mtMrEDU6XJcaXm4rbFzWQUNBfxllRI7U/hS3Zy7FaJ/hbg18 PqGIJVgj8+j7dJSPTg81pTuvSVk4vxCxljHRDqGMdzVMBenfLC2jRqVj4ZchLttEBT RLNs8lETLDWT5hc3d06mYF8set/vdsRVBeAxNcO9HiIYiZJEAphjr4qi+CRRPntTzu AUnKL/qqazaCYme7SlJyk1ghTMgdBA9c9djwJOusQJ61h2T4nAGGYKUccSgxpKn+d+ FTLOHzaTwFVSfi2RHOqmxqr8dRqC21t2KuH/cvc/8fBLb/VVpjbux9VBmCKnxqgobe TH6OJHPoOMoUQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7AE9667B5E; Tue, 30 Sep 2025 17:26:30 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:39 -0600 Message-ID: <20250930232611.1564850-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PBIR4ADAKHKTL3Q3CPBH2PZAOSX523DN X-Message-ID-Hash: PBIR4ADAKHKTL3Q3CPBH2PZAOSX523DN 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 v2 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 --- (no changes since v1) 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 23:25:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 454 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=1759274799; bh=LMKDM6msKudUVoYl2XYL1b9zQP/78bn9j96jJiW2xxI=; 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=QD0DvJrgfMSW0MqBaoJOSXCVYAK2rxD/kA2l8WmaarDfh+Dq84PGxs3LNTUrwKP/T BtGzEt71/2weuNf0WBSsX9RPW2XHFf2eiGcwSW0dBE41UbUiS4h8w74+No0o8UlbIO 9YPRvZ08pG2P/tE/iR+4o4H++eNkBHyzfZD/CGxjWxH9TNCUN9BDW1vi5soy+ASE7f axZm15n41nBpRzf8fHQkbDfMrDIz8KLaVJA7CiQsI8ZlcNSvt8OwOnwI0tnTOtXDHj y5p8sTm0XOCr0ry+4lPMqk9JtuB4XnRkJABGSXel7CnE8SgRGSTljn2o1Onb5oo+YO re1BIVOX4Ccog== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 006D067E7F for ; Tue, 30 Sep 2025 17:26:39 -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 4zqy9_GwGGB2 for ; Tue, 30 Sep 2025 17:26:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274798; bh=LMKDM6msKudUVoYl2XYL1b9zQP/78bn9j96jJiW2xxI=; 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=UBm9IbHwQFOA56uNQOtK1raS4eoC4/xRJVo8EOKkRtxRKh/is5wD0CCT6Tgj+SZn5 /Vfvv3NIYZwKb/W8+2ekO8qUZKhzGMgoJ3lwNl8M3O9C8AeSUu8g+Xn7RFfScQxz2w QoLIXfvttySOyFh/beQVheBxOa/rZsJYCBm6+p4zxU/Odwnhk4Dgj8fSzvSVu5zl6v sp/EDk8aij0rgtCp4Enl72ETYYReDYA+tdHXYNkjbK6d6lejUzQwqDJmHf86gptuAe yghP/cIiEQNKUSwQL72p3oxxkbkki5QM3ux7uwlLMd6G9OoNgbVWiDe7eES+EM+yHF ZY5tc9399Ma/Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E428367B7A for ; Tue, 30 Sep 2025 17:26:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274796; bh=WsDwlTgzoK92oXPRhlItLsGSydrUjzsAt3rEzzHiQjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nczARrSQE0wYn6Klad8lfe0LInF5br+6S7cizVmAXoakrxKekF9bXmF9+1npFQ7rn T56vayocrskITXm3b3d3edTgWAykE2p7i4SfLdcYY48OJFgBRCpfy4kDYpAbs91mFe idKvpYIufI/tCQ4Wb7W9262GhO+xVf3n6pLdfxn0vZNoZssleEZD1IZoE1FEFV+45e 5f9KQDiD3muqrMwFsgnrTWMPGNMwf0Uo7s9QYgkSTFF8Y3zTuK2fQ7d+bIeuCOyVM+ COBsseKpYXH+ezgZezwTXt0hmt9RNOtTZveLRW8KdbqX8FDJrcTA4QUMQ2U/fMN/0j gsRCQzWp6KwHg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EEB4167B5E; Tue, 30 Sep 2025 17:26: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 U30olA0Bdqbi; Tue, 30 Sep 2025 17:26:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274792; bh=+U4vy9bN6PmEviqfQG6N9SSL02RAncYWfiakC3JZHuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQyrzXSRjAW3FUWBw4Kf3gfqnM9xOd5heXH/2It2t9yTby8XfJNByLY9zQRTXqbKB NDuIayYYqPOlZLGKrYlrFlXJ7sx5YPwyhVwVwk/P9hnsTN6wXxBu/cJCeuEN12nCLO JmD+ThgqTcPhk/qbOMiFBL5MpHEMO1ESKk8gnPurle+uWwG/hrempSRxXoe+Lco17+ QMBGizJisUrjdf16ZO8m8CEeCX9xcBBVn3j/ivdmFStsQ7aCIA08u3CTmnG9eSaepP Xdj5jrduGtWv+IBV6h+9f2UnlAimyboyxG5k6M/qm8fgz2LA72jW03BbK9WK8U/vHe 6CzZJbXI/wdXw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 77A5967E2E; Tue, 30 Sep 2025 17:26:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:40 -0600 Message-ID: <20250930232611.1564850-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 65UOXXFXPQEBGYSXDC6FAR3DZUKBZFGW X-Message-ID-Hash: 65UOXXFXPQEBGYSXDC6FAR3DZUKBZFGW 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 v2 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 --- Changes in v2: - Add a log_err() for an invalid state boot/bootflow.c | 57 ++++++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 68 ++-------------------------------------------- include/bootflow.h | 9 ++++++ 3 files changed, 69 insertions(+), 65 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 79be94960e7..de86f196503 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -56,6 +56,63 @@ 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: + log_err("Unexpected boot value of bootflow error %d", + bflow->state); + 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 23:25:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 455 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=1759274803; bh=4FVS1NioSIAehLUxZ79JKhQKuYJzelLfc7SXc1p1JGs=; 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=osPqNwprbf/qiyXijkcz/gXBhGOsIWv80fO+X0fvLAF77O/XbGm8Ik2HUGaXs130a KMn2rEfytGYZ7Ev1PujI7KQIftUEb0sLLJKyapaCPWYAUGm0P8rw9lu9yl2varmCIE AHRgcoaO98ZFUVcsjTzYOAFvNSDHN1l7dOxv5IGR0KRMGDRvjwxPjGl/IRRRL4mPWT 0fyv10oFkEh2HEFQJ0ytHuPm1HKlx+hQL3K0PA/KYpAV+SnifO13sYaYjLtUDesbWm 57ZdDAdNtDdgRJawnBIdDSFCW5uPoGbwayj1yLaXrQrMVVwwifXDSeke5uau16j3gN 00YPbQg9gtOgw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B69FB67E2F for ; Tue, 30 Sep 2025 17:26: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 UMZ0o8gCkQnb for ; Tue, 30 Sep 2025 17:26:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274803; bh=4FVS1NioSIAehLUxZ79JKhQKuYJzelLfc7SXc1p1JGs=; 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=osPqNwprbf/qiyXijkcz/gXBhGOsIWv80fO+X0fvLAF77O/XbGm8Ik2HUGaXs130a KMn2rEfytGYZ7Ev1PujI7KQIftUEb0sLLJKyapaCPWYAUGm0P8rw9lu9yl2varmCIE AHRgcoaO98ZFUVcsjTzYOAFvNSDHN1l7dOxv5IGR0KRMGDRvjwxPjGl/IRRRL4mPWT 0fyv10oFkEh2HEFQJ0ytHuPm1HKlx+hQL3K0PA/KYpAV+SnifO13sYaYjLtUDesbWm 57ZdDAdNtDdgRJawnBIdDSFCW5uPoGbwayj1yLaXrQrMVVwwifXDSeke5uau16j3gN 00YPbQg9gtOgw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A154F67B7A for ; Tue, 30 Sep 2025 17:26:43 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274801; bh=8J13CLY6z7tjlARlmfYz7Y+b3aqU7lDFEHlXTVK+8go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XtW2W63u2KpMIia6k9xf2l/oQz8uwltCSSJyRXT+qcrmUlkZz1UYbEQO6aAhJnp0A dNjEjGP8MyBQ8ZdMnUqHjAwamISEM7TRSV8gok+QoGQH8hinvPjA1J9QWqo6PWJjT1 hK0vmFXO6NT50rYhA4KHKuzvbLy2Ew/n5/IXvXTDi0HGjoBsFYLU6NmacvW2VtIKMI nlQ5OVy3P9pn+eJv60xOSFFU6Wwx0q5DCXfUxqYjGUyOwrkNrSLu0mocV/0rbn6nUJ pEGSLlT9EEQx4pJElA6zFrVRi6pKi03AemPWfxXlNhVY8z/IzEFRuwb96FAUF85u57 eDqMsKs+88FaA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7DAE367B7A; Tue, 30 Sep 2025 17:26: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 X2D13m2i1Ax9; Tue, 30 Sep 2025 17:26:41 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274797; bh=wcXOjhbV8ZhYzEAqGL+qZv+Z2DUaq9DJMfb8+LAfFPs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vf9c+zmp9F1/gum5ou9ESzOWP8Ab5miafo7DKa1mdqrTLzQq3yJFwWXOWYqquMnDT bZCtiCbwqwwhsghM3QKPF8oyisCGLH7RW2wBfuIl4+F+OBO15Y4W96ttb9Bvarkto3 pY0iZghC1fGey/tTEDmLysrhz+rjdVq5mNjksxQtMvAh5dL517ptAbnamUcfdmV6rT Yi5uyrYX1pE8OaaNOwnUVrYS6PV19UlB6/U6guKgWrxWzOuvUj0MnqzieQLJbHT3Vo 65JizVXd5qKKQ7n8h9GifqIQaEUkgFilx6gh2GETZaUJqFvi0ZBQz7gAWXpsTM+Ish y93ml5FXU/JqA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 329BA67E2E; Tue, 30 Sep 2025 17:26:37 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:41 -0600 Message-ID: <20250930232611.1564850-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KNSIPMXLB4ZTX4QQWRBOSF3CAUKSWMWB X-Message-ID-Hash: KNSIPMXLB4ZTX4QQWRBOSF3CAUKSWMWB 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 v2 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 --- (no changes since v1) 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 23:25:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 456 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=1759274809; bh=kRjWts1h24GTjH64etKFAYZC20Vdm8MAzD0Pw8DzK2I=; 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=gjUKvHIzYkACdbrkZdXqn0hw0KZ1H0yXkGge18hk/NBVeAPm88pOTk05lP803j50u fbCyRHon9H7OB1sd9aqxBGbe63znjEpJwUPLDBD6hp02oiixT7mg7tV9R2ebrrpRTL +4SxNPDBWc3vteAYDGapNRt+CtSxW1nh+4TB4L3w4gO8XS7bzKRNzJ/FcEF9Do3e8c BDexgZfPXZtc1UN91L3cyHqQI4yWrVdO+9k1/noHjq12VEMFvwsYV20XgnlubPNfZY s5TWwi8CzCHUbuJ9MwyTcJ+L1oBL6OHCTRewZM+Ln2BcqUehfGo329z+qvOCPR/6cX lCkLEHWhDosbw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2BEF867E7F for ; Tue, 30 Sep 2025 17:26:49 -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 jKZt1gt2zFPu for ; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=kRjWts1h24GTjH64etKFAYZC20Vdm8MAzD0Pw8DzK2I=; 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=gjUKvHIzYkACdbrkZdXqn0hw0KZ1H0yXkGge18hk/NBVeAPm88pOTk05lP803j50u fbCyRHon9H7OB1sd9aqxBGbe63znjEpJwUPLDBD6hp02oiixT7mg7tV9R2ebrrpRTL +4SxNPDBWc3vteAYDGapNRt+CtSxW1nh+4TB4L3w4gO8XS7bzKRNzJ/FcEF9Do3e8c BDexgZfPXZtc1UN91L3cyHqQI4yWrVdO+9k1/noHjq12VEMFvwsYV20XgnlubPNfZY s5TWwi8CzCHUbuJ9MwyTcJ+L1oBL6OHCTRewZM+Ln2BcqUehfGo329z+qvOCPR/6cX lCkLEHWhDosbw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 16C9367E2E for ; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274806; bh=jq6pVu2REfwOs8m85xG58M/pVnh7Wo+CKlEBT80FGiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+BWhRZH20B4i+o86RfZstpkn3dnv4JTBHGMm4u6Iw/AuHy0LV2pbVit8GsC1HBeK uxQy6lf54zS9Qhc3hjG20VdguOoOn3llRK3JDj1GuJncStKJynsooanH2V1TxzUQiW wkzq2bGyVT6JknTZRWs+ISX9p5n93g4uY4pso5f6se8QNrDWGZNQhUPDonnOi8fshs GCMeRL5SRP7Y8l00fX4hcF1RaYXAGufz6Jy54Qjz+4ZcVvZ7tbTC8/Hgp4zW5vBjO3 UgawRiVU8ExwcBdcRY+sbnERRudaK0GyHXi5XSUmxMo1v6dcl0DOVgjUyuefa3nK43 LZuVb68yoHDZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 198EE67B5E; Tue, 30 Sep 2025 17:26:46 -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 yPDAmd-xfZKS; Tue, 30 Sep 2025 17:26:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274802; bh=UD+OObYKa1yXIf5qX6bBC88W8RsQHLiJFEhIE3Mg7A8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwKdW7RD+g1P0Pl4GNelwgniKZZyHe7Yt5O+roGPCSRdyaYNmKfYBRsxbiaAcpqPO KHo7uU3uT+h5NI6tcRIT5dAJG3SP3WLiP2XyFHP185x4tZekyqVCtRkVACZ0buA+67 PLsHu7PbiJv92wZPu/9YIhQNo2ivTE5ZcFpHgFTqTdf9QWeS1Wc2MPIPG4H+IoW3zl hklqifDZzD/MYKhGMSCy5MEN2g4klmT7p4+KL6anirNilnj8vje88YpCrSHbWbU4GA H7u/a1bcmK4Bdp5Ul4ekJZEE/exd8TICo1W4/eR4cnkLDDPzEJ/7eofdp3EcgHuJl3 h1h+3bKY7exZw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id BF43467E2E; Tue, 30 Sep 2025 17:26:41 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:42 -0600 Message-ID: <20250930232611.1564850-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: SWQCZEGA22JMU2P5UA7RZ6X4ZYVBTMTZ X-Message-ID-Hash: SWQCZEGA22JMU2P5UA7RZ6X4ZYVBTMTZ 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 v2 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 --- (no changes since v1) 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 de86f196503..dab4397e5eb 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -169,11 +169,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 23:25:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 457 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=1759274811; bh=uv9Fwjlwo7DYApcm0l/kFteSgTw8xyJEq0Zu3xr0lqw=; 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=OhcHNk214t29q54Kq1dOnJTayKXkRDktV7gVRyNOMYPCew1ZG+WZhuOjKw0UD1MiL j1jMaLfoUWbG8Dggh0JDEaWsb9RgVnHF/4iT1Q7WTgNsyqxBXw575OK+R4zFPJqjNA FX/KlVgVvAvtLEjbz4DMayXiFau0LqBRjeZ5rn8XdU/eGKaht/Kd6129+eCj2armT7 iOM8Po1wcM3Fm/kLrH5pNRGNt9/T86JhK6hnty+Nig8AAcae/eVG5LDtXAQLKPeJ8c c4/oFwKF97m1hb6+yd2Yw04swHk4irYGA4S5TFKWsq4DnSnkjqLRgPthd6igTMBCKW hxCP5MMupToYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 82BFD67EA9 for ; Tue, 30 Sep 2025 17:26:51 -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 3hQjOBtt6pbi for ; Tue, 30 Sep 2025 17:26:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=uv9Fwjlwo7DYApcm0l/kFteSgTw8xyJEq0Zu3xr0lqw=; 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=fCT8Tba/QjHefjvTbQJAmRPO7VMJQ+pvmf9czQoRe8N1eiBXhQZ9SyghyO9LQLt+n 4bwCNPDbLG02iKFen9SIQePkBaUUCHHmbVK+V0gLQ0n6IV9q9y44oqAagOGL/bQ90K RiW23m9LlgAiis+IVqexcu7KhNLV1by1go9JbaV92Idn4ahpUD28xJqybNNTvR+UHC ZDrfErmrwW975A7i9JGnQhpX6TkuB0nnSEZKtllWy6hnxq4nhi68YgZiP2lfcfrqM/ fnfXteL4fNvXeH1BxXifN6SI/Es2Ym5PHEDOj9x9zgf0LuIuRIBhvmZiz/rpluyrJy E8Fh7+8ptByYw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7CFD867E2B for ; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274808; bh=a4woHr4y4Y5pmzXqDoYPLE2p1qoncsGTAlr1boD8jc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=THrCY7yO1J3s4dx04yBhp0sja6gTUHfCxL6p3CsMAtAvWPV2Pr0oGpUv80LNt4RNY eLivSDCAsyXUQahGs6VFNPv7n9a/nvYO3jg9izgmEAcE7dYzMqr+l/Ek0yfRLQznIF LNgO93/rzJnS/Ivv74gd2wJBPehOJRNHZPo61Uj6DuCdqetWkRoeH0LZKgjoGUa8lI VTLXJb5UqTv28wBQZpF0+0WNBSu0xd4zs4dYGELVCddqMdbR/2l8B2rSo3CLuv5qha biTV9NOshim24t+FucsY3OMCfnuunhxBxRkNHMlxBeNvrU0tK4cMt4LMnQZaaAsqNJ Bv42vgL7zH59Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F71567B5E; Tue, 30 Sep 2025 17:26:48 -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 gAlrSwIrMJjs; Tue, 30 Sep 2025 17:26:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274806; bh=rTzGu5fSx+EQY2ANj/HXbbzxIpR6VcGfiNVH+Btr0U0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ozZFvNzLslhI/H0SUQxbTcjNZbyXeDaRw+5qN4F56IBX8H51FbGr6jHBW2Fk/2TB8 a5Uly0TZmxjEl41bDlJciePdy1SRn7uccwBCKIURDn6PKND87MdpEAzRDmsYe3U3nG a8WrU/40nWVXVgCQ6Wn31PfreoNkfnP96gELmevHJcwMlerOr2uSGuZz6Kel1g1oOY gTOkkvPwPu5ZLpD5PZaNI8/bwC0YnXoOkNGuv6aP4O+a6pbr/5j6n+WrI7ki9t6CPQ PmmYYNN1Ph4zBTecojl7IbM+l4dG/m5Bzor/mMKfVRNXb1f7v6LRKfkXH9SFEZFvub JFN1xn+2m6r5g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5F02067B7A; Tue, 30 Sep 2025 17:26:46 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:43 -0600 Message-ID: <20250930232611.1564850-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: VHHWBTBNLAPRMS7WRE53BIZVZRABDVKE X-Message-ID-Hash: VHHWBTBNLAPRMS7WRE53BIZVZRABDVKE 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 v2 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 --- (no changes since v1) 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 23:25:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 458 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=1759274811; bh=TwjHV8/6WmQbBJWz+vkFfKMLU6Jp0xel9lSOgjQradg=; 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=VexIUIf0ZwhHzlAheVjVmTi837p+tMHsnl1P/INnRgruP8pQnQDMwe182Z1wKtjG7 dvlhYRXjsGhucOrzEzXcm7LR6jymBlwXOVjJuIn2HadzO9iKWcDCtX2HiU7fc+yNkw fQFX6hzajWto6zAkek84ETmXOHBN3iG3YZ8bYTUy+220zBv+yRjRwZrM1KiTpyjv2Z nL+Wx6DQ6jCkRoPbbtfzR3rdjvxNG7uPmNLS3rZXvPm+2HcSrlr9debQl5lhTAafe3 srGtgVax4ekz+mZUmSPrZ/RsHFiz5zHSSuLjZZ4UGF3IcXIc5lDCaNH8owOb2L49jE DaY0OONMNjXkw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C7B6667B5E for ; Tue, 30 Sep 2025 17:26:51 -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 OcPHw8l4ot3e for ; Tue, 30 Sep 2025 17:26:51 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274810; bh=TwjHV8/6WmQbBJWz+vkFfKMLU6Jp0xel9lSOgjQradg=; 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=l85kdqDcAJha5PxRHB9g8NtzcoLE/yMnsD9sLyfgaoSp/Q2hl88cZeDb/Bx7B2fnj yl/S2hSo2jkT/L1Ztc6JR5j1rXixtTArNz0odQb7ljuESEeZarAkzoSzTupmOXAxnL XgDdOaCG6TTy5gtCeX7IYo1+XoX+mkC9x3oDTYS8NcRrRL9TpekVdy6gLnMpDrL/r6 ObNHSKqV1xEczqNMa6xxHKymAC7wVrCqznNrNQEEcDI5IEBwtuUbuHD28bm+4hxYlN 97+flJR6nEP8VR0LtuIA3e0tXK0aFLBQpNnG2GwYPtPudiLufCWrUlLEVNdjtB29VG DGoaJ2ap2WihQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DA93567E7F for ; Tue, 30 Sep 2025 17:26:50 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=U7RTFpGnoc97xRSqsr8zpsG2kVa74bfK3HJmW3qPoW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GLgrXkg0P3IwqzC9g3rhVmFIywwdJAwt9YvX4lMy/laD+QZ/rhUyA8+1WYuvljE42 NTQYD3Rfj20eWjHo01PB+uv9OOOM6325uw3x36Gn3tcrX/Ns40coWN1TxeLuuv5z01 3neMUjUw5Ha95ALbsgcfhsoxEsLwIuCU9ayRLVWS1fR3i5vcQ7t0dzCbL5ivBT0hrU 84JeAQZXc0FwqyGQY8IbB3h7ohEPDKeBIQF3uY/ytmJir01pAiStzTLcOGSpZpH1df gCc9e8QewgsvltGFTnQoMixZw5oWCmhW7h/FVkWfkwj2ExevPCRC55OoNaHXyzfvke dq6MUEcTl5sdg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19D4067E2F; Tue, 30 Sep 2025 17:26:49 -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 w3jfHEZtYj97; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274808; bh=VJ22Zlb7BGbsu0F2IEWq+BzdzRPi+Zeg5LKK4nPJwUU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YWl0SnIyUGAzWFMRtluUfKK3W/8V2tOzyPmh6YQp9uwvMnicjOCRNCKCXH+i6qViC IYkTQRF4HlZOgCYmzcnKe7V4VvzRabtpIeqE7treISaDER1xJ75vrl0L07SI2Bm1Cs l6wEj3vbM5JRwJ9GmkHDo+AgCuIsNs9D64fQObxPtULC5T0i6FGkpfMGxvJQVFYjss rtloXNW8/4H6avwiE916hwkwUSJ9R5cg7V5Qf6FFdn95S0jgfF6dR1jSaAEG/Y+izY Zg2Ca2XFMsUz+RDpN78FWtqNU3GwLsQr4Sn+39O9kYw9/eWVyr9OinrcFw3KlCFuwY Aj891NBcVZ1rw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5FF9867B7A; Tue, 30 Sep 2025 17:26:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:44 -0600 Message-ID: <20250930232611.1564850-8-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: MLKZHFQ32RTGMED4CA6RU5OUP7Q67B66 X-Message-ID-Hash: MLKZHFQ32RTGMED4CA6RU5OUP7Q67B66 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 v2 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 --- (no changes since v1) 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 dab4397e5eb..4e2a227c807 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, @@ -493,6 +497,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); @@ -520,6 +528,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 23:25:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 459 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=1759274815; bh=dTCgnJhkWIG6EouwT4XIOiIr1Eez0In9tk/bjDqG4h0=; 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=X+2vtAv66nrUVX8AlLm5RZg8N135SlUTdmSXow+IYDzPQr6Lpw2fa+s3rR7Mky3Gg faMzGkSGUO5mH+oSNvTxkmpLZ6CM5P5xKITXlwaKeghSqnMGd3gpe16OfG92p3c5Vt cR/glKFXSXMn2hIb8VhApQouWbsEBegINOLCLdxAmRUviW8veopgVb+p1lGCakm0MJ IAGL7eeyubWfgHDoY3E1tI1QG7U83xFDXUbSV0OUZrOiD9a46Sf8fi4vvDyQ9Enilw 3CY1YO48HmXJyY9RFrzL/+IrM7cl3wf/W9hHytxXlpPAqh0mcDS60GJn7Cy2SYGXEa ntDSFZzm8Q3vg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9AC1B67E2D for ; Tue, 30 Sep 2025 17:26:55 -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 kLtVfxZZ-wzL for ; Tue, 30 Sep 2025 17:26:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274815; bh=dTCgnJhkWIG6EouwT4XIOiIr1Eez0In9tk/bjDqG4h0=; 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=X+2vtAv66nrUVX8AlLm5RZg8N135SlUTdmSXow+IYDzPQr6Lpw2fa+s3rR7Mky3Gg faMzGkSGUO5mH+oSNvTxkmpLZ6CM5P5xKITXlwaKeghSqnMGd3gpe16OfG92p3c5Vt cR/glKFXSXMn2hIb8VhApQouWbsEBegINOLCLdxAmRUviW8veopgVb+p1lGCakm0MJ IAGL7eeyubWfgHDoY3E1tI1QG7U83xFDXUbSV0OUZrOiD9a46Sf8fi4vvDyQ9Enilw 3CY1YO48HmXJyY9RFrzL/+IrM7cl3wf/W9hHytxXlpPAqh0mcDS60GJn7Cy2SYGXEa ntDSFZzm8Q3vg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A45067E2F for ; Tue, 30 Sep 2025 17:26:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274813; bh=jeVRNwV38Uj1MUQIzegV7ELmDxuPFe2Lgujc1HYB6p4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bq84ow//J+3D/JAiM7VwqQyp8fJRLPmiE6Kf03yzkUqI8Ri+ZbK7dFBZOxAaYtbNe em1L46mX3HaVrcKjIalgbwRCozcMWzoJ3RZFjjQz4wcfw0w/7rA3gU1b8NVDujyZE+ NyDGudmpjusXbCmrdFze86N5Uc8+tegorRWY0DXnBa5IoeCXkv9ZZj12d+4mO7FajB COzxTA+QBWPSs3tgaPW39GS9aX8LoSrh+w4PI4F8P2aK60OnMlg/JsPk2y99TgmylY GdwpraPNLOuihDhtewTv2PZTNbVK/HLsN+Mz882HsEYv3sdRFBdfza2vE/U2YJLz9+ QV4a3yVI/NkvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AC74E67E2D; Tue, 30 Sep 2025 17:26:53 -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 Mz2LsE5fmLJ5; Tue, 30 Sep 2025 17:26:53 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274809; bh=hj+BYrembs9KTSJ+GxjlF8IUUgTVfSY4fI5It9lbyBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqkO57UDiJGYeRYOGQkhAsW493Yx6hTK/wFiDQyEiCNTYoLQkMKVE4GS4J6abMUc5 JMaWa7uryQ24e5V4W8I8wGXKZtFrI3n6u42V1o73fONj67wtiLJli8rLHF4ylM5a6L p/pFRMR0izUTqHu+eI964VThdgDO+5Ww85yJxFDdYWBrom2wSNCGVyPSF6AYM6YEsj mMXtPf7RLEIjNSV3luoBbmiCXerufqXsY134WSFmgTcs2N6v7bqWZgf0olIeiUtt8n yUBSpoC8oqdbnjX5P52SDLo9kmQ8ch+pFnY8H2ymYhCK8Cj9bTTz8h6KftvkBI9asy cI3Puy6tnY/QA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5DA6267EA0; Tue, 30 Sep 2025 17:26:49 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:45 -0600 Message-ID: <20250930232611.1564850-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6TD33V3DQJ2ONCGJTJYGAG5ATXPDPED2 X-Message-ID-Hash: 6TD33V3DQJ2ONCGJTJYGAG5ATXPDPED2 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 v2 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 --- (no changes since v1) boot/bootflow.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 4e2a227c807..488cf7b9a7e 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -247,6 +247,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) * @@ -391,18 +417,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 23:25:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 460 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=1759274820; bh=cbpJnZsncmMMcHbX+iC7dhCUY9V4XHS9KWyuBPS3sUE=; 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=MiV5ARISj20F7Ft13Q10zhjM3+NJv4dhminjIKckC1csBL5qM36CF/5rl8hbgZimg U6q7EcKZc2a1mv5sYSlcG9vN2L/QAWpVIj33yM8fPWuvkEEZBsRzOxRwToyRYt939m 8AnHvCX+5dE6F6RAWrTb0Z+eYdalmEmHTwtLHM6GbTpN6V4P9EidbRY1wm3uPuF63K p0MgRZVWQZMNDxFNmJUCy5cH/fAneCdvhkPdyzOGmw/ou4uoUEHzWHrCLFy/COLOM9 wlxDpUrKNUinZxxNOmqxLjEsWEkZs5yxLoSlPyu2zkQNSLmE4DRSleAKjpuhvE6VWR c9W5xvJ6BV68A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1D60967E7F for ; Tue, 30 Sep 2025 17:27:00 -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 WjYVbJ6_FADp for ; Tue, 30 Sep 2025 17:27:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274820; bh=cbpJnZsncmMMcHbX+iC7dhCUY9V4XHS9KWyuBPS3sUE=; 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=MiV5ARISj20F7Ft13Q10zhjM3+NJv4dhminjIKckC1csBL5qM36CF/5rl8hbgZimg U6q7EcKZc2a1mv5sYSlcG9vN2L/QAWpVIj33yM8fPWuvkEEZBsRzOxRwToyRYt939m 8AnHvCX+5dE6F6RAWrTb0Z+eYdalmEmHTwtLHM6GbTpN6V4P9EidbRY1wm3uPuF63K p0MgRZVWQZMNDxFNmJUCy5cH/fAneCdvhkPdyzOGmw/ou4uoUEHzWHrCLFy/COLOM9 wlxDpUrKNUinZxxNOmqxLjEsWEkZs5yxLoSlPyu2zkQNSLmE4DRSleAKjpuhvE6VWR c9W5xvJ6BV68A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0C4A467E2E for ; Tue, 30 Sep 2025 17:27:00 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274818; bh=SiNdbAz13lZ/N/Rs/alhu6BCIRIM2KR8kQK6JdZ2t9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lC4fUgHGmHMlc/le/cUSPKhyK7jOzlWXlkrFwrgomwoC5pxDXQJaGu37n5bPNXUcc Ci4KTfwbe9osK+kyqicG2geHhAJpBKZONxqviiXSM7u3ZW1p4ZDv0mzTt2nsqHVTPo OUjHSbdnmgoFruCvojjB2S8Lv5ryaLTB7rTNegJR9MLqpO7Q+8VDmgcNkOzuTScuUv bXKwUcuELEHX9y9GFd7hM1hRkpO7Wjfj3zMPVj7fR/3UCnSIrOCvcn2VtMq1ETfkuh bq6mqRV9c2WmtIqQLKgLCiE08989m/1YPkf+HlRYY0toOQGeFFSX85Kbck6ZcpkeDl WvszMIYq9sznw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4834667B5E; Tue, 30 Sep 2025 17:26:58 -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 k26r4RoWQ-Ac; Tue, 30 Sep 2025 17:26:58 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274814; bh=Gsi9Ztef//pm0OwK0FbADvyN26x4D8PzwIdWZXHWHGM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nkbEdhHDH7xBPl07tWeXJ/xs/eBMIW12I1g80KiAMqRfpQkQF1jApkZOuIHbVOQ1L 6Tnt0xVwuo69v5tnp/nvegDRh/0bJeB/G3WUpcEuCZgZRMNTR0qfudyYEChENCMHkE nrMfJxoIAJoOITtQKeSxWHmHI2/Z9PLZ86cUL/A7enmWEW0QGXCCxTUnPaX2ehBENB rLg9+VEoVxO/zozhu6511+vsA0+aN9Mi8hlc0DoQPtQbFSHrHA23ctz0EhCmjXUDDb jisRKekojpWx92qV33gNS0A+O9x1xpJzljiVonng0bSKZXQP6nObMokarH3uOkgw2v +eo8gKHffQ/dA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ECBE367E2E; Tue, 30 Sep 2025 17:26:53 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:46 -0600 Message-ID: <20250930232611.1564850-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NSYMDWFQUDS2NKLPF6VVVDEUTOMN7KW4 X-Message-ID-Hash: NSYMDWFQUDS2NKLPF6VVVDEUTOMN7KW4 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 v2 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 --- (no changes since v1) 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 488cf7b9a7e..e6f99402d68 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -247,19 +247,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 @@ -310,6 +372,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! @@ -420,7 +506,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 23:25:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 461 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=1759274824; bh=PUpmDVWU4Ijeoal0NDRwPAxJ2t83+JpOD0blpaKT7TQ=; 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=BTW00xm67aNB2HWouh1tyzz/uW9/jQu+cL2t69Q7th2I3ZKA/enByanujNhnFq26o lX/UtYasP+iUE8ap6IX3VJokGtEaFIxF/Zv6p0+MG5wJtoC/9rnbZSC7CxcpA/KaSh Z+f+PTFjtQDqR8cjjCVRrLMK4KbIMjBmqMUMaLVUiHDu4DReRBJCODCVzDCEVOunuO qiARGMCdhE5oeKDebydBwd1NKbzf/q+DylBZlErcyZZ1VX/DjTJexOGAQDyEL2w+kw MPu/FpAsiRm0AfLQ5+vXDlL6mgtjvDRDx61Uvtcso0lfEqUf589sPZDI4efawsl/IQ eKqUNH+TCxmNg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A0E0C67E7F for ; Tue, 30 Sep 2025 17:27: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 10024) with ESMTP id YfJpvrI5-kn2 for ; Tue, 30 Sep 2025 17:27:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274824; bh=PUpmDVWU4Ijeoal0NDRwPAxJ2t83+JpOD0blpaKT7TQ=; 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=BTW00xm67aNB2HWouh1tyzz/uW9/jQu+cL2t69Q7th2I3ZKA/enByanujNhnFq26o lX/UtYasP+iUE8ap6IX3VJokGtEaFIxF/Zv6p0+MG5wJtoC/9rnbZSC7CxcpA/KaSh Z+f+PTFjtQDqR8cjjCVRrLMK4KbIMjBmqMUMaLVUiHDu4DReRBJCODCVzDCEVOunuO qiARGMCdhE5oeKDebydBwd1NKbzf/q+DylBZlErcyZZ1VX/DjTJexOGAQDyEL2w+kw MPu/FpAsiRm0AfLQ5+vXDlL6mgtjvDRDx61Uvtcso0lfEqUf589sPZDI4efawsl/IQ eKqUNH+TCxmNg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8EDBE67E2B for ; Tue, 30 Sep 2025 17:27:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274822; bh=2tGsHDk/lL4mv1FpIlx7io6zONxu3LMBBLE9Lv/iv1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRiwkymyEu44F42QZq77FwH1Ig8EFqXyZNdyaHESo4jtuTWEc2XeqBevhk0htHue1 rruNca0DpbtIJxf4VqKHAKMb/oaG3UzAS01lXw87jfVJB8wkkTS+c/qK+LYJPXyrfG bpMnwYCeArmL+Isi4vPBWOhQZygfw1T6NFj/ukytN7MTNwTWMhM+t1wtOrxoGFAiO0 3a6qGrMb1dWCiUxahT3ASz0iDAOf61UIJ4pYc+DALoBDPZ+cmrAySvFgF8k/Ypq4xl 5yrvHQLC9H/6p3wwnKG8QZ6fIsBa1HfdutPmHvdVt5axwWU8ZYaRkeeEeSd/iBsaae SYbjZMrSErgBw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CE9B367B5E; Tue, 30 Sep 2025 17:27: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 10026) with ESMTP id VEwKn6QOGbJm; Tue, 30 Sep 2025 17:27:02 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274818; bh=8TBgVWzTfAQ1OYW9LV1Qe7T8nB0+WgijEon9d+FhjBc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rlmRL5VVBbHsT0Kdca6Ehpi6SgziZBdkw+uvLv71ALMhIy9L5FW7tu+1c02Kg2M0v H3mIryYC6ZQeOaGAFyGULao08F+XxehY6DjKr9vyneo2VvQh/qY1sLAW15ageFsxGF +ASQY8RiJ44q4YhUQWpWoCLVVzAWXRxZmEE7r/wBZ58AP9YgFHrv/PH+87oJ2Dzz4H BCd7+iPZY46l3Zg4agLljYy3SBLRK9yJVCs7xCSuoRS/GcQe2b2CPI6F9nRRZmaPx7 +M6u071BLHouraG8qGd5IaaAix3R/N1NqBwvqLXHiNgJzzm0EJaDYXAcXDDMclEy5t 9VWh/bSJTAZtA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8768667E2B; Tue, 30 Sep 2025 17:26:58 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:47 -0600 Message-ID: <20250930232611.1564850-11-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: U7OGZTPL4E5AUX5QZLWXTF5G5HIGBYED X-Message-ID-Hash: U7OGZTPL4E5AUX5QZLWXTF5G5HIGBYED 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 v2 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 --- (no changes since v1) boot/bootflow.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index e6f99402d68..02b08eec641 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -356,7 +356,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 23:25:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 462 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=1759274830; bh=De22AU1AyvuNy1P2qWYgN72UaZAv78Sz5e/r1czldT0=; 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=RgFQgYRWbe9CDhdSDeAwkOSJdPPciN+dRsXMruvkT7RRCUYjnMgfiBDFW27uzC0Dp 3fVJr1DeeCnkavCWyVNSGKUySjx075zLFJi0FR3p2+c71nL9pNSIn+PY54NqILgRm0 3Sgc0YnKdMG9SiGtFtiV4JoKt6RZtJ8Qt/AKVip4B5ROofqWkQqCbVmTJM7ONl8xVm 7nX8CW41YHKg4GoHbzhnUX1aXy7L7XFdrbHPz30/wsdH1VLtSzHMMwxQe1gWX5GwxQ EPCA6w4r1/eMwbFXtpaZt8bSi5Bi2grBeACw3aUgSj145HeQyM2LYdpetO4nh4Hvrk BabJ9dlNfeIgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 24D1967E97 for ; Tue, 30 Sep 2025 17:27:10 -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 xpscao3E9IUY for ; Tue, 30 Sep 2025 17:27:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274830; bh=De22AU1AyvuNy1P2qWYgN72UaZAv78Sz5e/r1czldT0=; 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=RgFQgYRWbe9CDhdSDeAwkOSJdPPciN+dRsXMruvkT7RRCUYjnMgfiBDFW27uzC0Dp 3fVJr1DeeCnkavCWyVNSGKUySjx075zLFJi0FR3p2+c71nL9pNSIn+PY54NqILgRm0 3Sgc0YnKdMG9SiGtFtiV4JoKt6RZtJ8Qt/AKVip4B5ROofqWkQqCbVmTJM7ONl8xVm 7nX8CW41YHKg4GoHbzhnUX1aXy7L7XFdrbHPz30/wsdH1VLtSzHMMwxQe1gWX5GwxQ EPCA6w4r1/eMwbFXtpaZt8bSi5Bi2grBeACw3aUgSj145HeQyM2LYdpetO4nh4Hvrk BabJ9dlNfeIgA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CF4E67E2E for ; Tue, 30 Sep 2025 17:27:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274829; bh=a9vvaIom7ZVg8N2W0A0Z5e6QE3Ng6kW1dg1xFH0yggo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4pK57fS2mPGdPJzZ4ahfsCt8DSIZs/nNHjB9qH48CXRhEmvElAPkwyaNJJktnRU3 pBkADfTJyaL/BUHG4s2Iy/PS0VuSrtgsivBJDp7waFqOZ4VrOig43YMotN3kGlhv4D 7nb6seCuKvOh3M/ld9TTgiEGAr1sRHVPie/RqZbPgOpWuWx/9J3KaCdk2kH/1dHeMr f+7sOCgq4a0K6MGGO2BWYSvLOIesQkHgP+Hq2K3dPHFDMZpUJ4DlVw4bQZdkN5ok2d 0NUvJd4oS1JV3yhJgeVjRocfn3PCCfXXxTTcUvD/p9RG15PS9rHl2Nv6hvj0in3KhE AXFvXeFwqmlpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F74267B5E; Tue, 30 Sep 2025 17:27: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 10026) with ESMTP id sj88iN--xXI2; Tue, 30 Sep 2025 17:27:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274823; bh=+bxlAIbSNJQt7bzRVC4eoi32xU1O9Tyu+QqhuCeQhKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djzYGtfivd4pE4WPTFOVjBH5cvrSELd96Axfi+8j8jjcW+byF+FCVPnULq4lcDo0b SylWjBD/Ouixw+Qk+HAufPExGXnAK9WyUjuZtr8pNQpS5ppNY1V69ELlEZQoaxQK9Z GgffNpFl2SSGD+Hvr0o9gagzR1cA/Bx3COBZw3yArKHCGgxGGn/7ZiDsxVaFzIqCs3 oRBfaq1l7BLpb6D2YAMC2wjQJ6D4Ji3t9Dqo/dyqMYaPA4F8MAZHEIR4dwZb+z3B4U xmnuMU6ztESxZfAskVGCXbXpOL0Rx1U4NEDxskWoLWIsTBIDyCy0WehedvLG+tYfxl 5i2cRatInES4g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1C7A167E2E; Tue, 30 Sep 2025 17:27:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:48 -0600 Message-ID: <20250930232611.1564850-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: JMISZNZ6KW25CSRX7C4RIQKUHSW2DDCH X-Message-ID-Hash: JMISZNZ6KW25CSRX7C4RIQKUHSW2DDCH 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 v2 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 --- (no changes since v1) 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 02b08eec641..bdae861a96c 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -251,17 +251,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 23:25:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 463 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=1759274832; bh=JPE0ZrADVgSAZGKDJnb06xZUZ3LFokGZhwtemr9zoHo=; 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=SePaciluSUdq/cbYWyFd0EcJ+FgGp6+A0+fMQRfS/xCvl4bpSYBMr6y8v64lhqNcr RY92Y+9LBAyDM+99ZQ+W7Q/N+81sfwhomVgfE3PHb24jEDeUBqUl3q7tJ1eCzLZw1K dMXlBOLv1rLFSS96k8RP8eo0qs4roPbExjhn9d5C5jWazsif/VByBlAnVEBaGvhPq8 x0u7F7jcSkT87A4WCVBByTwcAVtQ9cfHy9Hx8OvGTL/JYNMoKttwvPWV7Uz4NH4Xmw J+Q2C9OIqacMwnoOXNw4+8TwIQx3NWR0YP1yAr3eO8WN+82npO4LbpP8R9NwTxzrVz T3ZwWzFfx32/Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9FEFD67B7A for ; Tue, 30 Sep 2025 17:27:12 -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 W4juXZhWhVy1 for ; Tue, 30 Sep 2025 17:27:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274831; bh=JPE0ZrADVgSAZGKDJnb06xZUZ3LFokGZhwtemr9zoHo=; 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=M+AhaomlemDaRUHfcAQYRgF3YeFkiZCNZv0iQobjEFXeJc/oxwzLYW+J6i4QAN5XB tJ1JdA+XnpbiMa1+Pbvx7u9IggUD61/Uoo+NGt4xfFrSowZMkDyw/idH55iAy1ZWIA RhuNhvotmKZMP9srj+1VWB8uW26ip5VyoqzfkKBoVbLXeoKa5aQpuE0a2eu2s2gg4O w+8NBuuUShlQ9af+joNMH4chXr4XtdT9mZWRfPwE+zuqxfZS0dt65uku8ew2JE2eDG ZXNRIeOWv8kQM5S4hx0unl0SctYfH7FDiZtcbccvp8b2YidVInA2Vg63z4Hob06atz oPuBoJtQJigJw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 07EC167E97 for ; Tue, 30 Sep 2025 17:27:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274829; bh=ABV3TGLNgOgjW/yCSlTkmswI7dKmWtQceEKJtctBfAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGxedr71u06n/JrJcTbLNfXEeeXLuITJ97kMv825jrnQi40Zd8QrqYg7NGelaZycF frES4M1gR57U2sVv/Rx+R6oBRzX+OHLJlGkZ6jyd65SZdm2WFJgcoP7oauj7AC+Ech AQWtM/jk3K9bKpb13APRHXjHaL0a15yRkoCIk+nYOQRjjt7+46k2DdJoI+ko47CRDZ fj7OxRBb7UzDoHYhsBFVnJHeth34EWJ5OfDW0bJ+WpqajfZdHPMaTurg9HfylEGfQ/ Inz9faUZ2uorGCl/pGYKIAaMSBkYaOUWlqnfaRCIHSap/hn+s81WHvdYfWbky9GD4v OagPD41y6JFgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 34ED167B7A; Tue, 30 Sep 2025 17:27: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 10026) with ESMTP id j-t6UI-oauum; Tue, 30 Sep 2025 17:27:09 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274825; bh=qfgxBHIW4O0e/3+vPPFXKivJSPdMLCsNveySAgFvecg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iWa4Qzp83i68YQt59YlXXrtq2fRNAJl9DnrM7KL6Xam4p2uPlPaXxUa8qMdAbPaai xMz0PXy1PjGpVF8f1BfL7mV5YTBcCNlbxI/IOMXZK+U1nhpVYYfC6rhejE1Zb7XOoy Ai1I5W4nVSEa75r0rFx12aIvHPSiiPcmF060kKZQct2sEFtM6eDnZJilTva1djjIZg 3OiYCePcp/OnywyWeL6pBUce5iwtS29kGC3Z51wGbNEx4Ek7j4q9PyYm1mfL82iQTb p1SamYCjd0tvLi7w+BISFgnyK0+UWZOD6Ax5qpLszVyiA3Y4QnsbGH195gXpHOdcuV MxceNUfvJtT0g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 26CB367E32; Tue, 30 Sep 2025 17:27:05 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:49 -0600 Message-ID: <20250930232611.1564850-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IAUNB222RVAPORVP6ADAMJF3ATPG5I2Q X-Message-ID-Hash: IAUNB222RVAPORVP6ADAMJF3ATPG5I2Q 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 v2 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 --- (no changes since v1) 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 bdae861a96c..98d57ef017e 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -366,9 +366,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); @@ -382,7 +393,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 23:25:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 464 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=1759274835; bh=R+J0vG1KIVNIdWkhAP0/QW8IwsiyqjF+iEhq+VVQUzc=; 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=OwnFQRNSGjcHdf699JqdHDrG5ICLdIfuqsf3UPFQdAMgdCYh4OXhAne+l3E+T/rJZ 9LFm6VLEsy3mJ2Zuwl6P/eBmtYclLb9SQq9nUFwyWWh/tUBCLrZPYea2WuOnJnUszs qxmMrXZ51NM92tRDdqpkV2JyaouFji8prSI4h6o1JLah0vmsUvHBNX/OuuRx4ELUyA am0NAd/cqPHTfyPPb2Naf8oLCcTxr72GKxTC9s3po0+7wPFjul8HOzpEmyphe9nAcQ qZBBlwk5CNW22iXUA4FRUJuCepLQfz/LgdhoV+QgEMZMooyBAIeCh3YC/SZR6JySpY WXs9uHssN3W1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 43D4C67EA9 for ; Tue, 30 Sep 2025 17:27:15 -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 Ud5oqZykv6Aj for ; Tue, 30 Sep 2025 17:27:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274833; bh=R+J0vG1KIVNIdWkhAP0/QW8IwsiyqjF+iEhq+VVQUzc=; 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=hVT0ilrBGQYstfzBoY7Urx1nqb1WkWKz1vlGR27+TrSu+cyJJ4CCn8rDX84DG2kY9 Cem1w/YpPKSf1LPcRXht3SIJTVlKFRvOPF3YO6VzW0nA3uqzofrWyU4QKZ+dXvSFcg RSrgqiAeiLFHOd3W3Vluc8bWDZIFrpyg40e4qWUTAHcx9+jdFpSlB253I8xsRF/S2Z CuOrNlnFq7R6B9ViQSV17t8bYpxBMroerJiCiRCIjQaQXOazPadQz5fKgBtsxbT1q5 4tyBXZLG8mKAf8vIIb9GRokQnfJ6HdHq1v21YhaZvcJ6RBXizrF/PnY2qmbM8fcu/e 5gud+rxTJQJHg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 779C267B7A for ; Tue, 30 Sep 2025 17:27:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274832; bh=yIZb12M0jUvo+l6cVFyKJRJFK8nVXiOmP2Ov03FqHGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L1S3kwr5BnxZFjDG/xNkfn7yE8hB+VZdBfXmxqH9N8aFqpjBgQ1wSZzvrp35VYzaK yrVY5ukKqMFHcp1infEUqJWaD48cnjM837lIsn1tNJOmFXktzmN3NxKwehDxs+vUFB 37dpKCL0jT62w2NzMvff1Yx2hznkcRBGy44ZR/FblM/ckZ2x7eeq+XPxUdZ3LkIhbW 9Bom5kGG8dVGDjnJf8pAObrRcu5XykWrRtdIr7qKQs1mL/0TU/GGgjXBjou3zMLOC9 7opMqItXQtF5iTHNY3YfHHvYSERfMZditTopm2nYRO7ZE9yis7NC+lwnpbolgzKFPc +JSDQG9YSjf3g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6462667E2C; Tue, 30 Sep 2025 17:27:12 -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 T0zNSuiolsYH; Tue, 30 Sep 2025 17:27:12 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274826; bh=scFlZwUmsjCrSQziZ+PM053KQ1+fFCVdM93rf1DqIcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A9r9uw082xXqH8FQKkCFmMXcatgOWbmjXkx3lXhMt2yiC2UbaGm2qiyxIRZ4HA7z/ e0sBJoZC+Z8NTB6mJVvbZy5xAsfGIKU+aDJYFp0J/RJsE/O5gxnQG+O1i/sPqYP7jt Muadac375Zc+uk/Y27i1WdCtDite3YUNz9yHMl4Ul0VEXkNTZZ7c3/lx8DuldcIvVc qLq5d/MKngP6TPtzUpkjITKWAH10DCsoeLhZJMH7kFM7XUpeCOZRkkddiJhSO9Aen9 sDQhUgeARHDIiG7GRYwAiYtej7C1b/4VqUmqH51rXcj60nnmapeRPIDVdQhAG0NwE2 SKtbq4Hiqn7bw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ED97267E7F; Tue, 30 Sep 2025 17:27:05 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:50 -0600 Message-ID: <20250930232611.1564850-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 7S5SFJLWA54TVUFZFQLUX3ICX4LQSIH2 X-Message-ID-Hash: 7S5SFJLWA54TVUFZFQLUX3ICX4LQSIH2 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 v2 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 --- (no changes since v1) boot/bootflow.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/boot/bootflow.c b/boot/bootflow.c index 98d57ef017e..30e0644a09e 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -419,6 +419,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! @@ -532,6 +544,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 23:25:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 465 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=1759274835; bh=pfkrY4V5BRJclwxtoAAM+bDwxt00+pycULPHwQCtQnQ=; 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=UdBKDj15AvMnyW4cL7k9hh4JiJaePy8WMRyXB5LCf7zmUGmhVwQKnHoc+UhHzV5Ri wkQxGE45v8OApTQKXSSUUlb00vmTOAFq0oZeHkudlmdTlYv3aqoSj1yStzxMaoOFnm Kpls555MtuY94DYzw3SiKLmMFmhUx2Sku0+py9vnT1Flr2HW0XU6ruBwdNeOp0izvj hwdiJqHbwKGqgZG++1pqDBD3GjbIKOTo5xFrDgsT328V33qVngpkbcn+gKP4lRgI2B HSKILB126AoCC35Z4KBhPZmp+sPQukwH9ecRucoWIpYe349bpBubbo1wMkotvmZdGR uiMugZRHoZklA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AB59567E2D for ; Tue, 30 Sep 2025 17:27:15 -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 x2N34eCKQaQY for ; Tue, 30 Sep 2025 17:27:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274835; bh=pfkrY4V5BRJclwxtoAAM+bDwxt00+pycULPHwQCtQnQ=; 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=UdBKDj15AvMnyW4cL7k9hh4JiJaePy8WMRyXB5LCf7zmUGmhVwQKnHoc+UhHzV5Ri wkQxGE45v8OApTQKXSSUUlb00vmTOAFq0oZeHkudlmdTlYv3aqoSj1yStzxMaoOFnm Kpls555MtuY94DYzw3SiKLmMFmhUx2Sku0+py9vnT1Flr2HW0XU6ruBwdNeOp0izvj hwdiJqHbwKGqgZG++1pqDBD3GjbIKOTo5xFrDgsT328V33qVngpkbcn+gKP4lRgI2B HSKILB126AoCC35Z4KBhPZmp+sPQukwH9ecRucoWIpYe349bpBubbo1wMkotvmZdGR uiMugZRHoZklA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 21BDD67E97 for ; Tue, 30 Sep 2025 17:27:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274834; bh=uZeMIlqb9dC+1GTs7elGQPWV/17hU5XOUxJaYFFDpE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ki74/0cRdvL4bGxd+8C3cjUlBdYZ8G8qHF/DY6wQqOwRB5wRUndw1L2fH5z6fphid K81Iciul7Xm4zgBc62LgJd6m5Ydt3qOsqix8abK1MP+kVm6+6iAtAUySGDM+vnbgoG g7L4Biv8TW7nSUJ3KMaMzaeEYZyQZNuwHl+tvVBnDT3mZ+IBT+qzLo4m/yjdrLtAUT ZxmJE+7y4FUMCFztlAKB+lHlpBcpF7qJqpwJfZb9xEEjRR8dHKvKUKeOoHT2ASM0MX cMinHdg/E8OK3CLItmL1m7Kmhobe6DQa2cBtFnu6F6CNoFc6mZdM3JCfRMqGVe13x7 facXpjEGryR+Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 144B767E2D; Tue, 30 Sep 2025 17:27: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 10026) with ESMTP id rv-SiojwKRcw; Tue, 30 Sep 2025 17:27:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274830; bh=BRtil7tllHKoDx0KPajjqzGQK0/pEB7dsIXy/8PLOxo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CvPbqAIAx650hmQxZpVd7L9Q45UlkqZ5vesqiLmy+tXen6H42BoWAeViISNQ69V+Q VUFLXvKXSdTCKYv4lyBK+tjr+q+mVRmnDrO83MyiteBrzIKIxNi07BUvAlqWZvdsT+ vCP6MNgkkYIgTyAYrTw2sFcL3Ouuoq3lvC1gOONzJHLCkHhmXN2bsmglfNr2WXWKvk l/OLepkfiQuVbB30qk1W0kwaeAC9fs8CjRcbDFMBe1AixUvkIUpAXTuU/yKtyKhRxt mml0wIxc+PsVv/zMPMv3/7lt1wYK1PKA1gqhB4yORWBHRIeeis+gqvNPiiJ2m4duop IoyS+E6BmU4UA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8498567E32; Tue, 30 Sep 2025 17:27:10 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:51 -0600 Message-ID: <20250930232611.1564850-15-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZBOT3XP6L3AUGJJHI6S2TY7MGK2AQFUL X-Message-ID-Hash: ZBOT3XP6L3AUGJJHI6S2TY7MGK2AQFUL 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 v2 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. Note that if there are no hunted network devices hunted, then it will run at the end, after all bootdevs are exhausted. In other words, it will always run. Signed-off-by: Simon Glass --- Changes in v2: - Update commit message to indicate the bootmeth will always run - Document how the priority was chosen boot/bootmeth_efi_mgr.c | 9 +++++++++ test/boot/bootflow.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/boot/bootmeth_efi_mgr.c b/boot/bootmeth_efi_mgr.c index 5e83d1da103..6e0ca02d0a4 100644 --- a/boot/bootmeth_efi_mgr.c +++ b/boot/bootmeth_efi_mgr.c @@ -99,6 +99,15 @@ static int bootmeth_efi_mgr_bind(struct udevice *dev) plat->desc = "EFI bootmgr flow"; plat->flags = BOOTMETHF_GLOBAL; + /* + * bootmgr scans all available devices which can take a while, + * especially for network devices. So choose the priority so that it + * comes just before the 'very slow' devices. This allows systems which + * don't rely on bootmgr to boot quickly, while allowing bootmgr to run + * on systems which need it. + */ + 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 23:25:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 466 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=1759274839; bh=q1lg4hohrxqW0wwNyL+LBl3X6H2oOroXqrB6Enaq3Jg=; 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=rFdulpaoyh3e49/XyS0qVzIWCAMLMArxX5GPHyrk/7RffdzSnr46Ku6wtq7xXqC21 7umucpJdyKxnIeFApOVXDWNMrJ3xVTY0vRuLacEmQ2lHajSftJzW5VEtwC++bZGgky l8RGNYDgICUeTeS+ujtSo8O5AQdRM2JqXhbxva4Vl5IeQ2n+VJ3ywsShBlha54s1DE GgS5a8ssfLcG6qy/CLWyx62ff76tVloLbCm+xwZHxNxVHG1XMPXaGsUQX9Bvqgwdyf zRyGiyI94pVZtjTG73C9oeWz+U/NMws0o3sBQ3BO9KlzvWMWOVzMMPiIuOKFwq1XfV maJ4hbrm3NKAA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9C6AB67B7A for ; Tue, 30 Sep 2025 17:27:19 -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 4ImWTLdPf8CF for ; Tue, 30 Sep 2025 17:27:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274839; bh=q1lg4hohrxqW0wwNyL+LBl3X6H2oOroXqrB6Enaq3Jg=; 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=rFdulpaoyh3e49/XyS0qVzIWCAMLMArxX5GPHyrk/7RffdzSnr46Ku6wtq7xXqC21 7umucpJdyKxnIeFApOVXDWNMrJ3xVTY0vRuLacEmQ2lHajSftJzW5VEtwC++bZGgky l8RGNYDgICUeTeS+ujtSo8O5AQdRM2JqXhbxva4Vl5IeQ2n+VJ3ywsShBlha54s1DE GgS5a8ssfLcG6qy/CLWyx62ff76tVloLbCm+xwZHxNxVHG1XMPXaGsUQX9Bvqgwdyf zRyGiyI94pVZtjTG73C9oeWz+U/NMws0o3sBQ3BO9KlzvWMWOVzMMPiIuOKFwq1XfV maJ4hbrm3NKAA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8A95067E2B for ; Tue, 30 Sep 2025 17:27:19 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274838; bh=leXV4Pyz5Gj8gW6zEyvO1E1daGxcjUnorDcxA1ymer8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tyi551BVG4AOqSOvxGJJAC4FxVK2DIY8rygYiOJ0Y6XlDh2pvQovMtZ4GZQkOfBOn HSb39/XdzQ5CVEpmSqtXCexoRmeYGIS5wbQoI7QL0cWbI8x7n4YicVmjIl7azi8osR NIc4XZVn3WWCAdEBnu72Z/8ZmoTW+cL/OxLBcNrKw6IDhJ0lA8Idcj1bD2E1at8DHQ wAKGqEGa0/mtnkOJUv/W0KE2SQhI4ufWJCMR2Tds2ycg9GP5J9JbWyEZXAvsjFnSZX rg4zKqDyNnXyCHFJTV8Bsu2REzSrCneHhtiw/KGTP0pk3jKNqE+CdBD6SmTlNyL/FU 2D77CpeWdIl7Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2899A67B5E; Tue, 30 Sep 2025 17:27: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 sykbUGbMT5OW; Tue, 30 Sep 2025 17:27:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274831; bh=LhdM68z6t1M9+DY6b83yWkmEnj8lVBjyEat6sDMRNpc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r0vFCjXoGBmM38oyHolafrjny3SqlC4lQR6J/sZYsJ/yjT4xGWNglecAKzHOGr4yF 3TPumh4FHyaxhc4yzSNvfyG8ARE+E6i+jaC+JObe7mYzVchJs8XPlSGzxCYIxpd/A2 5PHPugOac8xxN1Kvd8hd9ODT0MWx7uByr5xNysoXj0klyGAIQqZAeSza8D97bKawYC +fh2suxw0/Fvg233FI0aAbb20D3bEtR8ScUybiJF9AAOx8B8RDpYC9kj76xnbl3J/Q 77F/Ls1lw7f0e8tCWEdHZilWldeRE79OJwTKCnSMhgA0n2BG9Wn/LRChTE1n0vvecE xiHfbFlUJAqeA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 615E867EAB; Tue, 30 Sep 2025 17:27:11 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:52 -0600 Message-ID: <20250930232611.1564850-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZP3IZA54C7EYPPTGOZN76YSQX3K63XZK X-Message-ID-Hash: ZP3IZA54C7EYPPTGOZN76YSQX3K63XZK 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 v2 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 --- Changes in v2: - Add a bit more detail suggested by Heinrich doc/develop/bootstd/overview.rst | 40 +++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/doc/develop/bootstd/overview.rst b/doc/develop/bootstd/overview.rst index ca76bad7bca..208c371bb0e 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 @@ -716,8 +717,35 @@ to the next partition, or bootdev, for example. The special values `BF_NO_MORE_PARTS` and `BF_NO_MORE_DEVICES` handle this. When `iter_incr` sees `BF_NO_MORE_PARTS` it knows that it should immediately move to the next bootdev. 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. +so it should immediately run any unused global bootmeths and then 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. + +It is important to note the special nature of global bootmeths, with respect to +priority. If there are two normal bootmeths and a global one, the normal ones +are run for each bootdev, but the global one is independent of bootdevs. The +order might be: + + bootdev priority 3: normal-1, normal-3 + global-2, prio 4 + bootdev priority 5: normal-1, normal-3 + +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