* [PATCH] bootchooser: add new value "reset" to reset boot attempts counter
@ 2023-12-14 19:01 Holger Assmann
2024-01-04 13:03 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Holger Assmann @ 2023-12-14 19:01 UTC (permalink / raw)
To: barebox; +Cc: Holger Assmann
bootchooser provides a mechanism that allows for resetting the
"remaining_attempts" counters of all enabled boot slots to their
defaults.
The current possible trigger values to be stored in the defining
variable $bootchooser.reset_attempts are "all-zero" (i.e. no attempts
left at any boot slot) and "power-on" (i.e. $global.system.reset="POR").
We now want to add the option "reset" (i.e. $global.system.reset="RST")
to that list, so that we do not have to perform an entire power cycle
every time we need a counter reset.
By introducing the "reset" value as an option, we can deliberately cause
the bootchooser to set the "remaining_attempts" values to their defaults
when performing a generic restart. The restart handler of the main OS
is hence responsible that the subsequent barebox run sees "RESET_RST" as
reset reason instead of e.g. "RESET_WDG".
Signed-off-by: Holger Assmann <h.assmann@pengutronix.de>
---
Documentation/user/bootchooser.rst | 6 ++++++
common/bootchooser.c | 11 +++++++++++
2 files changed, 17 insertions(+)
diff --git a/Documentation/user/bootchooser.rst b/Documentation/user/bootchooser.rst
index db0a4f8898..1a2ce70bb2 100644
--- a/Documentation/user/bootchooser.rst
+++ b/Documentation/user/bootchooser.rst
@@ -92,6 +92,12 @@ list of space-separated flags. Possible values are:
(``$global.system.reset="POR"``) is detected, the ``remaining_attempts``
counters of all enabled targets are reset to their defaults.
This means after a power cycle all boot targets will be tried again for the configured number of retries.
+- ``reset``: When the bootchooser starts and a generic reset
+ (``$global.system.reset="RST"``) is detected, the ``remaining_attempts``
+ counters of all enabled targets are reset to their defaults.
+ This means that, if the systems reports a generic restart, the
+ ``remaining_attempts`` counters of all enabled targets are reset to
+ their defaults.
- ``all-zero``: When the bootchooser starts and the ``remaining_attempts``
counters of all enabled targets are zero, the ``remaining_attempts``
counters of all enabled targets are reset to their defaults.
diff --git a/common/bootchooser.c b/common/bootchooser.c
index eb3dda52ab..022e225165 100644
--- a/common/bootchooser.c
+++ b/common/bootchooser.c
@@ -77,6 +77,7 @@ struct bootchooser_target {
enum reset_attempts {
RESET_ATTEMPTS_POWER_ON,
RESET_ATTEMPTS_ALL_ZERO,
+ RESET_ATTEMPTS_SRC_RST,
};
static unsigned long reset_attempts;
@@ -439,6 +440,13 @@ struct bootchooser *bootchooser_get(void)
attempts_resetted = 1;
}
+ if (test_bit(RESET_ATTEMPTS_SRC_RST, &reset_attempts) &&
+ reset_source_get() == RESET_RST && !attempts_resetted) {
+ pr_info("RST Reset, resetting remaining attempts\n");
+ bootchooser_reset_attempts(bc);
+ attempts_resetted = 1;
+ }
+
if (test_bit(RESET_ATTEMPTS_ALL_ZERO, &reset_attempts)) {
int attempts = 0;
@@ -915,6 +923,7 @@ static int bootchooser_add_entry(struct bootentries *entries, const char *name)
static const char * const reset_attempts_names[] = {
[RESET_ATTEMPTS_POWER_ON] = "power-on",
[RESET_ATTEMPTS_ALL_ZERO] = "all-zero",
+ [RESET_ATTEMPTS_SRC_RST] = "reset",
};
static const char * const reset_priorities_names[] = {
@@ -951,6 +960,8 @@ BAREBOX_MAGICVAR(global.bootchooser.targets,
"bootchooser: Space separated list of target names");
BAREBOX_MAGICVAR(global.bootchooser.default_attempts,
"bootchooser: Default number of attempts for a target");
+BAREBOX_MAGICVAR(global.bootchooser.reset_attempts,
+ "bootchooser: Choose condition to reset number of attempts for all enabled targets ('power-on', 'all-zero', 'reset')");
BAREBOX_MAGICVAR(global.bootchooser.default_priority,
"bootchooser: Default priority for a target");
BAREBOX_MAGICVAR(global.bootchooser.state_prefix,
--
2.39.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] bootchooser: add new value "reset" to reset boot attempts counter
2023-12-14 19:01 [PATCH] bootchooser: add new value "reset" to reset boot attempts counter Holger Assmann
@ 2024-01-04 13:03 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-01-04 13:03 UTC (permalink / raw)
To: Holger Assmann; +Cc: barebox
On Thu, Dec 14, 2023 at 08:01:25PM +0100, Holger Assmann wrote:
> bootchooser provides a mechanism that allows for resetting the
> "remaining_attempts" counters of all enabled boot slots to their
> defaults.
>
> The current possible trigger values to be stored in the defining
> variable $bootchooser.reset_attempts are "all-zero" (i.e. no attempts
> left at any boot slot) and "power-on" (i.e. $global.system.reset="POR").
>
> We now want to add the option "reset" (i.e. $global.system.reset="RST")
> to that list, so that we do not have to perform an entire power cycle
> every time we need a counter reset.
>
> By introducing the "reset" value as an option, we can deliberately cause
> the bootchooser to set the "remaining_attempts" values to their defaults
> when performing a generic restart. The restart handler of the main OS
> is hence responsible that the subsequent barebox run sees "RESET_RST" as
> reset reason instead of e.g. "RESET_WDG".
>
> Signed-off-by: Holger Assmann <h.assmann@pengutronix.de>
> ---
> Documentation/user/bootchooser.rst | 6 ++++++
> common/bootchooser.c | 11 +++++++++++
> 2 files changed, 17 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/Documentation/user/bootchooser.rst b/Documentation/user/bootchooser.rst
> index db0a4f8898..1a2ce70bb2 100644
> --- a/Documentation/user/bootchooser.rst
> +++ b/Documentation/user/bootchooser.rst
> @@ -92,6 +92,12 @@ list of space-separated flags. Possible values are:
> (``$global.system.reset="POR"``) is detected, the ``remaining_attempts``
> counters of all enabled targets are reset to their defaults.
> This means after a power cycle all boot targets will be tried again for the configured number of retries.
> +- ``reset``: When the bootchooser starts and a generic reset
> + (``$global.system.reset="RST"``) is detected, the ``remaining_attempts``
> + counters of all enabled targets are reset to their defaults.
> + This means that, if the systems reports a generic restart, the
> + ``remaining_attempts`` counters of all enabled targets are reset to
> + their defaults.
> - ``all-zero``: When the bootchooser starts and the ``remaining_attempts``
> counters of all enabled targets are zero, the ``remaining_attempts``
> counters of all enabled targets are reset to their defaults.
> diff --git a/common/bootchooser.c b/common/bootchooser.c
> index eb3dda52ab..022e225165 100644
> --- a/common/bootchooser.c
> +++ b/common/bootchooser.c
> @@ -77,6 +77,7 @@ struct bootchooser_target {
> enum reset_attempts {
> RESET_ATTEMPTS_POWER_ON,
> RESET_ATTEMPTS_ALL_ZERO,
> + RESET_ATTEMPTS_SRC_RST,
> };
>
> static unsigned long reset_attempts;
> @@ -439,6 +440,13 @@ struct bootchooser *bootchooser_get(void)
> attempts_resetted = 1;
> }
>
> + if (test_bit(RESET_ATTEMPTS_SRC_RST, &reset_attempts) &&
> + reset_source_get() == RESET_RST && !attempts_resetted) {
> + pr_info("RST Reset, resetting remaining attempts\n");
> + bootchooser_reset_attempts(bc);
> + attempts_resetted = 1;
> + }
> +
> if (test_bit(RESET_ATTEMPTS_ALL_ZERO, &reset_attempts)) {
> int attempts = 0;
>
> @@ -915,6 +923,7 @@ static int bootchooser_add_entry(struct bootentries *entries, const char *name)
> static const char * const reset_attempts_names[] = {
> [RESET_ATTEMPTS_POWER_ON] = "power-on",
> [RESET_ATTEMPTS_ALL_ZERO] = "all-zero",
> + [RESET_ATTEMPTS_SRC_RST] = "reset",
> };
>
> static const char * const reset_priorities_names[] = {
> @@ -951,6 +960,8 @@ BAREBOX_MAGICVAR(global.bootchooser.targets,
> "bootchooser: Space separated list of target names");
> BAREBOX_MAGICVAR(global.bootchooser.default_attempts,
> "bootchooser: Default number of attempts for a target");
> +BAREBOX_MAGICVAR(global.bootchooser.reset_attempts,
> + "bootchooser: Choose condition to reset number of attempts for all enabled targets ('power-on', 'all-zero', 'reset')");
> BAREBOX_MAGICVAR(global.bootchooser.default_priority,
> "bootchooser: Default priority for a target");
> BAREBOX_MAGICVAR(global.bootchooser.state_prefix,
> --
> 2.39.2
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-04 13:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-14 19:01 [PATCH] bootchooser: add new value "reset" to reset boot attempts counter Holger Assmann
2024-01-04 13:03 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox