lib: sbi: error handling in fdt_reset_init()
v2 cover lib: sbi: error handling in fdt_reset_init()
A failure to initialize a reset driver should not stop booting. Yet we should print an error message in such a case. This requires to move the initialization of reset drivers to after sbi_console_init() and to move printing the probed drivers to after the final initialization.
With the series applied the output including an error message will look like:
...
Domain0 Next Arg1 : 0x0000000080299f10
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
fdt_reset_init: da9063-reset init failed, -1001
Platform Name : SiFive HiFive Unmatched A00
Platform Features : medeleg
Platform HART Count : 5
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000000Hz
Platform Console Device : sifive_uart
Platform HSM Device : ---
Platform Reboot Device : ---
Platform Shutdown Device : gpio-reset
...
v2:
add error output
Heinrich Schuchardt (3):
lib: sbi: move sbi_boot_print_general()
platform: generic: move fdt_reset_init to final_init
lib: sbi: error handling in fdt_reset_init()
include/sbi_utils/reset/fdt_reset.h | 5 ++++- lib/sbi/sbi_init.c | 4 ++-- lib/utils/reset/fdt_reset.c | 13 ++++++------- platform/generic/platform.c | 15 +++++---------- 4 files changed, 17 insertions(+), 20 deletions(-)
Signature · 1 line
2.32.0
PATCH v2 1/3 lib: sbi: move sbi_boot_print_general()
Moving the sbi_boot_print_general() call after the sbi_platform_final_init() call allows to print devices initialized in the latter.
---
v2:
new patch
--- lib/sbi/sbi_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/sbi/sbi_init.c +2 -2
@@ -301,8 +301,6 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)sbi_hart_hang (); } -sbi_boot_print_general (scratch); -/* * Note: Finalize domains after HSM initialization so that we * can startup non-root domains.
@@ -336,6 +334,8 @@ static void __noreturn init_coldboot(struct sbi_scratch *scratch, u32 hartid)sbi_hart_hang (); } +sbi_boot_print_general (scratch); +sbi_boot_print_hart (scratch, hartid);wake_coldboot_harts (scratch, hartid);
Signature · 1 line
2.32.0
PATCH v2 2/3 platform: generic: move fdt_reset_init to final_init
In reply to Heinrich SchuchardtMove the fdt_reset_init() invocation from generic_early_init() to generic_final_init(). This allows to print error messages.
Ignore the return value of fdt_reset_init() as we should not stop booting due to failure to initialize reset drivers.
---
v2:
new patch
--- platform/generic/platform.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
platform/generic/platform.c +5 -10
@@ -120,18 +120,10 @@ fail:static int generic_early_init (bool cold_boot) { -int rc; - -if (generic_plat && generic_plat->early_init) { - rc = generic_plat->early_init (cold_boot, generic_plat_match); -if (rc) -return rc; - } - -if (!cold_boot) +if (!generic_plat || !generic_plat->early_init)return 0 ; -return fdt_reset_init (); +return generic_plat->early_init (cold_boot, generic_plat_match); }static int generic_final_init (bool cold_boot)
@@ -139,6 +131,9 @@ static int generic_final_init(bool cold_boot)void *fdt;int rc; +if (cold_boot) +fdt_reset_init (); +if (generic_plat && generic_plat->final_init) { rc = generic_plat->final_init (cold_boot, generic_plat_match);if (rc)
Signature · 1 line
2.32.0
PATCH v2 3/3 lib: sbi: error handling in fdt_reset_init()
In reply to Heinrich SchuchardtThe initialization of a reset driver may fail for various reasons, like a PMIC based reset driver not finding the required I2C driver. The return code of the init routine may take other error values than -ENODEV.
If the initialization of a reset driver fails, this should not lead to the board hanging. It is enough that the reset driver does not call sbi_system_reset_add_device() to avoid invoking the driver for a device that could not be initialized.
Change the return type of fdt_reset_init() to void. Print a message if an error occurs.
---
v2:
provide an error message
--- include/sbi_utils/reset/fdt_reset.h | 5 ++++- lib/utils/reset/fdt_reset.c | 13 ++++++------- 2 files changed, 10 insertions(+), 8 deletions(-)
include/sbi_utils/reset/fdt_reset.h +4 -1
@@ -17,6 +17,9 @@ struct fdt_reset { int (*init)(void *fdt, int nodeoff, const struct fdt_match *match); }; -int fdt_reset_init (void ); +/** +* fdt_reset_init() - initialize reset drivers based on the device-tree +*/ +void fdt_reset_init (void );#endif
lib/utils/reset/fdt_reset.c +6 -7
@@ -7,6 +7,7 @@* Anup Patel <[email protected]> */ +#include <sbi/sbi_console.h> #include <sbi/sbi_error.h> #include <sbi/sbi_scratch.h> #include <sbi_utils/fdt/fdt_helper.h>
@@ -28,7 +29,7 @@ static struct fdt_reset *reset_drivers[] = { &fdt_reset_thead, }; -int fdt_reset_init (void ) +void fdt_reset_init (void ) {int pos, noff, rc;struct fdt_reset *drv;
@@ -44,12 +45,10 @@ int fdt_reset_init(void)if (drv->init) { rc = drv->init (fdt, noff, match); -if (rc ==SBI_ENODEV ) -continue ; -if (rc) -return rc; +if (rc && rc != -SBI_ENODEV ) { +sbi_printf ("%s: %s init failed, %d\n" , + __func__, match->compatible, rc); + } } } - -return 0 ; }
Signature · 1 line
2.32.0
PATCH v2 3/3 lib: sbi: error handling in fdt_reset_init()
Quoted 59 lines · Heinrich Schuchardt heinrich.schuchardt at canonical.com
The initialization of a reset driver may fail for various reasons, like a PMIC based reset driver not finding the required I2C driver. The return code of the init routine may take other error values than
-ENODEV.If the initialization of a reset driver fails, this should not lead to the board hanging. It is enough that the reset driver does not call
sbi_system_reset_add_device()to avoid invoking the driver for a device that could not be initialized.Change the return type of
fdt_reset_init()to void. Print a message if an error occurs.Signed-off-by Heinrich Schuchardt <[email protected]>---
v2:
provide an error message
---include/sbi_utils/reset/fdt_reset.h| 5 ++++-lib/utils/reset/fdt_reset.c| 13 ++++++-------2 files changed, 10 insertions(+), 8 deletions(-)include/sbi_utils/reset/fdt_reset.h +4
-1@@ -17,6 +17,9 @@ struct fdt_reset { int (*init)(void *fdt, int nodeoff, const struct fdt_match *match); }; -int fdt_reset_init (void ); +/** +* fdt_reset_init() - initialize reset drivers based on the device-tree +*/ +void fdt_reset_init (void );#endif lib/utils/reset/fdt_reset.c +2
-1@@ -7,6 +7,7 @@* Anup Patel <[email protected]> */ +#include <sbi/sbi_console.h> #include <sbi/sbi_error.h> #include <sbi/sbi_scratch.h> #include <sbi_utils/fdt/fdt_helper.h> @@ -28,7 +29,7 @@ static struct fdt_reset *reset_drivers[] = { &fdt_reset_thead, }; -int fdt_reset_init (void ) +void fdt_reset_init (void ) {int pos, noff, rc;struct fdt_reset *drv;
lib/utils/reset/fdt_reset.c int fdt_reset_init(void) · line 48
Quoted 8 lines
lib/utils/reset/fdt_reset.c +1
-4@@ -44,12 +45,10 @@ int fdt_reset_init(void)if (drv->init) { rc = drv->init (fdt, noff, match); -if (rc ==SBI_ENODEV ) -continue ; -if (rc) -return rc; +if (rc && rc != -SBI_ENODEV ) {
Shouldn't this be SBI_ENODEV instead of -SBI_ENODEV?
Regards,
Dong
Quoted 16 lines
lib/utils/reset/fdt_reset.c +3
-3+sbi_printf ("%s: %s init failed, %d\n" , + __func__, match->compatible, rc); + } } } - -return 0 ; } --2.32.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v2 3/3 lib: sbi: error handling in fdt_reset_init()
Quoted 64 lines · Dong Du
Quoted 60 lines · Heinrich Schuchardt heinrich.schuchardt at canonical.com
The initialization of a reset driver may fail for various reasons, like a PMIC based reset driver not finding the required I2C driver. The return code of the init routine may take other error values than
-ENODEV.If the initialization of a reset driver fails, this should not lead to the board hanging. It is enough that the reset driver does not call
sbi_system_reset_add_device()to avoid invoking the driver for a device that could not be initialized.Change the return type of
fdt_reset_init()to void. Print a message if an error occurs.Signed-off-by Heinrich Schuchardt <[email protected]>---
v2:
provide an error message
---include/sbi_utils/reset/fdt_reset.h| 5 ++++-lib/utils/reset/fdt_reset.c| 13 ++++++-------2 files changed, 10 insertions(+), 8 deletions(-)include/sbi_utils/reset/fdt_reset.h +4
-1@@ -17,6 +17,9 @@ struct fdt_reset { int (*init)(void *fdt, int nodeoff, const struct fdt_match *match); }; -int fdt_reset_init (void ); +/** +* fdt_reset_init() - initialize reset drivers based on the device-tree +*/ +void fdt_reset_init (void );#endif lib/utils/reset/fdt_reset.c +2
-1@@ -7,6 +7,7 @@* Anup Patel <[email protected]> */ +#include <sbi/sbi_console.h> #include <sbi/sbi_error.h> #include <sbi/sbi_scratch.h> #include <sbi_utils/fdt/fdt_helper.h> @@ -28,7 +29,7 @@ static struct fdt_reset *reset_drivers[] = { &fdt_reset_thead, }; -int fdt_reset_init (void ) +void fdt_reset_init (void ) {int pos, noff, rc;struct fdt_reset *drv;@@ -44,12 +45,10 @@ int fdt_reset_init(void)
Quoted 9 lines
lib/utils/reset/fdt_reset.c int fdt_reset_init(void) · line 48
Quoted 7 lines
lib/utils/reset/fdt_reset.c +1
-4if (drv->init) { rc = drv->init (fdt, noff, match); -if (rc ==SBI_ENODEV ) -continue ; -if (rc) -return rc; +if (rc && rc != -SBI_ENODEV ) {Shouldn't this be
SBI_ENODEVinstead of -SBI_ENODEV?
Thanks for reviewing.
You are right.
Best regards
Heinrich
Quoted 20 lines
Regards,
DongQuoted 16 lines
lib/utils/reset/fdt_reset.c +3
-3+sbi_printf ("%s: %s init failed, %d\n" , + __func__, match->compatible, rc); + } } } - -return 0 ; } --2.32.0
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi