arm: topology: fix the topology reset path during init
init_cpu_topology has a bug where 1. It's referring to out of bounds array. 2. It's not actually resetting topology for each cpu. Fix this by iterating for each cpu for resetting topology. Change-Id: I4df03fb4fbe9cb636f135de982e35173b1900ec2 Signed-off-by: Srinivas Ramana <sramana@codeaurora.org>
This commit is contained in:
parent
7af744ebdf
commit
1d0f3783d5
1 changed files with 31 additions and 23 deletions
|
@ -234,6 +234,9 @@ static int __init parse_dt_topology(void)
|
||||||
unsigned long capacity = 0;
|
unsigned long capacity = 0;
|
||||||
int cpu = 0, ret = 0;
|
int cpu = 0, ret = 0;
|
||||||
|
|
||||||
|
__cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity),
|
||||||
|
GFP_NOWAIT);
|
||||||
|
|
||||||
cn = of_find_node_by_path("/cpus");
|
cn = of_find_node_by_path("/cpus");
|
||||||
if (!cn) {
|
if (!cn) {
|
||||||
pr_err("No CPU information found in DT\n");
|
pr_err("No CPU information found in DT\n");
|
||||||
|
@ -260,9 +263,6 @@ static int __init parse_dt_topology(void)
|
||||||
if (cpu_topology[cpu].cluster_id == -1)
|
if (cpu_topology[cpu].cluster_id == -1)
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
|
|
||||||
__cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity),
|
|
||||||
GFP_NOWAIT);
|
|
||||||
|
|
||||||
for_each_possible_cpu(cpu) {
|
for_each_possible_cpu(cpu) {
|
||||||
const u32 *rate;
|
const u32 *rate;
|
||||||
int len;
|
int len;
|
||||||
|
@ -456,6 +456,30 @@ static struct sched_domain_topology_level arm_topology[] = {
|
||||||
{ NULL, },
|
{ NULL, },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void __init reset_cpu_topology(void)
|
||||||
|
{
|
||||||
|
unsigned int cpu;
|
||||||
|
|
||||||
|
for_each_possible_cpu(cpu) {
|
||||||
|
struct cputopo_arm *cpu_topo = &cpu_topology[cpu];
|
||||||
|
|
||||||
|
cpu_topo->thread_id = -1;
|
||||||
|
cpu_topo->core_id = -1;
|
||||||
|
cpu_topo->cluster_id = -1;
|
||||||
|
|
||||||
|
cpumask_clear(&cpu_topo->core_sibling);
|
||||||
|
cpumask_clear(&cpu_topo->thread_sibling);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __init reset_cpu_capacity(void)
|
||||||
|
{
|
||||||
|
unsigned int cpu;
|
||||||
|
|
||||||
|
for_each_possible_cpu(cpu)
|
||||||
|
set_capacity_scale(cpu, SCHED_CAPACITY_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* init_cpu_topology is called at boot when only one cpu is running
|
* init_cpu_topology is called at boot when only one cpu is running
|
||||||
* which prevent simultaneous write access to cpu_topology array
|
* which prevent simultaneous write access to cpu_topology array
|
||||||
|
@ -465,29 +489,13 @@ void __init init_cpu_topology(void)
|
||||||
unsigned int cpu;
|
unsigned int cpu;
|
||||||
|
|
||||||
/* init core mask and capacity */
|
/* init core mask and capacity */
|
||||||
for_each_possible_cpu(cpu) {
|
reset_cpu_topology();
|
||||||
struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]);
|
reset_cpu_capacity();
|
||||||
|
|
||||||
cpu_topo->thread_id = -1;
|
|
||||||
cpu_topo->core_id = -1;
|
|
||||||
cpu_topo->cluster_id = -1;
|
|
||||||
cpumask_clear(&cpu_topo->core_sibling);
|
|
||||||
cpumask_clear(&cpu_topo->thread_sibling);
|
|
||||||
|
|
||||||
set_capacity_scale(cpu, SCHED_CAPACITY_SCALE);
|
|
||||||
}
|
|
||||||
smp_wmb();
|
smp_wmb();
|
||||||
|
|
||||||
if (parse_dt_topology()) {
|
if (parse_dt_topology()) {
|
||||||
struct cputopo_arm *cpu_topo = &(cpu_topology[cpu]);
|
reset_cpu_topology();
|
||||||
|
reset_cpu_capacity();
|
||||||
cpu_topo->thread_id = -1;
|
|
||||||
cpu_topo->core_id = -1;
|
|
||||||
cpu_topo->cluster_id = -1;
|
|
||||||
cpumask_clear(&cpu_topo->core_sibling);
|
|
||||||
cpumask_clear(&cpu_topo->thread_sibling);
|
|
||||||
|
|
||||||
set_capacity_scale(cpu, SCHED_CAPACITY_SCALE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_possible_cpu(cpu)
|
for_each_possible_cpu(cpu)
|
||||||
|
|
Loading…
Add table
Reference in a new issue