diff mbox series

[RFC,1/4] riscv: Add 3 SBI wrapper functions to get cpu manufacturer information

Message ID 1615175897-23509-2-git-send-email-vincent.chen@sifive.com (mailing list archive)
State New, archived
Headers show
Series riscv: introduce alternative mechanism to apply errata patches | expand

Commit Message

Vincent Chen March 8, 2021, 3:58 a.m. UTC
Add 3 wrapper functions to get vendor id, architecture id and implement id
from M-mode

Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
---
 arch/riscv/include/asm/sbi.h |  3 +++
 arch/riscv/kernel/sbi.c      | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

Comments

Palmer Dabbelt March 10, 2021, 4:39 a.m. UTC | #1
On Sun, 07 Mar 2021 19:58:14 PST (-0800), vincent.chen@sifive.com wrote:
> Add 3 wrapper functions to get vendor id, architecture id and implement id
> from M-mode
>
> Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> ---
>  arch/riscv/include/asm/sbi.h |  3 +++
>  arch/riscv/kernel/sbi.c      | 15 +++++++++++++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> index 99895d9c3bdd..94a7f664caf4 100644
> --- a/arch/riscv/include/asm/sbi.h
> +++ b/arch/riscv/include/asm/sbi.h
> @@ -97,6 +97,9 @@ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
>
>  void sbi_console_putchar(int ch);
>  int sbi_console_getchar(void);
> +long sbi_get_vendorid(void);
> +long sbi_get_archid(void);
> +long sbi_get_impid(void);
>  void sbi_set_timer(uint64_t stime_value);
>  void sbi_shutdown(void);
>  void sbi_clear_ipi(void);
> diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
> index f4a7db3d309e..33e3a9d6efab 100644
> --- a/arch/riscv/kernel/sbi.c
> +++ b/arch/riscv/kernel/sbi.c
> @@ -547,6 +547,21 @@ static inline long sbi_get_firmware_version(void)
>  	return __sbi_base_ecall(SBI_EXT_BASE_GET_IMP_VERSION);
>  }
>
> +long sbi_get_vendorid(void)
> +{
> +	return __sbi_base_ecall(SBI_EXT_BASE_GET_MVENDORID);
> +}
> +
> +long sbi_get_archid(void)
> +{
> +	return __sbi_base_ecall(SBI_EXT_BASE_GET_MARCHID);
> +}
> +
> +long sbi_get_impid(void)
> +{
> +	return __sbi_base_ecall(SBI_EXT_BASE_GET_MIMPID);
> +}

The function names should match the SBI function names, which have an extra "m" 
in them.  Otherwise it's just confusing.

> +
>  static void sbi_send_cpumask_ipi(const struct cpumask *target)
>  {
>  	struct cpumask hartid_mask;
Vincent Chen March 11, 2021, 5:21 a.m. UTC | #2
On Wed, Mar 10, 2021 at 12:39 PM Palmer Dabbelt <palmer@dabbelt.com> wrote:
>
> On Sun, 07 Mar 2021 19:58:14 PST (-0800), vincent.chen@sifive.com wrote:
> > Add 3 wrapper functions to get vendor id, architecture id and implement id
> > from M-mode
> >
> > Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
> > ---
> >  arch/riscv/include/asm/sbi.h |  3 +++
> >  arch/riscv/kernel/sbi.c      | 15 +++++++++++++++
> >  2 files changed, 18 insertions(+)
> >
> > diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
> > index 99895d9c3bdd..94a7f664caf4 100644
> > --- a/arch/riscv/include/asm/sbi.h
> > +++ b/arch/riscv/include/asm/sbi.h
> > @@ -97,6 +97,9 @@ struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
> >
> >  void sbi_console_putchar(int ch);
> >  int sbi_console_getchar(void);
> > +long sbi_get_vendorid(void);
> > +long sbi_get_archid(void);
> > +long sbi_get_impid(void);
> >  void sbi_set_timer(uint64_t stime_value);
> >  void sbi_shutdown(void);
> >  void sbi_clear_ipi(void);
> > diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
> > index f4a7db3d309e..33e3a9d6efab 100644
> > --- a/arch/riscv/kernel/sbi.c
> > +++ b/arch/riscv/kernel/sbi.c
> > @@ -547,6 +547,21 @@ static inline long sbi_get_firmware_version(void)
> >       return __sbi_base_ecall(SBI_EXT_BASE_GET_IMP_VERSION);
> >  }
> >
> > +long sbi_get_vendorid(void)
> > +{
> > +     return __sbi_base_ecall(SBI_EXT_BASE_GET_MVENDORID);
> > +}
> > +
> > +long sbi_get_archid(void)
> > +{
> > +     return __sbi_base_ecall(SBI_EXT_BASE_GET_MARCHID);
> > +}
> > +
> > +long sbi_get_impid(void)
> > +{
> > +     return __sbi_base_ecall(SBI_EXT_BASE_GET_MIMPID);
> > +}
>
> The function names should match the SBI function names, which have an extra "m"
> in them.  Otherwise it's just confusing.
>

OK, I will add an extra "m" to them to match the SBI function names.
Thank you for the comments.

> > +
> >  static void sbi_send_cpumask_ipi(const struct cpumask *target)
> >  {
> >       struct cpumask hartid_mask;
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
index 99895d9c3bdd..94a7f664caf4 100644
--- a/arch/riscv/include/asm/sbi.h
+++ b/arch/riscv/include/asm/sbi.h
@@ -97,6 +97,9 @@  struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0,
 
 void sbi_console_putchar(int ch);
 int sbi_console_getchar(void);
+long sbi_get_vendorid(void);
+long sbi_get_archid(void);
+long sbi_get_impid(void);
 void sbi_set_timer(uint64_t stime_value);
 void sbi_shutdown(void);
 void sbi_clear_ipi(void);
diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c
index f4a7db3d309e..33e3a9d6efab 100644
--- a/arch/riscv/kernel/sbi.c
+++ b/arch/riscv/kernel/sbi.c
@@ -547,6 +547,21 @@  static inline long sbi_get_firmware_version(void)
 	return __sbi_base_ecall(SBI_EXT_BASE_GET_IMP_VERSION);
 }
 
+long sbi_get_vendorid(void)
+{
+	return __sbi_base_ecall(SBI_EXT_BASE_GET_MVENDORID);
+}
+
+long sbi_get_archid(void)
+{
+	return __sbi_base_ecall(SBI_EXT_BASE_GET_MARCHID);
+}
+
+long sbi_get_impid(void)
+{
+	return __sbi_base_ecall(SBI_EXT_BASE_GET_MIMPID);
+}
+
 static void sbi_send_cpumask_ipi(const struct cpumask *target)
 {
 	struct cpumask hartid_mask;