Skip to content

Commit f34ee9c

Browse files
pratiksampatmpe
authored andcommitted
cpufreq: powernv: Fix init_chip_info initialization in numa=off
In the numa=off kernel command-line configuration init_chip_info() loops around the number of chips and attempts to copy the cpumask of that node which is NULL for all iterations after the first chip. Hence, store the cpu mask for each chip instead of derving cpumask from node while populating the "chips" struct array and copy that to the chips[i].mask Fixes: 053819e ("cpufreq: powernv: Handle throttling due to Pmax capping at chip level") Cc: stable@vger.kernel.org # v4.3+ Reported-by: Shirisha Ganta <shirisha.ganta1@ibm.com> Signed-off-by: Pratik R. Sampat <psampat@linux.ibm.com> Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com> [mpe: Rename goto label to out_free_chip_cpu_mask] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20210728120500.87549-2-psampat@linux.ibm.com
1 parent 140a89b commit f34ee9c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/cpufreq/powernv-cpufreq.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#define MAX_PSTATE_SHIFT 32
3737
#define LPSTATE_SHIFT 48
3838
#define GPSTATE_SHIFT 56
39+
#define MAX_NR_CHIPS 32
3940

4041
#define MAX_RAMP_DOWN_TIME 5120
4142
/*
@@ -1046,35 +1047,46 @@ static int init_chip_info(void)
10461047
unsigned int *chip;
10471048
unsigned int cpu, i;
10481049
unsigned int prev_chip_id = UINT_MAX;
1050+
cpumask_t *chip_cpu_mask;
10491051
int ret = 0;
10501052

10511053
chip = kcalloc(num_possible_cpus(), sizeof(*chip), GFP_KERNEL);
10521054
if (!chip)
10531055
return -ENOMEM;
10541056

1057+
/* Allocate a chip cpu mask large enough to fit mask for all chips */
1058+
chip_cpu_mask = kcalloc(MAX_NR_CHIPS, sizeof(cpumask_t), GFP_KERNEL);
1059+
if (!chip_cpu_mask) {
1060+
ret = -ENOMEM;
1061+
goto free_and_return;
1062+
}
1063+
10551064
for_each_possible_cpu(cpu) {
10561065
unsigned int id = cpu_to_chip_id(cpu);
10571066

10581067
if (prev_chip_id != id) {
10591068
prev_chip_id = id;
10601069
chip[nr_chips++] = id;
10611070
}
1071+
cpumask_set_cpu(cpu, &chip_cpu_mask[nr_chips-1]);
10621072
}
10631073

10641074
chips = kcalloc(nr_chips, sizeof(struct chip), GFP_KERNEL);
10651075
if (!chips) {
10661076
ret = -ENOMEM;
1067-
goto free_and_return;
1077+
goto out_free_chip_cpu_mask;
10681078
}
10691079

10701080
for (i = 0; i < nr_chips; i++) {
10711081
chips[i].id = chip[i];
1072-
cpumask_copy(&chips[i].mask, cpumask_of_node(chip[i]));
1082+
cpumask_copy(&chips[i].mask, &chip_cpu_mask[i]);
10731083
INIT_WORK(&chips[i].throttle, powernv_cpufreq_work_fn);
10741084
for_each_cpu(cpu, &chips[i].mask)
10751085
per_cpu(chip_info, cpu) = &chips[i];
10761086
}
10771087

1088+
out_free_chip_cpu_mask:
1089+
kfree(chip_cpu_mask);
10781090
free_and_return:
10791091
kfree(chip);
10801092
return ret;

0 commit comments

Comments
 (0)