From patchwork Tue Sep 30 00:51:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 441 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193534; bh=bOiwz8cWht8R8j7By4jpeiyRz+Zm9wabdicsT3Enooc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=m4VVzTF+pU5VOR8uD6j/qLR1kIBbrl45fj4jCqD8HQ9SZ3IbMpfbLtA5MAXUnZsAg qm2zTStqVVAWcoQ3CXt2t8fBghCHeXXEDnmcgsSbGYfUb6Qh0W5G0zk5VffPQq3PWd skdvC7ocYxuFy3Yi4thYyCeih8pz1UwlcfmnU4Jh0ZNvivBGdWhVMzpKh7z+g25bZ5 UPPPAbDLURDVr3hHZ2BLawPlGehEaC5Yvz/ibPlUCCHbWVExlehbYAvGy7TLe/bQfr q7Jm5ffGsXgeXGCeP3eE+JKX6aMN1kRAWCS6CzK10GioJqsBv6fp4ohumermOJxsS4 vKQdbYeV6hb2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0EED367E59 for ; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id apchU5P1CVAx for ; Mon, 29 Sep 2025 18:52:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193533; bh=bOiwz8cWht8R8j7By4jpeiyRz+Zm9wabdicsT3Enooc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=cJJ3LqNtACMqsB+6B9sXzPgdU+8oPhkCGz1Fd7bIv9Hw0v18/AQB3bUsRN6gmPDp2 gcU7poQSWExDxP6yOVIoH07KseuxDT4NQ2/5Bb9nzvh4y4SUZE23L0bMSQa4aPxGrS Oyt5ffZk58ekCn6lFTxzJs3I0GcQRjQ2NJ0n8lIc8qdPt0zxnP9h5Oi9/LjxMOM2VV nxM1tP5Il4sR5IvYS0qTZV/xdUXCj8aVe0v0jNhewX7Q65B07blFKzhSxad9lliHYT VQPVUdqiE1i8vTr1xairBMvUfq6NWWhyRDxw5fb+VW1UhOuj+nrPenOuhNOhFVqpgM tOv3hpFBJMQog== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F215067E31 for ; Mon, 29 Sep 2025 18:52:13 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193531; bh=M0CI2aAeqRLe6kDzWHmuYMUOS94aLb9IrcLYp3SJXxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVjHMpkP7UDB7l9WJPLZ322I8HaVMkPrKB1zHF6qxqRXajKXum+nhe9xCdrTwPm/1 94RgHBj9Ug+LlqddogStkT7ah1Kp6CQ5Tbe3R9s9sjTrihja+oW2p4ng4MMBJQO705 uD5C8kvD6/Cw+z3X088cxscY9G0jn5ot8JtRAdB5Dn52C3ga0v4n2yf43ZY/BV3osT PNwr34hCedOGdQ0X5cDg5sDgmEXq79L05NrJeb344RfwdhcNiSqjn8SR6pnT6P4yDq uUNHbXSmtZbkmkmGP8GsTJb6PJYCDRuPePs5WQB721oY6pnek9QunBnqTMerjvTbDU 51B3n/VG9DTXw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7692C67E57; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id lDY2uMY2Kzcb; Mon, 29 Sep 2025 18:52:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193528; bh=HIWiRA9chOokrUqb+3hfbruNw6Wm94a5qFZdkAXsFoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oCep1eA4DVnZb2Z7HMq45SQ6rooMUh6gf7tABpdSQ2ubiqdH+aSreYF2Zr1Lsg351 5s9tGddcGXvCv0OJhyVZhCfZ0bYaiOVY5mlParV75hODtqn41Kf/NabcaLjBzTAXAj L9HEUBQ6qn+6EqOepmPxfIb70ef4n3SrMB1MGWZAZGUrsFI5kZ0o1LEF/RD4t6nn9f LzFKd7e4YhO09iB9H2FOiqIGtJ4L9qQ+wUeQ1N3oPiB6BdYO1OeyUsMozQ3n80fo2e yL6MkZqokqPE9/HSOUTzFcod7E1svlc4HDayEqz0C8dHdR8UvjwEfZO5dYwE0gKtE+ is1W7U7y42+Rw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 34C9E67E00; Mon, 29 Sep 2025 18:52:08 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:22 -0600 Message-ID: <20250930005137.3650600-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: XICTB64POEOLFWQM25YNROUFSN7OHYDQ X-Message-ID-Hash: XICTB64POEOLFWQM25YNROUFSN7OHYDQ X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 06/15] boot: Add a flag for whether there are global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The current 'doing_global' refers to being in the state of processing global bootmeths. Since global bootmeths are currently used once at the start, it becomes false once the last global bootmeth has been used. In preparation for allowing bootmeths to run at other points in the bootstd interation, add a new 'have_global' flag which tracks whether there are any global bootmeths in the method_order[] list. It is set up when iteration starts. Unlike doing_global which resets back to false after the global bootmeths have been handled, once have_global is set to true, it remains true for the entire iteration process. This provides a quick check as to whether global-bootmeth processing is needed. Signed-off-by: Simon Glass --- boot/bootmeth-uclass.c | 1 + include/bootflow.h | 2 ++ test/boot/bootflow.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 152c334f205..0147b97fcb0 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -197,6 +197,7 @@ int bootmeth_setup_iter_order(struct bootflow_iter *iter, bool include_global) iter->first_glob_method != -1 && iter->first_glob_method != count) { iter->cur_method = iter->first_glob_method; iter->doing_global = true; + iter->have_global = true; } iter->method_order = order; iter->num_methods = count; diff --git a/include/bootflow.h b/include/bootflow.h index 6f53a7d4991..0805d10e197 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -268,6 +268,7 @@ enum bootflow_meth_flags_t { * @cur_prio: Current priority being scanned * @method_order: List of bootmeth devices to use, in order. The normal methods * appear first, then the global ones, if any + * @have_global: true if we have global bootmeths in @method_order[] * @doing_global: true if we are iterating through the global bootmeths (which * happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev @@ -291,6 +292,7 @@ struct bootflow_iter { int first_glob_method; enum bootdev_prio_t cur_prio; struct udevice **method_order; + bool have_global; bool doing_global; int method_flags; }; diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 7748a5ad534..a18afad0f72 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -314,6 +314,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); ut_assert(!iter.doing_global); + ut_assert(!iter.have_global); ut_asserteq(-1, iter.first_glob_method); /* @@ -444,6 +445,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts) bootflow_show(0, &bflow, true); ut_asserteq(4, iter.num_methods); ut_assert(iter.doing_global); + ut_assert(iter.have_global); ut_asserteq(3, iter.first_glob_method); ut_asserteq(3, iter.cur_method); @@ -460,6 +462,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts) ut_asserteq(3, iter.num_methods); ut_asserteq(3, iter.first_glob_method); ut_assert(!iter.doing_global); + ut_assert(iter.have_global); ut_asserteq(0, iter.cur_method); ut_asserteq(0, iter.part); @@ -525,6 +528,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) /* at this point the global bootmeths are stranded above num_methods */ ut_asserteq(4, iter.num_methods); ut_assert(!iter.doing_global); + ut_assert(iter.have_global); ut_asserteq(4, iter.first_glob_method); ut_asserteq_str("sandbox", iter.method->name); ut_assertok(inject_response(uts));