Thread (20 messages) 20 messages, 3 authors, 2021-02-24
STALE1950d REVIEWED: 1 (0M)
Revisions (4)
  1. rfc [diff vs current]
  2. rfc current
  3. v2 [diff vs current]
  4. v3 [diff vs current]

[RFC PATCH 06/10] lib: sbi: Add sbi_hart_reinit() function

From: Atish Patra <hidden>
Date: 2021-02-23 23:41:59

On Sun, Feb 21, 2021 at 12:54 AM Anup Patel [off-list ref] wrote:
quoted hunk ↗ jump to hunk
We add sbi_hart_reinit() function which will re-initialize HART CSRs
assuming HART features are already detected. This new function will
be useful in re-initializing HART after it resumes from HSM SUSPENDED
state.

Signed-off-by: Anup Patel <redacted>
---
 include/sbi/sbi_hart.h |  1 +
 lib/sbi/sbi_hart.c     | 29 +++++++++++++++++------------
 2 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h
index ec9e30f..031c7b0 100644
--- a/include/sbi/sbi_hart.h
+++ b/include/sbi/sbi_hart.h
@@ -27,6 +27,7 @@ enum sbi_hart_features {

 struct sbi_scratch;

+int sbi_hart_reinit(struct sbi_scratch *scratch);
 int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot);

 extern void (*sbi_hart_expected_trap)(void);
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index fc86e9f..d91b08c 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -430,10 +430,25 @@ __mhpm_skip:
                hfeatures->features |= SBI_HART_HAS_TIME;
 }

-int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)
+int sbi_hart_reinit(struct sbi_scratch *scratch)
 {
        int rc;

+       mstatus_init(scratch);
+
+       rc = fp_init(scratch);
+       if (rc)
+               return rc;
+
+       rc = delegate_traps(scratch);
+       if (rc)
+               return rc;
+
+       return 0;
+}
+
+int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)
+{
        if (cold_boot) {
                if (misa_extension('H'))
                        sbi_hart_expected_trap = &__sbi_expected_trap_hext;
@@ -447,17 +462,7 @@ int sbi_hart_init(struct sbi_scratch *scratch, bool cold_boot)

        hart_detect_features(scratch);

-       mstatus_init(scratch);
-
-       rc = fp_init(scratch);
-       if (rc)
-               return rc;
-
-       rc = delegate_traps(scratch);
-       if (rc)
-               return rc;
-
-       return 0;
+       return sbi_hart_reinit(scratch);
 }

 void __attribute__((noreturn)) sbi_hart_hang(void)
--
2.25.1


--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

Reviewed-by: Atish Patra <redacted>

-- 
Regards,
Atish
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help