diff mbox series

lib: sbi_hsm: Put the resume_pending hart in the interruptible hart mask

Message ID 20231201095147.1791731-1-nick.hu@sifive.com
State Accepted
Headers show
Series lib: sbi_hsm: Put the resume_pending hart in the interruptible hart mask | expand

Commit Message

Nick Hu Dec. 1, 2023, 9:51 a.m. UTC
Current interruptible hart mask doesn't include the hart which HSM state
is SBI_HSM_STATE_RESUME_PENDING. So when there is a request to send an
IPI to the hart which is in the resume process, this hart would miss the
IPI forever. Put the SBI_HSM_STATE_RESUME_PENDING hart in the
interruptible hart mask to fix the issue.

Signed-off-by: Nick Hu <nick.hu@sifive.com>
---
 lib/sbi/sbi_hsm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Xiang W Dec. 1, 2023, 1:45 p.m. UTC | #1
在 2023-12-01星期五的 17:51 +0800,Nick Hu写道:
> Current interruptible hart mask doesn't include the hart which HSM state
> is SBI_HSM_STATE_RESUME_PENDING. So when there is a request to send an
> IPI to the hart which is in the resume process, this hart would miss the
> IPI forever. Put the SBI_HSM_STATE_RESUME_PENDING hart in the
> interruptible hart mask to fix the issue.
> 
> Signed-off-by: Nick Hu <nick.hu@sifive.com>
LGTM

Reviewed-by: Xiang W <wxjstz@126.com>
> ---
>  lib/sbi/sbi_hsm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
> index 147f954..3d60ceb 100644
> --- a/lib/sbi/sbi_hsm.c
> +++ b/lib/sbi/sbi_hsm.c
> @@ -128,7 +128,8 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
>  
>  		hstate = __sbi_hsm_hart_get_state(hbase + i);
>  		if (hstate == SBI_HSM_STATE_STARTED ||
> -		    hstate == SBI_HSM_STATE_SUSPENDED)
> +		    hstate == SBI_HSM_STATE_SUSPENDED ||
> +		    hstate == SBI_HSM_STATE_RESUME_PENDING)
>  			*out_hmask |= hmask;
>  	}
>  
> -- 
> 2.34.1
> 
>
Anup Patel Dec. 10, 2023, 8:10 a.m. UTC | #2
On Fri, Dec 1, 2023 at 3:22 PM Nick Hu <nick.hu@sifive.com> wrote:
>
> Current interruptible hart mask doesn't include the hart which HSM state
> is SBI_HSM_STATE_RESUME_PENDING. So when there is a request to send an
> IPI to the hart which is in the resume process, this hart would miss the
> IPI forever. Put the SBI_HSM_STATE_RESUME_PENDING hart in the
> interruptible hart mask to fix the issue.
>
> Signed-off-by: Nick Hu <nick.hu@sifive.com>

Looks good to me.

Reviewed-by: Anup Patel <anup@brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  lib/sbi/sbi_hsm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
> index 147f954..3d60ceb 100644
> --- a/lib/sbi/sbi_hsm.c
> +++ b/lib/sbi/sbi_hsm.c
> @@ -128,7 +128,8 @@ int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
>
>                 hstate = __sbi_hsm_hart_get_state(hbase + i);
>                 if (hstate == SBI_HSM_STATE_STARTED ||
> -                   hstate == SBI_HSM_STATE_SUSPENDED)
> +                   hstate == SBI_HSM_STATE_SUSPENDED ||
> +                   hstate == SBI_HSM_STATE_RESUME_PENDING)
>                         *out_hmask |= hmask;
>         }
>
> --
> 2.34.1
>
>
> --
> opensbi mailing list
> opensbi@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
diff mbox series

Patch

diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
index 147f954..3d60ceb 100644
--- a/lib/sbi/sbi_hsm.c
+++ b/lib/sbi/sbi_hsm.c
@@ -128,7 +128,8 @@  int sbi_hsm_hart_interruptible_mask(const struct sbi_domain *dom,
 
 		hstate = __sbi_hsm_hart_get_state(hbase + i);
 		if (hstate == SBI_HSM_STATE_STARTED ||
-		    hstate == SBI_HSM_STATE_SUSPENDED)
+		    hstate == SBI_HSM_STATE_SUSPENDED ||
+		    hstate == SBI_HSM_STATE_RESUME_PENDING)
 			*out_hmask |= hmask;
 	}