From patchwork Tue Sep 30 23:25:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 462 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=1759274830; bh=De22AU1AyvuNy1P2qWYgN72UaZAv78Sz5e/r1czldT0=; 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=RgFQgYRWbe9CDhdSDeAwkOSJdPPciN+dRsXMruvkT7RRCUYjnMgfiBDFW27uzC0Dp 3fVJr1DeeCnkavCWyVNSGKUySjx075zLFJi0FR3p2+c71nL9pNSIn+PY54NqILgRm0 3Sgc0YnKdMG9SiGtFtiV4JoKt6RZtJ8Qt/AKVip4B5ROofqWkQqCbVmTJM7ONl8xVm 7nX8CW41YHKg4GoHbzhnUX1aXy7L7XFdrbHPz30/wsdH1VLtSzHMMwxQe1gWX5GwxQ EPCA6w4r1/eMwbFXtpaZt8bSi5Bi2grBeACw3aUgSj145HeQyM2LYdpetO4nh4Hvrk BabJ9dlNfeIgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 24D1967E97 for ; Tue, 30 Sep 2025 17:27:10 -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 xpscao3E9IUY for ; Tue, 30 Sep 2025 17:27:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274830; bh=De22AU1AyvuNy1P2qWYgN72UaZAv78Sz5e/r1czldT0=; 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=RgFQgYRWbe9CDhdSDeAwkOSJdPPciN+dRsXMruvkT7RRCUYjnMgfiBDFW27uzC0Dp 3fVJr1DeeCnkavCWyVNSGKUySjx075zLFJi0FR3p2+c71nL9pNSIn+PY54NqILgRm0 3Sgc0YnKdMG9SiGtFtiV4JoKt6RZtJ8Qt/AKVip4B5ROofqWkQqCbVmTJM7ONl8xVm 7nX8CW41YHKg4GoHbzhnUX1aXy7L7XFdrbHPz30/wsdH1VLtSzHMMwxQe1gWX5GwxQ EPCA6w4r1/eMwbFXtpaZt8bSi5Bi2grBeACw3aUgSj145HeQyM2LYdpetO4nh4Hvrk BabJ9dlNfeIgA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0CF4E67E2E for ; Tue, 30 Sep 2025 17:27:10 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274829; bh=a9vvaIom7ZVg8N2W0A0Z5e6QE3Ng6kW1dg1xFH0yggo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N4pK57fS2mPGdPJzZ4ahfsCt8DSIZs/nNHjB9qH48CXRhEmvElAPkwyaNJJktnRU3 pBkADfTJyaL/BUHG4s2Iy/PS0VuSrtgsivBJDp7waFqOZ4VrOig43YMotN3kGlhv4D 7nb6seCuKvOh3M/ld9TTgiEGAr1sRHVPie/RqZbPgOpWuWx/9J3KaCdk2kH/1dHeMr f+7sOCgq4a0K6MGGO2BWYSvLOIesQkHgP+Hq2K3dPHFDMZpUJ4DlVw4bQZdkN5ok2d 0NUvJd4oS1JV3yhJgeVjRocfn3PCCfXXxTTcUvD/p9RG15PS9rHl2Nv6hvj0in3KhE AXFvXeFwqmlpw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1F74267B5E; 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 sj88iN--xXI2; 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=1759274823; bh=+bxlAIbSNJQt7bzRVC4eoi32xU1O9Tyu+QqhuCeQhKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djzYGtfivd4pE4WPTFOVjBH5cvrSELd96Axfi+8j8jjcW+byF+FCVPnULq4lcDo0b SylWjBD/Ouixw+Qk+HAufPExGXnAK9WyUjuZtr8pNQpS5ppNY1V69ELlEZQoaxQK9Z GgffNpFl2SSGD+Hvr0o9gagzR1cA/Bx3COBZw3yArKHCGgxGGn/7ZiDsxVaFzIqCs3 oRBfaq1l7BLpb6D2YAMC2wjQJ6D4Ji3t9Dqo/dyqMYaPA4F8MAZHEIR4dwZb+z3B4U xmnuMU6ztESxZfAskVGCXbXpOL0Rx1U4NEDxskWoLWIsTBIDyCy0WehedvLG+tYfxl 5i2cRatInES4g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1C7A167E2E; Tue, 30 Sep 2025 17:27:03 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:48 -0600 Message-ID: <20250930232611.1564850-12-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: JMISZNZ6KW25CSRX7C4RIQKUHSW2DDCH X-Message-ID-Hash: JMISZNZ6KW25CSRX7C4RIQKUHSW2DDCH 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 11/15] boot: Implement a 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 Allow bootmeths to select when they want to run, using the bootdev priority. Provide a new bootmeth_glob_allowed() function which checks if a bootmeth is ready to use. Fix a comment in bootflow_system() which is a test for global bootmeths. Signed-off-by: Simon Glass --- (no changes since v1) boot/bootflow.c | 15 +++++++++++---- include/bootflow.h | 2 +- include/bootmeth.h | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 02b08eec641..bdae861a96c 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -251,17 +251,24 @@ static void scan_next_in_uclass(struct udevice **devp) * bootmeth_glob_allowed() - Check if a global bootmeth is usable at this point * * @iter: Bootflow iterator being used - * Return: true if the global bootmeth has not already been used + * Return: true if the global bootmeth has a suitable priority and has not + * already been used */ static bool bootmeth_glob_allowed(struct bootflow_iter *iter, int meth_seq) { struct udevice *meth = iter->method_order[meth_seq]; bool done = iter->methods_done & BIT(meth_seq); + struct bootmeth_uc_plat *ucp; - log_debug("considering glob '%s': done %d\n", meth->name, done); + ucp = dev_get_uclass_plat(meth); + log_debug("considering glob '%s': done %d glob_prio %d\n", meth->name, + done, ucp->glob_prio); - /* if this one has already been used, try the next */ - if (done) + /* + * if this one has already been used, or its priority is too low, try + * the next + */ + if (done || ucp->glob_prio > iter->cur_prio) return false; return true; diff --git a/include/bootflow.h b/include/bootflow.h index 5ef0f4b61d3..351a6539978 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -275,7 +275,7 @@ enum { * 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) + * generally happens before the normal ones) * @method_flags: flags controlling which methods should be used for this @dev * (enum bootflow_meth_flags_t) * @methods_done: indicates which methods have been processed, one bit for diff --git a/include/bootmeth.h b/include/bootmeth.h index a34bfc91dd5..b5288843d03 100644 --- a/include/bootmeth.h +++ b/include/bootmeth.h @@ -30,10 +30,14 @@ enum bootmeth_flags { * * @desc: A long description of the bootmeth * @flags: Flags for this bootmeth (enum bootmeth_flags) + * @glob_prio: Priority for this bootmeth. If unset (0) the bootmeth is started + * before all other bootmeths. Otherwise it is started before the iteration + * reaches the given priority. */ struct bootmeth_uc_plat { const char *desc; int flags; + enum bootdev_prio_t glob_prio; }; /** struct bootmeth_ops - Operations for boot methods */