public inbox for opensbi@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2] generic: mips: support harts to boot from mips_warm_boot
@ 2025-07-22 23:04 Chao-ying Fu
  2025-07-23  0:18 ` Samuel Holland
  0 siblings, 1 reply; 3+ messages in thread
From: Chao-ying Fu @ 2025-07-22 23:04 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 | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
index 888a45c..8c93ebf 100644
--- a/platform/generic/mips/p8700.c
+++ b/platform/generic/mips/p8700.c
@@ -140,6 +140,20 @@ 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	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	"	.align	2\n"
+	"	j	_start_warm\n"
+	);
+}
+
 static int mips_hart_start(u32 hartid, ulong saddr)
 {
 	unsigned int stat;
@@ -150,6 +164,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] 3+ messages in thread

* Re: [PATCH v2] generic: mips: support harts to boot from mips_warm_boot
  2025-07-22 23:04 [PATCH v2] generic: mips: support harts to boot from mips_warm_boot Chao-ying Fu
@ 2025-07-23  0:18 ` Samuel Holland
  2025-07-23 20:37   ` Chao-ying Fu
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Holland @ 2025-07-23  0:18 UTC (permalink / raw)
  To: Chao-ying Fu, opensbi; +Cc: Chao-ying Fu

Hi Chao-ying,

On 2025-07-22 6:04 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 | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
> index 888a45c..8c93ebf 100644
> --- a/platform/generic/mips/p8700.c
> +++ b/platform/generic/mips/p8700.c
> @@ -140,6 +140,20 @@ static void power_up_other_cluster(u32 hartid)
>  }
>  #endif
>  
> +static void __attribute__((naked,no_instrument_function,aligned(4096)))

Please follow Jess's suggestion and use an assembly file like we already do for
platform/generic/andes/sleep.S. This will be more reliable than forever fighting
the compiler to keep it from inserting any instructions on its own. (Are you
_sure_ that this list of attributes covers every toolchain and configuration?)

Regards,
Samuel

> +mips_warm_boot(void)
> +{
> +  __asm__ __volatile__(
> +	"	j	_start_warm\n"
> +	"	.align	2\n"
> +	"	j	_start_warm\n"
> +	"	.align	2\n"
> +	"	j	_start_warm\n"
> +	"	.align	2\n"
> +	"	j	_start_warm\n"
> +	);
> +}
> +
>  static int mips_hart_start(u32 hartid, ulong saddr)
>  {
>  	unsigned int stat;
> @@ -150,6 +164,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] 3+ messages in thread

* Re: [PATCH v2] generic: mips: support harts to boot from mips_warm_boot
  2025-07-23  0:18 ` Samuel Holland
@ 2025-07-23 20:37   ` Chao-ying Fu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao-ying Fu @ 2025-07-23 20:37 UTC (permalink / raw)
  To: Samuel Holland; +Cc: opensbi, Chao-ying Fu

On Tue, Jul 22, 2025 at 5:18 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> Hi Chao-ying,
>
> On 2025-07-22 6:04 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 | 17 +++++++++++++++++
> >  1 file changed, 17 insertions(+)
> >
> > diff --git a/platform/generic/mips/p8700.c b/platform/generic/mips/p8700.c
> > index 888a45c..8c93ebf 100644
> > --- a/platform/generic/mips/p8700.c
> > +++ b/platform/generic/mips/p8700.c
> > @@ -140,6 +140,20 @@ static void power_up_other_cluster(u32 hartid)
> >  }
> >  #endif
> >
> > +static void __attribute__((naked,no_instrument_function,aligned(4096)))
>
> Please follow Jess's suggestion and use an assembly file like we already do for
> platform/generic/andes/sleep.S. This will be more reliable than forever fighting
> the compiler to keep it from inserting any instructions on its own. (Are you
> _sure_ that this list of attributes covers every toolchain and configuration?)
>
Hi Sam,

  Ok. I will change to use an assembly file and send out v3 soon,
similar to sleep.S.
  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] 3+ messages in thread

end of thread, other threads:[~2025-07-23 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-22 23:04 [PATCH v2] generic: mips: support harts to boot from mips_warm_boot Chao-ying Fu
2025-07-23  0:18 ` Samuel Holland
2025-07-23 20:37   ` 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