diff mbox series

[2/2] riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01

Message ID 1590570293-14225-2-git-send-email-bmeng.cn@gmail.com
State Accepted
Commit 0a94007e829876c7ebd49daebfaa90eea25801b8
Delegated to: Andes
Headers show
Series [1/2] riscv: sbi: Remove sbi_spec_version | expand

Commit Message

Bin Meng May 27, 2020, 9:04 a.m. UTC
From: Bin Meng <bin.meng@windriver.com>

sbi_probe_extension() is an API defined in SBI v0.2, not v0.1.

Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

 arch/riscv/lib/sbi.c | 37 +++++++++++++++++++------------------
 1 file changed, 19 insertions(+), 18 deletions(-)

Comments

Rick Chen June 1, 2020, 7:59 a.m. UTC | #1
> From: Bin Meng [mailto:bmeng.cn@gmail.com]
> Sent: Wednesday, May 27, 2020 5:05 PM
> To: Rick Jian-Zhi Chen(陳建志); U-Boot Mailing List
> Cc: Atish Patra; Bin Meng
> Subject: [PATCH 2/2] riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01
>
> From: Bin Meng <bin.meng@windriver.com>
>
> sbi_probe_extension() is an API defined in SBI v0.2, not v0.1.
>
> Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---

Reviewed-by: Rick Chen <rick@andestech.com>

>
>  arch/riscv/lib/sbi.c | 37 +++++++++++++++++++------------------
>  1 file changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c index f298846..8fbc238 100644
> --- a/arch/riscv/lib/sbi.c
> +++ b/arch/riscv/lib/sbi.c
> @@ -53,6 +53,25 @@ void sbi_set_timer(uint64_t stime_value)  #endif  }
>
> +/**
> + * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
> + * @extid: The extension ID to be probed.
> + *
> + * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
> + */
> +int sbi_probe_extension(int extid)
> +{
> +       struct sbiret ret;
> +
> +       ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
> +                       0, 0, 0, 0, 0);
> +       if (!ret.error)
> +               if (ret.value)
> +                       return ret.value;
> +
> +       return -ENOTSUPP;
> +}
> +
>  #ifdef CONFIG_SBI_V01
>
>  /**
> @@ -162,22 +181,4 @@ void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
>                   (unsigned long)hart_mask, start, size, asid, 0, 0);  }
>
> -/**
> - * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
> - * @extid: The extension ID to be probed.
> - *
> - * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
> - */
> -int sbi_probe_extension(int extid)
> -{
> -       struct sbiret ret;
> -
> -       ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
> -                       0, 0, 0, 0, 0);
> -       if (!ret.error)
> -               if (ret.value)
> -                       return ret.value;
> -
> -       return -ENOTSUPP;
> -}
>  #endif /* CONFIG_SBI_V01 */
> --
> 2.7.4
>
Rick Chen June 1, 2020, 9:07 a.m. UTC | #2
Hi Bin

> > From: Bin Meng [mailto:bmeng.cn@gmail.com]
> > Sent: Wednesday, May 27, 2020 5:05 PM
> > To: Rick Jian-Zhi Chen(陳建志); U-Boot Mailing List
> > Cc: Atish Patra; Bin Meng
> > Subject: [PATCH 2/2] riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01
> >
> > From: Bin Meng <bin.meng@windriver.com>
> >
> > sbi_probe_extension() is an API defined in SBI v0.2, not v0.1.
> >
> > Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
> > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > ---
>
> Reviewed-by: Rick Chen <rick@andestech.com>
>

BTW, it seem look like sbi_remote_fence_i, sbi_remote_sfence_vma and
sbi_remote_sfence_vma_asid
are all can be used no mater in SBI_V01 or SBI_V02. Because you have
distinguished them in sbi.h

Thanks,
Rick

> >
> >  arch/riscv/lib/sbi.c | 37 +++++++++++++++++++------------------
> >  1 file changed, 19 insertions(+), 18 deletions(-)
> >
> > diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c index f298846..8fbc238 100644
> > --- a/arch/riscv/lib/sbi.c
> > +++ b/arch/riscv/lib/sbi.c
> > @@ -53,6 +53,25 @@ void sbi_set_timer(uint64_t stime_value)  #endif  }
> >
> > +/**
> > + * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
> > + * @extid: The extension ID to be probed.
> > + *
> > + * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
> > + */
> > +int sbi_probe_extension(int extid)
> > +{
> > +       struct sbiret ret;
> > +
> > +       ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
> > +                       0, 0, 0, 0, 0);
> > +       if (!ret.error)
> > +               if (ret.value)
> > +                       return ret.value;
> > +
> > +       return -ENOTSUPP;
> > +}
> > +
> >  #ifdef CONFIG_SBI_V01
> >
> >  /**
> > @@ -162,22 +181,4 @@ void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
> >                   (unsigned long)hart_mask, start, size, asid, 0, 0);  }
> >
> > -/**
> > - * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
> > - * @extid: The extension ID to be probed.
> > - *
> > - * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
> > - */
> > -int sbi_probe_extension(int extid)
> > -{
> > -       struct sbiret ret;
> > -
> > -       ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
> > -                       0, 0, 0, 0, 0);
> > -       if (!ret.error)
> > -               if (ret.value)
> > -                       return ret.value;
> > -
> > -       return -ENOTSUPP;
> > -}
> >  #endif /* CONFIG_SBI_V01 */
> > --
> > 2.7.4
> >
Bin Meng June 1, 2020, 9:09 a.m. UTC | #3
Hi Rick,

On Mon, Jun 1, 2020 at 5:08 PM Rick Chen <rickchen36@gmail.com> wrote:
>
> Hi Bin
>
> > > From: Bin Meng [mailto:bmeng.cn@gmail.com]
> > > Sent: Wednesday, May 27, 2020 5:05 PM
> > > To: Rick Jian-Zhi Chen(陳建志); U-Boot Mailing List
> > > Cc: Atish Patra; Bin Meng
> > > Subject: [PATCH 2/2] riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01
> > >
> > > From: Bin Meng <bin.meng@windriver.com>
> > >
> > > sbi_probe_extension() is an API defined in SBI v0.2, not v0.1.
> > >
> > > Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
> > > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > > ---
> >
> > Reviewed-by: Rick Chen <rick@andestech.com>
> >
>
> BTW, it seem look like sbi_remote_fence_i, sbi_remote_sfence_vma and
> sbi_remote_sfence_vma_asid
> are all can be used no mater in SBI_V01 or SBI_V02. Because you have
> distinguished them in sbi.h

No these calls are different and not compatible between SBI_V01 and SBI_V02.

See commit 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")

Regards,
Bin
Atish Patra June 2, 2020, 6:32 p.m. UTC | #4
On Mon, Jun 1, 2020 at 2:09 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi Rick,
>
> On Mon, Jun 1, 2020 at 5:08 PM Rick Chen <rickchen36@gmail.com> wrote:
> >
> > Hi Bin
> >
> > > > From: Bin Meng [mailto:bmeng.cn@gmail.com]
> > > > Sent: Wednesday, May 27, 2020 5:05 PM
> > > > To: Rick Jian-Zhi Chen(陳建志); U-Boot Mailing List
> > > > Cc: Atish Patra; Bin Meng
> > > > Subject: [PATCH 2/2] riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01
> > > >
> > > > From: Bin Meng <bin.meng@windriver.com>
> > > >
> > > > sbi_probe_extension() is an API defined in SBI v0.2, not v0.1.
> > > >
> > > > Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
> > > > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > > > ---
> > >
> > > Reviewed-by: Rick Chen <rick@andestech.com>
> > >
> >
> > BTW, it seem look like sbi_remote_fence_i, sbi_remote_sfence_vma and
> > sbi_remote_sfence_vma_asid
> > are all can be used no mater in SBI_V01 or SBI_V02. Because you have
> > distinguished them in sbi.h
>
> No these calls are different and not compatible between SBI_V01 and SBI_V02.
>

In addition to that, U-Boot proper enables SMP only for SBI_V01
because U-Boot doesn't need
boot all the cores if the supervisor OS & SBI provider supports SBI
v0.2 with HSM.

Starting with OpenSBI v0.7 & Linux kernel 5.7 supports both. Thus,
there is no advantage in adding
redundant code in a generic path that is never going to be used.

Any SBI provider that only supports SBI v0.1, the user can fall back
to SBI_V01 config.
> See commit 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
>
> Regards,
> Bin
Rick Chen June 3, 2020, 1:16 a.m. UTC | #5
Hi Atish

Atish Patra <atishp@atishpatra.org> 於 2020年6月3日 週三 上午2:32寫道:
>
> On Mon, Jun 1, 2020 at 2:09 AM Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Hi Rick,
> >
> > On Mon, Jun 1, 2020 at 5:08 PM Rick Chen <rickchen36@gmail.com> wrote:
> > >
> > > Hi Bin
> > >
> > > > > From: Bin Meng [mailto:bmeng.cn@gmail.com]
> > > > > Sent: Wednesday, May 27, 2020 5:05 PM
> > > > > To: Rick Jian-Zhi Chen(陳建志); U-Boot Mailing List
> > > > > Cc: Atish Patra; Bin Meng
> > > > > Subject: [PATCH 2/2] riscv: sbi: Move sbi_probe_extension() out of CONFIG_SBI_V01
> > > > >
> > > > > From: Bin Meng <bin.meng@windriver.com>
> > > > >
> > > > > sbi_probe_extension() is an API defined in SBI v0.2, not v0.1.
> > > > >
> > > > > Fixes 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
> > > > > Signed-off-by: Bin Meng <bin.meng@windriver.com>
> > > > > ---
> > > >
> > > > Reviewed-by: Rick Chen <rick@andestech.com>
> > > >
> > >
> > > BTW, it seem look like sbi_remote_fence_i, sbi_remote_sfence_vma and
> > > sbi_remote_sfence_vma_asid
> > > are all can be used no mater in SBI_V01 or SBI_V02. Because you have
> > > distinguished them in sbi.h
> >
> > No these calls are different and not compatible between SBI_V01 and SBI_V02.
> >
>
> In addition to that, U-Boot proper enables SMP only for SBI_V01
> because U-Boot doesn't need
> boot all the cores if the supervisor OS & SBI provider supports SBI
> v0.2 with HSM.
>
> Starting with OpenSBI v0.7 & Linux kernel 5.7 supports both. Thus,
> there is no advantage in adding
> redundant code in a generic path that is never going to be used.
>
> Any SBI provider that only supports SBI v0.1, the user can fall back
> to SBI_V01 config.

Thanks for your explanation.

Regards,
Rick

> > See commit 7e249bc13aaf: ("riscv: Move all SMP related SBI calls to SBI_v01")
> >
> > Regards,
> > Bin
>
>
>
> --
> Regards,
> Atish
diff mbox series

Patch

diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
index f298846..8fbc238 100644
--- a/arch/riscv/lib/sbi.c
+++ b/arch/riscv/lib/sbi.c
@@ -53,6 +53,25 @@  void sbi_set_timer(uint64_t stime_value)
 #endif
 }
 
+/**
+ * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
+ * @extid: The extension ID to be probed.
+ *
+ * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
+ */
+int sbi_probe_extension(int extid)
+{
+	struct sbiret ret;
+
+	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
+			0, 0, 0, 0, 0);
+	if (!ret.error)
+		if (ret.value)
+			return ret.value;
+
+	return -ENOTSUPP;
+}
+
 #ifdef CONFIG_SBI_V01
 
 /**
@@ -162,22 +181,4 @@  void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
 		  (unsigned long)hart_mask, start, size, asid, 0, 0);
 }
 
-/**
- * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
- * @extid: The extension ID to be probed.
- *
- * Return: Extension specific nonzero value f yes, -ENOTSUPP otherwise.
- */
-int sbi_probe_extension(int extid)
-{
-	struct sbiret ret;
-
-	ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_PROBE_EXT, extid,
-			0, 0, 0, 0, 0);
-	if (!ret.error)
-		if (ret.value)
-			return ret.value;
-
-	return -ENOTSUPP;
-}
 #endif /* CONFIG_SBI_V01 */