Skip to content

Commit

Permalink
irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
  • Loading branch information
zijun_hu authored and Marc Zyngier committed Sep 19, 2017
1 parent 2bd6bf0 commit 3fad4cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/irqchip/irq-gic-v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,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)
Expand All @@ -1056,9 +1056,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;
}
Expand Down

0 comments on commit 3fad4cd

Please sign in to comment.