From: Yao Zi <ziyao@disroot.org>
To: opensbi@lists.infradead.org
Subject: [PATCH 1/2] lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr
Date: Tue, 25 Mar 2025 08:43:45 +0000 [thread overview]
Message-ID: <Z-Jswdfa7pbQlnib@pie> (raw)
In-Reply-To: <CAAhSdy0LhKVEmvOHNObyDHDixCZ+GQh=hWK+g3NZVFWHBrmKnQ@mail.gmail.com>
On Tue, Mar 25, 2025 at 01:45:25PM +0530, Anup Patel wrote:
> On Tue, Feb 25, 2025 at 10:14?PM Yao Zi <ziyao@disroot.org> wrote:
> >
> > Zicntr extension specifies three RO CSRs, time, cycle and instret. It
> > isn't precise to report Zicntr is fully supported with only time CSR
> > detected.
> >
> > Since CSR emulating code only cares about the availablity of time CSR,
> > add additional definitions to represent the existance of cycle and
> > instret CSRs.
> >
> > Signed-off-by: Yao Zi <ziyao@disroot.org>
> > ---
> > include/sbi/sbi_hart.h | 8 ++++++--
> > lib/sbi/sbi_hart.c | 30 ++++++++++++++++++++++--------
> > lib/sbi/sbi_timer.c | 2 +-
> > 3 files changed, 29 insertions(+), 11 deletions(-)
> >
> > diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h
> > index 4c36c77..0a740cf 100644
> > --- a/include/sbi/sbi_hart.h
> > +++ b/include/sbi/sbi_hart.h
> > @@ -37,8 +37,12 @@ enum sbi_hart_extensions {
> > SBI_HART_EXT_SSCOFPMF,
> > /** HART has Sstc extension */
> > SBI_HART_EXT_SSTC,
> > - /** HART has Zicntr extension (i.e. HW cycle, time & instret CSRs) */
> > - SBI_HART_EXT_ZICNTR,
> > + /** HART has HW time CSR, as specified in Zicntr extension */
> > + SBI_HART_EXT_ZICNTR_TIME,
> > + /** HART has HW cycle CSR, as specified in Zicntr extension */
> > + SBI_HART_EXT_ZICNTR_CYCLE,
> > + /** HART has HW instret CSR, as specified in Zicntr extension */
> > + SBI_HART_EXT_ZICNTR_INSTRET,
>
> Zicntr_time, Zicntr_cycle, and Zicntr_instret are not real extension
> names so let's not add pseudo extension names.
>
> Instead, I suggest introducing "enum sbi_hart_csrs" for CSRs
> detected at boot-time. We will also need "csrs" bitmap in
> "struct sbi_hart_features".
>
> The new "enum sbi_hart_csrs" can have:
> SBI_HART_CSR_CYCLE,
> SBI_HART_CSR_TIME,
> SBI_HART_CSR_INSTRET
>
> These bits will be set in "struct sbi_hart_features" when
> corresponding CSRs are detected at boot-time.
Makes sense to me, I'll take it in v2.
Thanks,
Yao Zi
next prev parent reply other threads:[~2025-03-25 8:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-25 15:41 [PATCH 0/2] Register Zicntr in FDT when emulating is possible Yao Zi
2025-02-25 15:41 ` [PATCH 1/2] lib: sbi: hart: Detect existence of cycle and instret CSRs for Zicntr Yao Zi
2025-02-26 6:26 ` Xiang W
2025-02-26 7:04 ` Yao Zi
2025-03-25 8:15 ` Anup Patel
2025-03-25 8:43 ` Yao Zi [this message]
2025-02-25 15:41 ` [PATCH 2/2] lib: utils: fdt: Claim Zicntr if time CSR emulation is possible Yao Zi
2025-03-14 3:48 ` [PATCH 0/2] Register Zicntr in FDT when emulating " Yao Zi
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=Z-Jswdfa7pbQlnib@pie \
--to=ziyao@disroot.org \
--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