Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park
@ 2020-01-09  3:15 Greentime Hu
  2020-01-09 19:27 ` Paul Walmsley
  0 siblings, 1 reply; 6+ messages in thread
From: Greentime Hu @ 2020-01-09  3:15 UTC (permalink / raw)
  To: green.hu, greentime, paul.walmsley, palmer, linux-riscv,
	linux-kernel, schwab, anup
  Cc: Greentime Hu

The code in secondary_park is currently placed in the .init section.  The
kernel reclaims and clears this code when it finishes booting.  That
causes the cores parked in it to go to somewhere unpredictable, so we
move this function out of init to make sure the cores stay looping there.

Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
---
 arch/riscv/kernel/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index f8f996916c5b..276b98f9d0bd 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -217,11 +217,6 @@ relocate:
 	tail smp_callin
 #endif
 
-.align 2
-.Lsecondary_park:
-	/* We lack SMP support or have too many harts, so park this hart */
-	wfi
-	j .Lsecondary_park
 END(_start)
 
 #ifdef CONFIG_RISCV_M_MODE
@@ -303,6 +298,13 @@ ENTRY(reset_regs)
 END(reset_regs)
 #endif /* CONFIG_RISCV_M_MODE */
 
+.section ".text", "ax",@progbits
+.align 2
+.Lsecondary_park:
+	/* We lack SMP support or have too many harts, so park this hart */
+	wfi
+	j .Lsecondary_park
+
 __PAGE_ALIGNED_BSS
 	/* Empty zero page */
 	.balign PAGE_SIZE
-- 
2.17.1



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

* Re: [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-09  3:15 [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park Greentime Hu
@ 2020-01-09 19:27 ` Paul Walmsley
  2020-01-12 18:12   ` Paul Walmsley
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2020-01-09 19:27 UTC (permalink / raw)
  To: Greentime Hu
  Cc: schwab, linux-kernel, palmer, green.hu, anup, greentime, linux-riscv

On Thu, 9 Jan 2020, Greentime Hu wrote:

> The code in secondary_park is currently placed in the .init section.  The
> kernel reclaims and clears this code when it finishes booting.  That
> causes the cores parked in it to go to somewhere unpredictable, so we
> move this function out of init to make sure the cores stay looping there.
> 
> Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>

Thanks, the following is what's been queued for v5.5-rc.


- Paul

From: Greentime Hu <greentime.hu@sifive.com>
Date: Thu, 9 Jan 2020 11:15:16 +0800
Subject: [PATCH] riscv: make sure the cores stay looping in .Lsecondary_park

The code in secondary_park is currently placed in the .init section.  The
kernel reclaims and clears this code when it finishes booting.  That
causes the cores parked in it to go to somewhere unpredictable, so we
move this function out of init to make sure the cores stay looping there.

Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Cc: Andreas Schwab <schwab@suse.de>
Cc: stable@vger.kernel.org
Fixes: 76d2a0493a17d ("RISC-V: Init and Halt Code")
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
---
 arch/riscv/kernel/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index 797802c73dee..c9cc44ef7184 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -209,11 +209,6 @@ relocate:
 	tail smp_callin
 #endif
 
-.align 2
-.Lsecondary_park:
-	/* We lack SMP support or have too many harts, so park this hart */
-	wfi
-	j .Lsecondary_park
 END(_start)
 
 #ifdef CONFIG_RISCV_M_MODE
@@ -295,6 +290,13 @@ ENTRY(reset_regs)
 END(reset_regs)
 #endif /* CONFIG_RISCV_M_MODE */
 
+.section ".text", "ax",@progbits
+.align 2
+.Lsecondary_park:
+	/* We lack SMP support or have too many harts, so park this hart */
+	wfi
+	j .Lsecondary_park
+
 __PAGE_ALIGNED_BSS
 	/* Empty zero page */
 	.balign PAGE_SIZE
-- 
2.25.0.rc2



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

* Re: [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-09 19:27 ` Paul Walmsley
@ 2020-01-12 18:12   ` Paul Walmsley
  2020-01-14  3:48     ` Greentime Hu
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2020-01-12 18:12 UTC (permalink / raw)
  To: Greentime Hu
  Cc: schwab, linux-kernel, palmer, green.hu, anup, greentime, linux-riscv

Hi Greentime,

On Thu, 9 Jan 2020, Paul Walmsley wrote:

> On Thu, 9 Jan 2020, Greentime Hu wrote:
> 
> > The code in secondary_park is currently placed in the .init section.  The
> > kernel reclaims and clears this code when it finishes booting.  That
> > causes the cores parked in it to go to somewhere unpredictable, so we
> > move this function out of init to make sure the cores stay looping there.
> > 
> > Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
> > Reviewed-by: Anup Patel <anup@brainfault.org>
> 
> Thanks, the following is what's been queued for v5.5-rc.

During final testing, when building the kernel with an initramfs, I hit 
the following linker error:

  LD      .tmp_vmlinux1
arch/riscv/kernel/head.o: in function `.L0 ':(.init.text+0x5c): relocation truncated to fit: R_RISCV_JAL against `.Lsecondary_park'
make[1]: *** [Makefile:1079: vmlinux] Error 1
make: *** [Makefile:326: __build_one_by_one] Error 2

Could you take a look at this?


thanks,

- Paul


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

* Re: [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-12 18:12   ` Paul Walmsley
@ 2020-01-14  3:48     ` Greentime Hu
  2020-01-14 22:55       ` Paul Walmsley
  0 siblings, 1 reply; 6+ messages in thread
From: Greentime Hu @ 2020-01-14  3:48 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: Andreas Schwab, Linux Kernel Mailing List, Palmer Dabbelt, Gt,
	Anup Patel, greentime, linux-riscv

Hi Paul,

On Mon, Jan 13, 2020 at 2:12 AM Paul Walmsley <paul.walmsley@sifive.com> wrote:
>
> Hi Greentime,
>
> On Thu, 9 Jan 2020, Paul Walmsley wrote:
>
> > On Thu, 9 Jan 2020, Greentime Hu wrote:
> >
> > > The code in secondary_park is currently placed in the .init section.  The
> > > kernel reclaims and clears this code when it finishes booting.  That
> > > causes the cores parked in it to go to somewhere unpredictable, so we
> > > move this function out of init to make sure the cores stay looping there.
> > >
> > > Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
> > > Reviewed-by: Anup Patel <anup@brainfault.org>
> >
> > Thanks, the following is what's been queued for v5.5-rc.
>
> During final testing, when building the kernel with an initramfs, I hit
> the following linker error:
>
>   LD      .tmp_vmlinux1
> arch/riscv/kernel/head.o: in function `.L0 ':(.init.text+0x5c): relocation truncated to fit: R_RISCV_JAL against `.Lsecondary_park'
> make[1]: *** [Makefile:1079: vmlinux] Error 1
> make: *** [Makefile:326: __build_one_by_one] Error 2
>
> Could you take a look at this?

I think it is because the sections are too far for bqeu to jump and
the config I used just small enough for it to jump so I didn't see
this bug. Sorry about that.
I tried this fix to boot in Unleashed board.

 #ifdef CONFIG_SMP
        li t0, CONFIG_NR_CPUS
-       bgeu a0, t0, .Lsecondary_park
+       blt a0, t0, .Lgood_cores
+       tail .Lsecondary_park
+.Lgood_cores:
 #endif


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

* Re: [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-14  3:48     ` Greentime Hu
@ 2020-01-14 22:55       ` Paul Walmsley
  2020-01-15  7:06         ` Greentime Hu
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Walmsley @ 2020-01-14 22:55 UTC (permalink / raw)
  To: Greentime Hu
  Cc: Andreas Schwab, Linux Kernel Mailing List, Palmer Dabbelt, Gt,
	Anup Patel, greentime, linux-riscv

Hi Greentime,

On Tue, 14 Jan 2020, Greentime Hu wrote:

> I think it is because the sections are too far for bqeu to jump and
> the config I used just small enough for it to jump so I didn't see
> this bug. Sorry about that.

No problem.

> I tried this fix to boot in Unleashed board.
> 
>  #ifdef CONFIG_SMP
>         li t0, CONFIG_NR_CPUS
> -       bgeu a0, t0, .Lsecondary_park
> +       blt a0, t0, .Lgood_cores
> +       tail .Lsecondary_park
> +.Lgood_cores:
>  #endif

Looks reasonable to me.  Care to update and repost the patch?


- Paul


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

* Re: [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-14 22:55       ` Paul Walmsley
@ 2020-01-15  7:06         ` Greentime Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Greentime Hu @ 2020-01-15  7:06 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: Andreas Schwab, Linux Kernel Mailing List, Palmer Dabbelt, Gt,
	Anup Patel, greentime, linux-riscv

On Wed, Jan 15, 2020 at 6:55 AM Paul Walmsley <paul.walmsley@sifive.com> wrote:
>
> Hi Greentime,
>
> On Tue, 14 Jan 2020, Greentime Hu wrote:
>
> > I think it is because the sections are too far for bqeu to jump and
> > the config I used just small enough for it to jump so I didn't see
> > this bug. Sorry about that.
>
> No problem.
>
> > I tried this fix to boot in Unleashed board.
> >
> >  #ifdef CONFIG_SMP
> >         li t0, CONFIG_NR_CPUS
> > -       bgeu a0, t0, .Lsecondary_park
> > +       blt a0, t0, .Lgood_cores
> > +       tail .Lsecondary_park
> > +.Lgood_cores:
> >  #endif
>
> Looks reasonable to me.  Care to update and repost the patch?

Yes, Paul. I have sent the v4 patch.
It is tested in Unleashed board.


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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09  3:15 [PATCH v3] riscv: make sure the cores stay looping in .Lsecondary_park Greentime Hu
2020-01-09 19:27 ` Paul Walmsley
2020-01-12 18:12   ` Paul Walmsley
2020-01-14  3:48     ` Greentime Hu
2020-01-14 22:55       ` Paul Walmsley
2020-01-15  7:06         ` Greentime Hu

Linux-RISC-V Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-riscv/0 linux-riscv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-riscv linux-riscv/ https://lore.kernel.org/linux-riscv \
		linux-riscv@lists.infradead.org
	public-inbox-index linux-riscv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-riscv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git