diff mbox series

[v2,04/11] lib: sbi_hsm: Move misplaced comment

Message ID 20230227103106.137995-5-ajones@ventanamicro.com
State Accepted
Headers show
Series SBI system suspend (SUSP) extension | expand

Commit Message

Andrew Jones Feb. 27, 2023, 10:30 a.m. UTC
While non-retentive suspend is not allowed for M-mode, the comment
at the top of sbi_hsm_hart_suspend() implied suspend wasn't allowed
for M-mode at all. Move the comment above the mode check which is
inside a suspend type is non-retentive check.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
---
 lib/sbi/sbi_hsm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Anup Patel Feb. 27, 2023, 2:22 p.m. UTC | #1
On Mon, Feb 27, 2023 at 4:01 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> While non-retentive suspend is not allowed for M-mode, the comment
> at the top of sbi_hsm_hart_suspend() implied suspend wasn't allowed
> for M-mode at all. Move the comment above the mode check which is
> inside a suspend type is non-retentive check.
>
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  lib/sbi/sbi_hsm.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
> index 3455520b8a94..294156a9a7bd 100644
> --- a/lib/sbi/sbi_hsm.c
> +++ b/lib/sbi/sbi_hsm.c
> @@ -398,8 +398,6 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
>         struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
>                                                             hart_data_offset);
>
> -       /* For now, we only allow suspend from S-mode or U-mode. */
> -
>         /* Sanity check on domain assigned to current HART */
>         if (!dom)
>                 return SBI_EFAIL;
> @@ -414,6 +412,10 @@ int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
>
>         /* Additional sanity check for non-retentive suspend */
>         if (suspend_type & SBI_HSM_SUSP_NON_RET_BIT) {
> +               /*
> +                * For now, we only allow non-retentive suspend from
> +                * S-mode or U-mode.
> +                */
>                 if (rmode != PRV_S && rmode != PRV_U)
>                         return SBI_EFAIL;
>                 if (dom && !sbi_domain_check_addr(dom, raddr, rmode,
> --
> 2.39.1
>
diff mbox series

Patch

diff --git a/lib/sbi/sbi_hsm.c b/lib/sbi/sbi_hsm.c
index 3455520b8a94..294156a9a7bd 100644
--- a/lib/sbi/sbi_hsm.c
+++ b/lib/sbi/sbi_hsm.c
@@ -398,8 +398,6 @@  int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
 	struct sbi_hsm_data *hdata = sbi_scratch_offset_ptr(scratch,
 							    hart_data_offset);
 
-	/* For now, we only allow suspend from S-mode or U-mode. */
-
 	/* Sanity check on domain assigned to current HART */
 	if (!dom)
 		return SBI_EFAIL;
@@ -414,6 +412,10 @@  int sbi_hsm_hart_suspend(struct sbi_scratch *scratch, u32 suspend_type,
 
 	/* Additional sanity check for non-retentive suspend */
 	if (suspend_type & SBI_HSM_SUSP_NON_RET_BIT) {
+		/*
+		 * For now, we only allow non-retentive suspend from
+		 * S-mode or U-mode.
+		 */
 		if (rmode != PRV_S && rmode != PRV_U)
 			return SBI_EFAIL;
 		if (dom && !sbi_domain_check_addr(dom, raddr, rmode,