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));