Skip to content

Commit 3fad4cd

Browse files
zijun_huMarc Zyngier
authored andcommitted
irqchip/gic-v3: Iterate over possible CPUs by for_each_possible_cpu()
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]>
1 parent 2bd6bf0 commit 3fad4cd

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/irqchip/irq-gic-v3.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ static int get_cpu_number(struct device_node *dn)
10421042
{
10431043
const __be32 *cell;
10441044
u64 hwid;
1045-
int i;
1045+
int cpu;
10461046

10471047
cell = of_get_property(dn, "reg", NULL);
10481048
if (!cell)
@@ -1056,9 +1056,9 @@ static int get_cpu_number(struct device_node *dn)
10561056
if (hwid & ~MPIDR_HWID_BITMASK)
10571057
return -1;
10581058

1059-
for (i = 0; i < num_possible_cpus(); i++)
1060-
if (cpu_logical_map(i) == hwid)
1061-
return i;
1059+
for_each_possible_cpu(cpu)
1060+
if (cpu_logical_map(cpu) == hwid)
1061+
return cpu;
10621062

10631063
return -1;
10641064
}

0 commit comments

Comments
 (0)