Linux-RISC-V Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v4] riscv: make sure the cores stay looping in .Lsecondary_park
@ 2020-01-15  6:54 Greentime Hu
  2020-01-16  2:32 ` Paul Walmsley
  0 siblings, 1 reply; 3+ messages in thread
From: Greentime Hu @ 2020-01-15  6:54 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.

The instruction bgeu a0, t0, .Lsecondary_park may have "a relocation
truncated to fit" issue during linking time. It is because that sections
are too far to jump. Let's use tail to jump to the .Lsecondary_park.

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

diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index f8f996916c5b..d7820764122c 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -88,7 +88,9 @@ _start_kernel:
 
 #ifdef CONFIG_SMP
 	li t0, CONFIG_NR_CPUS
-	bgeu a0, t0, .Lsecondary_park
+	blt a0, t0, .Lgood_cores
+	tail .Lsecondary_park
+.Lgood_cores:
 #endif
 
 	/* Pick one hart to run the main boot sequence */
@@ -217,11 +219,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 +300,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] 3+ messages in thread

* Re: [PATCH v4] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-15  6:54 [PATCH v4] riscv: make sure the cores stay looping in .Lsecondary_park Greentime Hu
@ 2020-01-16  2:32 ` Paul Walmsley
  2020-01-16  4:28   ` Anup Patel
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Walmsley @ 2020-01-16  2:32 UTC (permalink / raw)
  To: Greentime Hu, anup
  Cc: schwab, linux-kernel, palmer, green.hu, greentime, linux-riscv

On Wed, 15 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.
> 
> The instruction bgeu a0, t0, .Lsecondary_park may have "a relocation
> truncated to fit" issue during linking time. It is because that sections
> are too far to jump. Let's use tail to jump to the .Lsecondary_park.
> 
> Signed-off-by: Greentime Hu <greentime.hu@sifive.com>

Thanks, queued for v5.5-rc.  Anup's Reviewed-by: has been dropped since 
the patch changed significantly - Anup, if you are still happy with it, 
please reply with another Reviewed-by:.  Thanks,


- Paul


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

* Re: [PATCH v4] riscv: make sure the cores stay looping in .Lsecondary_park
  2020-01-16  2:32 ` Paul Walmsley
@ 2020-01-16  4:28   ` Anup Patel
  0 siblings, 0 replies; 3+ messages in thread
From: Anup Patel @ 2020-01-16  4:28 UTC (permalink / raw)
  To: Paul Walmsley
  Cc: Andreas Schwab, linux-kernel@vger.kernel.org List,
	Palmer Dabbelt, Greentime Hu, greentime, Greentime Hu,
	linux-riscv

On Thu, Jan 16, 2020 at 8:02 AM Paul Walmsley <paul.walmsley@sifive.com> wrote:
>
> On Wed, 15 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.
> >
> > The instruction bgeu a0, t0, .Lsecondary_park may have "a relocation
> > truncated to fit" issue during linking time. It is because that sections
> > are too far to jump. Let's use tail to jump to the .Lsecondary_park.
> >
> > Signed-off-by: Greentime Hu <greentime.hu@sifive.com>
>
> Thanks, queued for v5.5-rc.  Anup's Reviewed-by: has been dropped since
> the patch changed significantly - Anup, if you are still happy with it,
> please reply with another Reviewed-by:.  Thanks,

You can keep my Reviewed-by. I did not see any functional
changes in the patch so I am fine.

Thanks,
Anup


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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15  6:54 [PATCH v4] riscv: make sure the cores stay looping in .Lsecondary_park Greentime Hu
2020-01-16  2:32 ` Paul Walmsley
2020-01-16  4:28   ` Anup Patel

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