summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Cunado <david.cunado@arm.com>2018-04-05 14:07:10 +0100
committerDavid Cunado <david.cunado@arm.com>2018-04-05 17:26:48 +0100
commit699fa90de5b7fe963d4aee73f84f79f9a0b0cfc8 (patch)
tree0fe1cbc2acd36b14692a98955c527c71c2141b98
parent78ea0f89cce0cbde03171ad2855db9de9bab0305 (diff)
FVP: Fix function for translating MPIDR to linear index
The current version of plat_get_core_pos uses an incorrect algorithm to calculate the linear position of a core / PE from its MPIDR. This patch corrects the algorithm to: (ClusterId * FVP_MAX_CPUS_PER_CLUSTER) * FVP_MAX_PE_PER_CPU + (CPUId * FVP_MAX_PE_PER_CPU) + ThreadId Change-Id: Ida862a99a74c2a7f85b813ba270404224aa78987 Signed-off-by: David Cunado <david.cunado@arm.com>
-rw-r--r--plat/arm/board/fvp/aarch32/plat_helpers.S22
-rw-r--r--plat/arm/board/fvp/aarch64/plat_helpers.S15
2 files changed, 24 insertions, 13 deletions
diff --git a/plat/arm/board/fvp/aarch32/plat_helpers.S b/plat/arm/board/fvp/aarch32/plat_helpers.S
index 5b4f91a..3f974b7 100644
--- a/plat/arm/board/fvp/aarch32/plat_helpers.S
+++ b/plat/arm/board/fvp/aarch32/plat_helpers.S
@@ -34,15 +34,20 @@
.globl platform_get_core_pos
-/*-----------------------------------------------------
+/*----------------------------------------------------------------------
* unsigned int platform_get_core_pos(unsigned long mpid)
*
* Function to calculate the core position on FVP.
*
- * (ClusterId * FVP_MAX_CPUS_PER_CLUSTER) +
+ * (ClusterId * FVP_MAX_CPUS_PER_CLUSTER * FVP_MAX_PE_PER_CPU) +
* (CPUId * FVP_MAX_PE_PER_CPU) +
* ThreadId
- * -----------------------------------------------------
+ *
+ * which can be simplified as:
+ *
+ * ((ClusterId * FVP_MAX_CPUS_PER_CLUSTER + CPUId) * FVP_MAX_PE_PER_CPU)
+ * + ThreadId
+ * ---------------------------------------------------------------------
*/
func platform_get_core_pos
/*
@@ -54,14 +59,15 @@ func platform_get_core_pos
lsleq r3, r0, #MPIDR_AFFINITY_BITS
/* Extract individual affinity fields from MPIDR */
- mov r2, #FVP_MAX_PE_PER_CPU
ubfx r0, r3, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS
ubfx r1, r3, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS
- mla r0, r1, r2, r0
-
- mov r1, #FVP_MAX_CPUS_PER_CLUSTER
ubfx r2, r3, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
- mla r0, r1, r2, r0
+
+ /* Compute linear position */
+ mov r3, #FVP_MAX_CPUS_PER_CLUSTER
+ mla r1, r2, r3, r1
+ mov r3, #FVP_MAX_PE_PER_CPU
+ mla r0, r1, r3, r0
bx lr
endfunc platform_get_core_pos
diff --git a/plat/arm/board/fvp/aarch64/plat_helpers.S b/plat/arm/board/fvp/aarch64/plat_helpers.S
index f4c60fb..a0e9d3c 100644
--- a/plat/arm/board/fvp/aarch64/plat_helpers.S
+++ b/plat/arm/board/fvp/aarch64/plat_helpers.S
@@ -34,15 +34,20 @@
.globl platform_get_core_pos
-/*-----------------------------------------------------
+/*----------------------------------------------------------------------
* unsigned int platform_get_core_pos(unsigned long mpid)
*
* Function to calculate the core position on FVP.
*
- * (ClusterId * FVP_MAX_CPUS_PER_CLUSTER) +
+ * (ClusterId * FVP_MAX_CPUS_PER_CLUSTER * FVP_MAX_PE_PER_CPU) +
* (CPUId * FVP_MAX_PE_PER_CPU) +
* ThreadId
- * -----------------------------------------------------
+ *
+ * which can be simplified as:
+ *
+ * ((ClusterId * FVP_MAX_CPUS_PER_CLUSTER + CPUId) * FVP_MAX_PE_PER_CPU)
+ * + ThreadId
+ * ---------------------------------------------------------------------
*/
func platform_get_core_pos
/*
@@ -59,9 +64,9 @@ func platform_get_core_pos
ubfx x2, x3, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS
/* Compute linear position */
+ mov x3, #FVP_MAX_CPUS_PER_CLUSTER
+ madd x1, x2, x3, x1
mov x3, #FVP_MAX_PE_PER_CPU
madd x0, x1, x3, x0
- mov x3, #FVP_MAX_CPUS_PER_CLUSTER
- madd x0, x2, x3, x0
ret
endfunc platform_get_core_pos