From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available
Date: Thu, 28 Apr 2022 13:18:16 +0530 [thread overview]
Message-ID: <20220428074816.196542-1-apatel@ventanamicro.com> (raw)
The mhpmevent3h to mhpmevent31h CSRs are available on RV32 only when
Sscofpmf extension is available so mstatus_init() should set this
CSRs only when Sscofpmf extension is available.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
lib/sbi/sbi_hart.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index a50b6e4..229c14a 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -82,7 +82,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
for (cidx = 0; cidx < num_mhpm; cidx++) {
#if __riscv_xlen == 32
csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val & 0xFFFFFFFF);
- csr_write_num(CSR_MHPMEVENT3H + cidx, mhpmevent_init_val >> BITS_PER_LONG);
+ if (sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOFPMF))
+ csr_write_num(CSR_MHPMEVENT3H + cidx,
+ mhpmevent_init_val >> BITS_PER_LONG);
#else
csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val);
#endif
--
2.34.1
next reply other threads:[~2022-04-28 7:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-28 7:48 Anup Patel [this message]
2022-04-28 13:53 ` [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available Atish Patra
2022-04-28 14:11 ` Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220428074816.196542-1-apatel@ventanamicro.com \
--to=apatel@ventanamicro.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox