Skip to content

Commit 18d7f15

Browse files
Lorenzo PieralisiRussell King
authored andcommitted
ARM: 7763/1: kernel: fix __cpu_logical_map default initialization
The __cpu_logical_map array is statically initialized to 0, which is a valid MPIDR value. To prevent issues with the current implementation, this patch defines an MPIDR_INVALID value, and statically initializes the __cpu_logical_map[] array to it. Entries in the arm_dt_init_cpu_maps() tmp_map array used to stash DT reg properties while parsing DT are initialized with the MPIDR_INVALID value as well for consistency. Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Nicolas Pitre <nico@linaro.org> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 1ba9bf0 commit 18d7f15

4 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎arch/arm/include/asm/cputype.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
#define MPIDR_HWID_BITMASK 0xFFFFFF
3434

35+
#define MPIDR_INVALID (~MPIDR_HWID_BITMASK)
36+
3537
#define MPIDR_LEVEL_BITS 8
3638
#define MPIDR_LEVEL_MASK ((1 << MPIDR_LEVEL_BITS) - 1)
3739

‎arch/arm/include/asm/smp_plat.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static inline int cache_ops_need_broadcast(void)
4949
/*
5050
* Logical CPU mapping.
5151
*/
52-
extern int __cpu_logical_map[];
52+
extern u32 __cpu_logical_map[];
5353
#define cpu_logical_map(cpu) __cpu_logical_map[cpu]
5454
/*
5555
* Retrieve logical cpu index corresponding to a given MPIDR[23:0]

‎arch/arm/kernel/devtree.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void __init arm_dt_init_cpu_maps(void)
8282
u32 i, j, cpuidx = 1;
8383
u32 mpidr = is_smp() ? read_cpuid_mpidr() & MPIDR_HWID_BITMASK : 0;
8484

85-
u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = UINT_MAX };
85+
u32 tmp_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
8686
bool bootcpu_valid = false;
8787
cpus = of_find_node_by_path("/cpus");
8888

‎arch/arm/kernel/setup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ void notrace cpu_init(void)
444444
: "r14");
445445
}
446446

447-
int __cpu_logical_map[NR_CPUS];
447+
u32 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
448448

449449
void __init smp_setup_processor_id(void)
450450
{

0 commit comments

Comments
 (0)