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