From patchwork Tue Sep 30 00:51:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 448 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193553; bh=Or4rQv8gYhWYv7bVaKk6p0WoSEPOK4yeZM4jhumpPNg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=eaFkABg498gaei9Ggd/ZB7MvdYvvsClsBwcdFYbteUbhanGAfFpWHLpPuGbM0BHFM TeCzJSkyYwY4X1x71yR0zeriJ/fAGIp0+rivG+ki+hQMHm0xnKkrsBxmVRFhd8Gf8X oCCaZaIfxDrb6c+4RoSatqHDoM00+1Cr6zCeRC79OZy44adXoxv2O7DArWceovLL8o qaGNJ3OB5YfLwsDNljbZYPDwcBSlJjY2bdtQ5CM6KyrC8O3+NdzdEEyZtpFYguyzzF gkj2qu/cCGOggw7V/a74QwEoL3YDbhqHa56zumixcK5lkxR0H3GJ+R3uynlmXbwWoa NqgFfLsbGS9iQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A51A067E5E for ; Mon, 29 Sep 2025 18:52:33 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id D10yAT65lpEq for ; Mon, 29 Sep 2025 18:52:33 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193552; bh=Or4rQv8gYhWYv7bVaKk6p0WoSEPOK4yeZM4jhumpPNg=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BEPfuJTB+SJsl4HNQrhIcAvXVTXI9D8x/bhCBY9XnHTU7TnmtKThVJ+vFCAhAXOc7 n+Aj8rptEiylYLc7E6lUhuMMDXDYXVaPwsS/Fra6oogaXA9rQP4TAsWUVOO89DZJC/ erFrsAFsVRYvPDYTyYbwFvxZscKBir48msH4W3kBvXZ8KMliY4DcNGzwN5Su75RNb2 Xj1lPiRKDGxN7hnX4nnYYBXsWs9dbKxLgT37wop51QGAkmJamaQWFYD9K6TrLI0WCg Cjy/ciQtKDC4zKsAXiZc+Ty2qQ90L5UuR/ymPuasICmJ3SNt88nOps19ugaXlVHKgu F8QQAx9vOVpfA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B578767E00 for ; Mon, 29 Sep 2025 18:52:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193551; bh=tdgE5i76CqAX/ZAu+SN7Muus3AGgVIm1gx3icfdp2Kw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXysyiMhpyqvpldUoeshXsHKSZmzr9WFvLVwHUXoW0PCkc+I0qwfGFFQBudMRvXLT iqwJUNScxOTQQQUMH4OOCeX1ynwXirsgsWkfiI3orq6S799rdaFCXKinmPw/Qj/rAl 9cOJXebUZr4oP86jpfoVE16QYV8tt7Vt0LBkILAFfZIPjXUlYT2dN828JM3FOTTeMj BqxUaU3trFDlDtOOOfPqM0QsPRxkYrhKuefuzJTp+5O//x+J2T8eo/W63z5e95pSQv 6j4ruTXBhboCHFi+3h/L93PqFoqZCtJp1F+lz9XD5cB+Lbm3Dw3Dmy3B95Ux5A9289 8dONV79sR1b6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 56B1F67E79; Mon, 29 Sep 2025 18:52:31 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id 70h0gRh13ldm; Mon, 29 Sep 2025 18:52:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193548; bh=FY05Z7CrvNLYy09x+88j/4/01SHrEkpRFVVMQ1GLEek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=plh6W7OhAAnz6NkJ64jhdS2UYE+eGWHX0id4T49+fC/KoF6VXVmF2EKUZjg282SNW B8yDcbNUmGAh5EwjvLYg3TmbyWDZIvxoNorG4yL0bw3gONVkMPr9aN/r01QD0rRDIp t8GwsT5cuZ28CluOneLVEOjQ9fUBIUkhUYxky9uWD8R4UmIlxj6aSwVUFlXVgfeNkD C3vLwumn5PTCDtiQZkJgEfn01I3kGZlU+RX7VoiTFIIPpOazQXkvrAyJIaMQKvw9ul oJhvWNtJPMOBwfIfrwx5ibQlrH5j9N4ui56rEnibGePEzPceY6E7hv9ZpYDGsRlUQq 5dpDxaVqkrbbA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 13D5D67E04; Mon, 29 Sep 2025 18:52:28 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:28 -0600 Message-ID: <20250930005137.3650600-13-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: ZVBT7FHCED3IWNH37TU5XLA3BKS6TQC7 X-Message-ID-Hash: ZVBT7FHCED3IWNH37TU5XLA3BKS6TQC7 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 12/15] boot: Don't change the method count after global bootmeths List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass At present before scanning global bootmeths, the iterator sets the method count to the index of the first global bootmeth. Now that we support scanning the global bootmeths multiple times, we must leave this count alone. Check against have_global and first_glob_method instead. Signed-off-by: Simon Glass --- boot/bootflow.c | 18 ++++++++++++++---- test/boot/bootflow.c | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index becb2ef109f..e58c55ebf19 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -364,9 +364,20 @@ static int iter_incr(struct bootflow_iter *iter) for (iter->cur_method++; iter->cur_method < iter->num_methods; iter->cur_method++) { /* loop until we find a global bootmeth we haven't used */ - if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global && - !bootmeth_glob_allowed(iter, iter->cur_method)) - continue; + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->doing_global) { + if (!bootmeth_glob_allowed(iter, iter->cur_method)) + continue; + + iter->method = iter->method_order[iter->cur_method]; + log_debug("-> next global method '%s'\n", + iter->method->name); + return 0; + } + + /* at this point we are only considering non-global bootmeths */ + if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && iter->have_global && + iter->cur_method >= iter->first_glob_method) + break; iter->method = iter->method_order[iter->cur_method]; log_debug("-> next method '%s'\n", iter->method->name); @@ -380,7 +391,6 @@ static int iter_incr(struct bootflow_iter *iter) * normal bootdev scan */ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && global) { - iter->num_methods = iter->first_glob_method; iter->doing_global = false; /* diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index af7f7391160..ceab3c453c4 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -467,7 +467,7 @@ static int bootflow_iter_glob(struct unit_test_state *uts) ut_asserteq(-EPROTONOSUPPORT, bootflow_scan_next(&iter, &bflow)); /* at this point the global bootmeths are stranded above num_methods */ - ut_asserteq(3, iter.num_methods); + ut_asserteq(4, iter.num_methods); ut_asserteq(3, iter.first_glob_method); ut_assert(!iter.doing_global); ut_assert(iter.have_global); @@ -534,7 +534,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) ut_assertok(bootflow_scan_first(NULL, NULL, &iter, 0, &bflow)); /* at this point the global bootmeths are stranded above num_methods */ - ut_asserteq(4, iter.num_methods); + ut_asserteq(5, iter.num_methods); ut_assert(!iter.doing_global); ut_assert(iter.have_global); ut_asserteq(4, iter.first_glob_method); @@ -546,7 +546,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts) ut_assert_console_end(); /* Check that the sandbox bootmeth has been removed */ - ut_asserteq(3, iter.num_methods); + ut_asserteq(4, iter.num_methods); for (i = 0; i < iter.num_methods; i++) ut_assert(strcmp("sandbox", iter.method_order[i]->name));