From patchwork Tue Sep 30 00:51:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 447 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=1759193551; bh=7hCjhQMf60w1BTQPeYAMEQhDAnqym6eiuyCIdouxjiY=; 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=g9JjxHeeSWfMRzf8J3lZ+qxu3oFA1Jaz5Pi3cbbftnDno6ATjh5uxbnGw+T5SvBD/ 2kKxYPfTfN6tH9E1yKx7MGdd3m++ho0CyiiOR2MEYG8m/wAuhLY1l3fB1ZKsTsLYg0 ckwr7PqJjeVTxI6xzW+BZ7W49+TgSDwgefzaPTuRRrbJIqBYBnGZRuPOL0pXgEyuLr 56FwoaqyuBPOemG6vWSrFf1DQkm1wxO/QBUmWceOYhCN5Y+LYdEiYDYj9t7pNYzOth ujI2Qt5ATmEbB3u+jGqni8VZ1fuUeEcWPv7yoim/UkxIegi8sGSwQIDWjAELxW0/EH P1eUXPFkIgajA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 688CD67E00 for ; 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 10024) with ESMTP id IXo49FMjcosK for ; 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=1759193550; bh=7hCjhQMf60w1BTQPeYAMEQhDAnqym6eiuyCIdouxjiY=; 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=b0EKAmztwRCuA7yM3838MssGur2H2SvhBXsgcPzclozl+BUHRYLQGEMwAV/61xdwS bYKd4E8Jv2jxKcLL46SaDrfcsrp6cq9KPAQ6B/bS4tkvfyVBNhJH2mrcmmrnRXzZXM skNnW51jbty0Rq152lMq32+AQz7RyVpnZXhTZ8EA9HvsUGPeXTTw/b5WHADd1GDAVj AuIRxftNTy+/MFKMSnpGRHVIMh9lVxHl91CZVUDvfg16DCSlQFCs1XC4l1xc9dlnRC 5kI9IgRHMdlPCxhp9xK8aqJVVr2cMOM35Mx6MxtNwjX583LpdFcYhJndbGJBhUb+ub stKmj2wb7P/sQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 530D767E59 for ; Mon, 29 Sep 2025 18:52:30 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193547; bh=eh0nNHu0D7/ehklZM2spfhYat50pVgW8MSTAdmJRk00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=upsRKS33LECjay3xy9fkZ527rUB3/cDmu0Mm1CcyQQFD/hydiMIjxPz9WiKTqNZOU JbflYrK5YCBbcN5bJLUk9wBzrjD4GigmstPqBHi1L96YC2tPuvbYM1N0aCK3+ylbMG bzjJ+YzdckeKHB68VWZRAiw/3aWIsmwYrOo3yD8q894dUvWouZDkdkTPiCdU8aZYzm uW37vHKMKCtQpN6FG4YwdHnLwGxuKc+nniVUSsOJzDYmgCG9R9p8JIiWIRIeX4ZDJj NPKKDtm4yIWYWLtk2WfLtghDZTPRlX+Jrm87GWZiOeoMJclZHvY+PZ0jH1gHvXyfqL MvyvqRNtvSu4g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CA9DF67E00; Mon, 29 Sep 2025 18:52:27 -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 teyFL3oBp4ku; Mon, 29 Sep 2025 18:52:27 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193543; bh=I9B80UpkNtAN+FSL4lBh/oebU7Wj4pay5mMBOtu8Ks4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgejrlhWT9i8NwrkX0Arorjbp5MKL1bHG/0N8X/G+E3wxcY59FmJ/IXtbYP9/ld1N hWU4IaeSUYJ1LxMEV+oIxvCTNKZ2gaZI0o3Sz20+LXrn6z+eF/AnvQGoM4YFV7fEt1 NXHzjz08CIPFh+gwdsIUXm3Zu1aAlGkpityVwa9p108bsVC/foB8aF7q1Bk+fD/Z1M VItLaqR2SXCeovlnhUQFV/XuG4AgIQ+GEKGIEyqafuokjfYsOpgAiD0oQsmfVpf/zP RKE51zt7ckGf4h8lYFlFndgmv529YDXm1SsWD5PgXCnhwJADH96lSNhWBeH69gCzPS kYcGkK9kK/gNg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7FCE967E7D; Mon, 29 Sep 2025 18:52:23 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:27 -0600 Message-ID: <20250930005137.3650600-12-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: 3CCEKZO6VRWSDZ5HV2VJ4KGNHW372JC7 X-Message-ID-Hash: 3CCEKZO6VRWSDZ5HV2VJ4KGNHW372JC7 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 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 --- 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 d6c396e3087..becb2ef109f 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -249,17 +249,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 */