From patchwork Tue Sep 30 23:25:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 32 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=1759274785; bh=mzsOy76BlEyIENf0o2ZkVGp+XIs8Acwsjmo1lxPRlPM=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=uWDmTl+t0BYJTJoy2sInole5f1p2s14NeHV+OGYB0ZHaR54UYbWbSkW1j+QNT21Ae Lvy4j2yxuNbFAQwWoLb1JvfktUOxqIOxUzLlO6AkkLVn2wKcral1gxMwrMnbW+CIJD TZi/iBBu+xNSuzlZJ2VlEB3LiQdNj2vj8FcT/Y2hT6MXiEr0fzwfykkEKFjQmQyARB 9dTmmsBzTC686y5krOFR/ViJPzs9um0hrdSXcOXj6j5CqA9GtrkKQqm9HGOk7FuXH/ lXxxSyBQaVPdPANKIKlvdGXShC0Bup/Mxw73IgMUmbl2p6ivpC2xYwyeWsUZUAwOyG pI00cjl1kgQTQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A026C67E7F for ; Tue, 30 Sep 2025 17:26:25 -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 ao8zwwabExVb for ; Tue, 30 Sep 2025 17:26:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274785; bh=mzsOy76BlEyIENf0o2ZkVGp+XIs8Acwsjmo1lxPRlPM=; h=From:To:Date:CC:Subject:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=uWDmTl+t0BYJTJoy2sInole5f1p2s14NeHV+OGYB0ZHaR54UYbWbSkW1j+QNT21Ae Lvy4j2yxuNbFAQwWoLb1JvfktUOxqIOxUzLlO6AkkLVn2wKcral1gxMwrMnbW+CIJD TZi/iBBu+xNSuzlZJ2VlEB3LiQdNj2vj8FcT/Y2hT6MXiEr0fzwfykkEKFjQmQyARB 9dTmmsBzTC686y5krOFR/ViJPzs9um0hrdSXcOXj6j5CqA9GtrkKQqm9HGOk7FuXH/ lXxxSyBQaVPdPANKIKlvdGXShC0Bup/Mxw73IgMUmbl2p6ivpC2xYwyeWsUZUAwOyG pI00cjl1kgQTQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D6C067B5E for ; Tue, 30 Sep 2025 17:26:25 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274783; bh=QHXleX0DVMsnRYLeYCUq0AfaTGxjOYwisOmCXm+jmlE=; h=From:To:Cc:Subject:Date:From; b=QJFNLwY6saYpxhJDGjFvQOiUI0VKm9Bh4bySwTtRhHAgl7UEeoiTF/lJxwUTfwNj9 U2ZZCEAl2TRUBWCQIQ5rFw7Mvi89gemHKujYCpHavDwP8Cbj2TjaEBl73APGNlW36q 2Q1El+zHfX2ijypI7N7wnSa0N+b6Ht0U9xsyBuQeAoJxxxigeVSCXmjEKXKAAqyT2Q u/0Y06tr7wF1g6eFLvLdT0TMPiXyvLw2uLEf7ftzlXDzraR1k3IiZtN6nMx2tAQhFc +Q6xAZ2QN6I7V6lbWtCrT1yAcgQl7hBEBP5B8hVuhx7p0BFzZshb+CEk4qVEXkU46s VvQnfdaB+ctYA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AD84967B5E; Tue, 30 Sep 2025 17:26:23 -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 IGwVnsZGFbSl; Tue, 30 Sep 2025 17:26:23 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274779; bh=CsxlveZgqBvDrz0CX++ETWBGkkWn3lgIwfg4sTp1lak=; h=From:To:Cc:Subject:Date:From; b=cv9GX/NgxGIvRIJsMvusnh71MvGFgfRraW06qU8WIDuWPLtNtM5Tx9/DgBoX5ccaY u1vfgAhf0Y9BRZGksYNtp260DZNbxwqxUSnQQTR+YiDFXyob/YAbKdV6a8zCFBWtXe KNL3/5gJUcr6vhFDcEMvvcTKuVoJuGUDMVUFHhUr5zLl0MypELprMfp6CKqrlu4HC4 dXVfudnKjHvSAiS3HV7cbL382OJAlQ0BlQbNnCHLG42vNteYW+mZ3k4zVg3JNFLwi/ obiYJp6oQv69Fy31aOICpsCf3KHB/Y/nt9Yw7+MVsidB2YH8kPMknjrU2HQp42ojZm ROwJA4gvrHaqQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 498C767E28; Tue, 30 Sep 2025 17:26:19 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:37 -0600 Message-ID: <20250930232611.1564850-1-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: L2VGLWVGVUNDS7J462ENYCLX3ULMZTMN X-Message-ID-Hash: L2VGLWVGVUNDS7J462ENYCLX3ULMZTMN 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 00/15] boot: Support 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 At present global bootmeths always run first, before all other bootmeths. Optimisations in the code take advantage of this, putting them at the end, so they can be used once and then forgotten. In some cases it is useful to run global bootmeths later in the boot. For example, the EFI-bootmgr bootmeth may itself scan devices and the network, so running it first can hold up the boot significantly for boards not actually relying on EFI-bootmgr to boot. This series introduces a new field in global bootmeths which indicates the priority, using the same scheme as is used with bootdev hunters. Thus it is possible to insert the EFI-bootmgr bootmeth just before the hunter for network bootdevs is invoked. Despite the simplicity of the concept and the relatively small series, this is a fairly significant enhancement. It is also quite tricky to implement, largely due to the way the original code was written, with global bootmeths being a small, size-optimised add-on to the original bootstd implementation. For now we only allow each global bootmeth to run at most once, but this implementation is written in a way that we could relax that if needed. Then the bootmeth itself could decide whether to run at any particular point in the bootflow iteration. Size growth is about 390 bytes on Thumb2 (e.g. firefly-rk3288) if CONFIG_BOOTMETH_GLOBAL is enabled, which it normally is. With that disabled (which saves about 4K on the same platform), there is no growth. Changes in v2: - Add a log_err() for an invalid state - Update commit message to indicate the bootmeth will always run - Document how the priority was chosen - Add a bit more detail suggested by Heinrich Simon Glass (15): boot: Improve comments related to global bootmeths boot: Add more debugging to iter_incr() boot: Move showing of bootflows out of the command boot: Add a new test for global bootmeths boot: Update first_glob_method when dropping a bootmeth boot: Add a flag for whether there are global bootmeths boot: Keep track of which bootmeths have been used boot: Move preparing bootdev into a function boot: Support rescanning the global bootmeths boot: Only run global bootmeths once each boot: Implement a priority for global bootmeths boot: Don't change the method count after global bootmeths boot: Run global bootmeths after all bootdevs are exhausted boot: Run the EFI bootmgr just before network devices boot: doc: Update for new global-bootmeth features boot/bootflow.c | 277 +++++++++++++++++++++++++++++-- boot/bootmeth-uclass.c | 15 +- boot/bootmeth_efi_mgr.c | 9 + cmd/bootflow.c | 68 +------- doc/develop/bootstd/overview.rst | 40 ++++- include/bootflow.h | 29 +++- include/bootmeth.h | 4 + test/boot/bootflow.c | 73 +++++++- 8 files changed, 419 insertions(+), 96 deletions(-)