diff mbox

[U-Boot,v5,02/14] ARM: Factor out common psci_get_cpu_id

Message ID 11dc905983694dd628cdb06700275f4ac8d163bc.1425884424.git.jan.kiszka@siemens.com
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Jan Kiszka March 9, 2015, 7 a.m. UTC
Will be required for obtaining the ID of the current CPU in shared PSCI
functions. The default implementation requires a dense ID space and only
supports a single cluster. Therefore, the functions can be overloaded in
cases where these assumptions do not hold.

CC: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/arm/cpu/armv7/psci.S       |  8 ++++++++
 arch/arm/cpu/armv7/sunxi/psci.S | 12 +++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

Comments

Tom Rini March 11, 2015, 3:11 p.m. UTC | #1
On Mon, Mar 09, 2015 at 08:00:12AM +0100, Jan Kiszka wrote:

> Will be required for obtaining the ID of the current CPU in shared PSCI
> functions. The default implementation requires a dense ID space and only
> supports a single cluster. Therefore, the functions can be overloaded in
> cases where these assumptions do not hold.
> 
> CC: Marc Zyngier <marc.zyngier@arm.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Ian Campbell March 18, 2015, 4:54 p.m. UTC | #2
On Mon, 2015-03-09 at 08:00 +0100, Jan Kiszka wrote:
> Will be required for obtaining the ID of the current CPU in shared PSCI
> functions. The default implementation requires a dense ID space and only
> supports a single cluster. Therefore, the functions can be overloaded in
> cases where these assumptions do not hold.
> 
> CC: Marc Zyngier <marc.zyngier@arm.com>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>  
> +@ Requires dense and single-cluste CPU ID space

"cluster"

Other than that: Acked-by: Ian Campbell <ijc@hellion.org.uk>
Jan Kiszka March 19, 2015, 7:52 a.m. UTC | #3
On 2015-03-18 17:54, Ian Campbell wrote:
> On Mon, 2015-03-09 at 08:00 +0100, Jan Kiszka wrote:
>> Will be required for obtaining the ID of the current CPU in shared PSCI
>> functions. The default implementation requires a dense ID space and only
>> supports a single cluster. Therefore, the functions can be overloaded in
>> cases where these assumptions do not hold.
>>
>> CC: Marc Zyngier <marc.zyngier@arm.com>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>>  
>> +@ Requires dense and single-cluste CPU ID space
> 
> "cluster"
> 
> Other than that: Acked-by: Ian Campbell <ijc@hellion.org.uk>
> 

Thanks, fixed locally. I will resend the series if requested or more
remarks arrive.

Jan
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/psci.S b/arch/arm/cpu/armv7/psci.S
index bf11a34..0df6633 100644
--- a/arch/arm/cpu/armv7/psci.S
+++ b/arch/arm/cpu/armv7/psci.S
@@ -99,4 +99,12 @@  _smc_psci:
 	pop	{r4-r7, lr}
 	movs	pc, lr			@ Return to the kernel
 
+@ Requires dense and single-cluste CPU ID space
+ENTRY(psci_get_cpu_id)
+	mrc	p15, 0, r0, c0, c0, 5	/* read MPIDR */
+	and	r0, r0, #0xff		/* return CPU ID in cluster */
+	bx	lr
+ENDPROC(psci_get_cpu_id)
+.weak psci_get_cpu_id
+
 	.popsection
diff --git a/arch/arm/cpu/armv7/sunxi/psci.S b/arch/arm/cpu/armv7/sunxi/psci.S
index 9e898f2..e29ae65 100644
--- a/arch/arm/cpu/armv7/sunxi/psci.S
+++ b/arch/arm/cpu/armv7/sunxi/psci.S
@@ -19,6 +19,7 @@ 
 
 #include <config.h>
 #include <asm/gic.h>
+#include <asm/macro.h>
 #include <asm/psci.h>
 #include <asm/arch/cpu.h>
 
@@ -290,6 +291,8 @@  psci_cpu_off:
 
 .globl	psci_arch_init
 psci_arch_init:
+	mov	r6, lr
+
 	movw	r4, #(GICD_BASE & 0xffff)
 	movt	r4, #(GICD_BASE >> 16)
 
@@ -315,18 +318,17 @@  psci_arch_init:
 	mcr	p15, 0, r5, c1, c1, 0	@ Write SCR
 	isb
 
-	mrc	p15, 0, r4, c0, c0, 5	@ MPIDR
-	and	r4, r4, #3		@ cpu number in cluster
+	bl	psci_get_cpu_id
 	mov	r5, #0x400		@ 1kB of stack per CPU
-	mul	r4, r4, r5
+	mul	r0, r0, r5
 
 	adr	r5, text_end		@ end of text
 	add	r5, r5, #0x2000		@ Skip two pages
 	lsr	r5, r5, #12		@ Align to start of page
 	lsl	r5, r5, #12
-	sub	sp, r5, r4		@ here's our stack!
+	sub	sp, r5, r0		@ here's our stack!
 
-	bx	lr
+	bx	r6
 
 text_end:
 	.popsection