public inbox for opensbi@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v1] generic: mips: support harts to boot from mips_warm_boot
@ 2025-07-10 23:17 Chao-ying Fu
  2025-07-11  4:33 ` Jessica Clarke
  2025-07-17  0:04 ` Samuel Holland
  0 siblings, 2 replies; 5+ messages in thread
From: Chao-ying Fu @ 2025-07-10 23:17 UTC (permalink / raw)
  To: opensbi; +Cc: Chao-ying Fu

We program reset base for harts (other than hart 0) to boot at
mips_warm_boot that jumps to _start_warm. This helps to skip some code
sequence to speed up.

Signed-off-by: Chao-ying Fu <cfu@mips.com>
---
 platform/generic/mips/p8700.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
index 888a45c..687912a 100644
--- a/platform/generic/mips/p8700.c
+++ b/platform/generic/mips/p8700.c
@@ -140,6 +140,22 @@ static void power_up_other_cluster(u32 hartid)
 }
 #endif
 
+static void __attribute__((naked,no_instrument_function,aligned(4096)))
+mips_warm_boot(void)
+{
+  __asm__ __volatile__(
+	"	j	1f\n"
+	"	.align	2\n"
+	"	j	1f\n"
+	"	.align	2\n"
+	"	j	1f\n"
+	"	.align	2\n"
+	"	j	1f\n"
+	"1:	lla	t0, _start_warm\n"
+	"	jr	t0\n"
+	);
+}
+
 static int mips_hart_start(u32 hartid, ulong saddr)
 {
 	unsigned int stat;
@@ -150,6 +166,9 @@ static int mips_hart_start(u32 hartid, ulong saddr)
 	if (hartid == 0)
 		return SBI_ENOTSUPP;
 
+	/* Change reset base to mips_warm_boot */
+	write_gcr_co_reset_base(hartid, (unsigned long)mips_warm_boot, local_p);
+
 	if (cpu_hart(hartid) == 0) {
 		/* Ensure its coherency is disabled */
 		write_gcr_co_coherence(hartid, 0, local_p);
-- 
2.47.1


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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] generic: mips: support harts to boot from mips_warm_boot
  2025-07-10 23:17 [PATCH v1] generic: mips: support harts to boot from mips_warm_boot Chao-ying Fu
@ 2025-07-11  4:33 ` Jessica Clarke
  2025-07-16 23:17   ` Chao-ying Fu
  2025-07-17  0:04 ` Samuel Holland
  1 sibling, 1 reply; 5+ messages in thread
From: Jessica Clarke @ 2025-07-11  4:33 UTC (permalink / raw)
  To: Chao-ying Fu; +Cc: opensbi, Chao-ying Fu

On 11 Jul 2025, at 00:17, Chao-ying Fu <icebergfu@gmail.com> wrote:
> 
> We program reset base for harts (other than hart 0) to boot at
> mips_warm_boot that jumps to _start_warm. This helps to skip some code
> sequence to speed up.
> 
> Signed-off-by: Chao-ying Fu <cfu@mips.com>
> ---
> platform/generic/mips/p8700.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
> 
> diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
> index 888a45c..687912a 100644
> --- a/platform/generic/mips/p8700.c
> +++ b/platform/generic/mips/p8700.c
> @@ -140,6 +140,22 @@ static void power_up_other_cluster(u32 hartid)
> }
> #endif
> 
> +static void __attribute__((naked,no_instrument_function,aligned(4096)))
> +mips_warm_boot(void)
> +{
> +  __asm__ __volatile__(
> + " j 1f\n"
> + " .align 2\n"
> + " j 1f\n"
> + " .align 2\n"
> + " j 1f\n"
> + " .align 2\n"
> + " j 1f\n"
> + "1: lla t0, _start_warm\n"
> + " jr t0\n"
> + );
> +}

What is the point of writing this as a C function if it’s going to be
entirely assembly? Just write an assembly function?

Jess


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] generic: mips: support harts to boot from mips_warm_boot
  2025-07-11  4:33 ` Jessica Clarke
@ 2025-07-16 23:17   ` Chao-ying Fu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao-ying Fu @ 2025-07-16 23:17 UTC (permalink / raw)
  To: Jessica Clarke; +Cc: opensbi, Chao-ying Fu

On Thu, Jul 10, 2025 at 9:34 PM Jessica Clarke <jrtc27@jrtc27.com> wrote:
>
> On 11 Jul 2025, at 00:17, Chao-ying Fu <icebergfu@gmail.com> wrote:
> >
> > We program reset base for harts (other than hart 0) to boot at
> > mips_warm_boot that jumps to _start_warm. This helps to skip some code
> > sequence to speed up.
> >
> > Signed-off-by: Chao-ying Fu <cfu@mips.com>
> > ---
> > platform/generic/mips/p8700.c | 19 +++++++++++++++++++
> > 1 file changed, 19 insertions(+)
> >
> > diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
> > index 888a45c..687912a 100644
> > --- a/platform/generic/mips/p8700.c
> > +++ b/platform/generic/mips/p8700.c
> > @@ -140,6 +140,22 @@ static void power_up_other_cluster(u32 hartid)
> > }
> > #endif
> >
> > +static void __attribute__((naked,no_instrument_function,aligned(4096)))
> > +mips_warm_boot(void)
> > +{
> > +  __asm__ __volatile__(
> > + " j 1f\n"
> > + " .align 2\n"
> > + " j 1f\n"
> > + " .align 2\n"
> > + " j 1f\n"
> > + " .align 2\n"
> > + " j 1f\n"
> > + "1: lla t0, _start_warm\n"
> > + " jr t0\n"
> > + );
> > +}
>
> What is the point of writing this as a C function if it’s going to be
> entirely assembly? Just write an assembly function?

  My intention is to have a minimum change, as there is only one file
modified in the patch.
Either writing assembly code or writing C code for mips_warm_boot is
fine or equivalent.
To have assembly code, we will need to modify Makefile and create a
new assembly file in the patch.

  Thanks a lot!

Regards,
Chao-ying

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] generic: mips: support harts to boot from mips_warm_boot
  2025-07-10 23:17 [PATCH v1] generic: mips: support harts to boot from mips_warm_boot Chao-ying Fu
  2025-07-11  4:33 ` Jessica Clarke
@ 2025-07-17  0:04 ` Samuel Holland
  2025-07-22 21:35   ` Chao-ying Fu
  1 sibling, 1 reply; 5+ messages in thread
From: Samuel Holland @ 2025-07-17  0:04 UTC (permalink / raw)
  To: Chao-ying Fu, opensbi; +Cc: Chao-ying Fu

On 2025-07-10 6:17 PM, Chao-ying Fu wrote:
> We program reset base for harts (other than hart 0) to boot at
> mips_warm_boot that jumps to _start_warm. This helps to skip some code
> sequence to speed up.
> 
> Signed-off-by: Chao-ying Fu <cfu@mips.com>
> ---
>  platform/generic/mips/p8700.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
> index 888a45c..687912a 100644
> --- a/platform/generic/mips/p8700.c
> +++ b/platform/generic/mips/p8700.c
> @@ -140,6 +140,22 @@ static void power_up_other_cluster(u32 hartid)
>  }
>  #endif
>  
> +static void __attribute__((naked,no_instrument_function,aligned(4096)))
> +mips_warm_boot(void)
> +{
> +  __asm__ __volatile__(
> +	"	j	1f\n"
> +	"	.align	2\n"
> +	"	j	1f\n"
> +	"	.align	2\n"
> +	"	j	1f\n"
> +	"	.align	2\n"
> +	"	j	1f\n"
> +	"1:	lla	t0, _start_warm\n"
> +	"	jr	t0\n"

The double/indirect jump is not necessary. jal (j) range is +/- 1 MiB, which is
much larger than the OpenSBI firmware size. So each entry point can jump to
_start_warm directly.

Regards,
Samuel

> +	);
> +}
> +
>  static int mips_hart_start(u32 hartid, ulong saddr)
>  {
>  	unsigned int stat;
> @@ -150,6 +166,9 @@ static int mips_hart_start(u32 hartid, ulong saddr)
>  	if (hartid == 0)
>  		return SBI_ENOTSUPP;
>  
> +	/* Change reset base to mips_warm_boot */
> +	write_gcr_co_reset_base(hartid, (unsigned long)mips_warm_boot, local_p);
> +
>  	if (cpu_hart(hartid) == 0) {
>  		/* Ensure its coherency is disabled */
>  		write_gcr_co_coherence(hartid, 0, local_p);


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] generic: mips: support harts to boot from mips_warm_boot
  2025-07-17  0:04 ` Samuel Holland
@ 2025-07-22 21:35   ` Chao-ying Fu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao-ying Fu @ 2025-07-22 21:35 UTC (permalink / raw)
  To: Samuel Holland; +Cc: opensbi, Chao-ying Fu

On Wed, Jul 16, 2025 at 5:04 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> On 2025-07-10 6:17 PM, Chao-ying Fu wrote:
> > We program reset base for harts (other than hart 0) to boot at
> > mips_warm_boot that jumps to _start_warm. This helps to skip some code
> > sequence to speed up.
> >
> > Signed-off-by: Chao-ying Fu <cfu@mips.com>
> > ---
> >  platform/generic/mips/p8700.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
> > index 888a45c..687912a 100644
> > --- a/platform/generic/mips/p8700.c
> > +++ b/platform/generic/mips/p8700.c
> > @@ -140,6 +140,22 @@ static void power_up_other_cluster(u32 hartid)
> >  }
> >  #endif
> >
> > +static void __attribute__((naked,no_instrument_function,aligned(4096)))
> > +mips_warm_boot(void)
> > +{
> > +  __asm__ __volatile__(
> > +     "       j       1f\n"
> > +     "       .align  2\n"
> > +     "       j       1f\n"
> > +     "       .align  2\n"
> > +     "       j       1f\n"
> > +     "       .align  2\n"
> > +     "       j       1f\n"
> > +     "1:     lla     t0, _start_warm\n"
> > +     "       jr      t0\n"
>
> The double/indirect jump is not necessary. jal (j) range is +/- 1 MiB, which is
> much larger than the OpenSBI firmware size. So each entry point can jump to
> _start_warm directly.
>
> Regards,
> Samuel
  Yes, we can use only one jump instruction to _start_warm for each
entry point, as you pointed out.
I will send out a new patch.

  Thanks a lot!

Regards,
Chao-ying

>
> > +     );
> > +}
> > +
> >  static int mips_hart_start(u32 hartid, ulong saddr)
> >  {
> >       unsigned int stat;
> > @@ -150,6 +166,9 @@ static int mips_hart_start(u32 hartid, ulong saddr)
> >       if (hartid == 0)
> >               return SBI_ENOTSUPP;
> >
> > +     /* Change reset base to mips_warm_boot */
> > +     write_gcr_co_reset_base(hartid, (unsigned long)mips_warm_boot, local_p);
> > +
> >       if (cpu_hart(hartid) == 0) {
> >               /* Ensure its coherency is disabled */
> >               write_gcr_co_coherence(hartid, 0, local_p);
>

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-22 21:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10 23:17 [PATCH v1] generic: mips: support harts to boot from mips_warm_boot Chao-ying Fu
2025-07-11  4:33 ` Jessica Clarke
2025-07-16 23:17   ` Chao-ying Fu
2025-07-17  0:04 ` Samuel Holland
2025-07-22 21:35   ` Chao-ying Fu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox