irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()

[ Upstream commit 3fad4cdac235c5b13227d0c09854c689ae62c70b ]

get_cpu_number() doesn't use existing helper to iterate over possible
CPUs, It will cause an error in case of discontinuous @cpu_possible_mask
such as 0b11110001, which can result from a core having failed to come
up on a SMP machine.

Fixed by using existing helper for_each_possible_cpu().

Signed-off-by: zijun_hu <zijun_hu@htc.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
zijun_hu 2017-09-16 01:59:41 +08:00 committed by Greg Kroah-Hartman
parent 87da903ce6
commit 3fe0d94cec

View File

@ -982,7 +982,7 @@ static int get_cpu_number(struct device_node *dn)
{
const __be32 *cell;
u64 hwid;
int i;
int cpu;
cell = of_get_property(dn, "reg", NULL);
if (!cell)
@ -996,9 +996,9 @@ static int get_cpu_number(struct device_node *dn)
if (hwid & ~MPIDR_HWID_BITMASK)
return -1;
for (i = 0; i < num_possible_cpus(); i++)
if (cpu_logical_map(i) == hwid)
return i;
for_each_possible_cpu(cpu)
if (cpu_logical_map(cpu) == hwid)
return cpu;
return -1;
}