[RFC PATCH 2/2] lib: sbi: add priority for reset handler
Xiang W
wxjstz at 126.com
Wed Sep 29 19:26:11 PDT 2021
在 2021-09-29星期三的 12:41 +0300,Nikita Shubin写道:
> From: Nikita Shubin <n.shubin at yadro.com>
>
> Let's make system_reset_check returning priority instead of only
> true/false. In that case 0 - means not supported, and anything above
> means priority that makes existing reset handlers being used in first
> place, unless it is decided to lower their priority.
>
> The handler with the least priority wins.
>
> Signed-off-by: Nikita Shubin <n.shubin at yadro.com>
Isn't this priority used to control the shutdown sequence of different
areas? What is this usage scenario?
Regards,
Xiang W
> ---
> lib/sbi/sbi_system.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/lib/sbi/sbi_system.c b/lib/sbi/sbi_system.c
> index 92bc0ac..a82c4ef 100644
> --- a/lib/sbi/sbi_system.c
> +++ b/lib/sbi/sbi_system.c
> @@ -55,6 +55,8 @@ void __noreturn sbi_system_reset(u32 reset_type,
> u32 reset_reason)
> struct sbi_domain *dom = sbi_domain_thishart_ptr();
> struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
> struct sbi_dlist *pos;
> + struct sbi_system_reset_device *reset_dev = 0;
> + int priority = 255;
>
> /* Send HALT IPI to every hart other than the current hart */
> while (!sbi_hsm_hart_interruptible_mask(dom, hbase, &hmask))
> {
> @@ -70,12 +72,22 @@ void __noreturn sbi_system_reset(u32 reset_type,
> u32 reset_reason)
>
> /* Check each reset device registered for supported reset
> type */
> sbi_list_for_each(pos, &(reset_devices_list)) {
> - struct sbi_system_reset_device *dev =
> - to_system_reset_device(pos);
> - if (dev->system_reset_check(reset_type,
> reset_reason))
> - dev->system_reset(reset_type, reset_reason);
> + struct sbi_system_reset_device *dev
> + = to_system_reset_device(pos);
> + int status = dev->system_reset_check(reset_type,
> reset_reason);
> +
> + if (status == 0)
> + continue;
> +
> + if (status < priority) {
> + reset_dev = dev;
> + priority = status;
> + }
> }
>
> + if (reset_dev)
> + reset_dev->system_reset(reset_type, reset_reason);
> +
> /* If platform specific reset did not work then do sbi_exit()
> */
> sbi_exit(scratch);
> }
> --
> 2.31.1
>
>
More information about the opensbi
mailing list