Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a4b355a authored by Manaf Meethalavalappu Pallikunhi's avatar Manaf Meethalavalappu Pallikunhi
Browse files

drivers: thermal: Use first online cpu from the policy for cpufreq update



Each cpufreq cooling device is using its cpu id to update cpu
frequency vote with cpufreq driver. There is a possible chance that
cpufreq policy update callback will not be called if that particular
cpu is offline. In that case, if cooling device clears mitigation,
cpufreq policy update doesn't re-evaluate thermal client vote and
it stays in mitigation state until next cpufreq policy update.

Instead of using its cpu id, use first online cpu from the related
cpus from the policy whenever cpufreq cooling device needs to update
its vote. This ensures that cpufreq policy update/re-evaluation is
done immediately when cpufreq cooling device update its vote.

Change-Id: I1450d2a8b6ce00a69b71ba4e4eb2b0d452ef8315
Signed-off-by: default avatarManaf Meethalavalappu Pallikunhi <manafm@codeaurora.org>
parent 3364ad12
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -105,6 +105,7 @@ struct cpufreq_cooling_device {
	unsigned int max_level;
	unsigned int *freq_table;	/* In descending order */
	struct cpumask allowed_cpus;
	struct cpufreq_policy *policy;
	struct list_head node;
	u32 last_load;
	u64 *time_in_idle;
@@ -647,6 +648,7 @@ static int cpufreq_set_min_state(struct thermal_cooling_device *cdev,
{
	struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
	unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus);
	struct cpumask policy_online_cpus;
	unsigned int floor_freq;

	if (state > cpufreq_device->max_level)
@@ -676,7 +678,10 @@ static int cpufreq_set_min_state(struct thermal_cooling_device *cdev,
	} else {
		floor_freq = cpufreq_device->freq_table[state];
		cpufreq_device->floor_freq = floor_freq;
		cpufreq_update_policy(cpu);
		if (cpumask_and(&policy_online_cpus, cpu_online_mask,
				cpufreq_device->policy->related_cpus))
			cpufreq_update_policy(cpumask_first(
						&policy_online_cpus));
	}

	return 0;
@@ -717,6 +722,7 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
{
	struct cpufreq_cooling_device *cpufreq_device = cdev->devdata;
	unsigned int cpu = cpumask_any(&cpufreq_device->allowed_cpus);
	struct cpumask policy_online_cpus;
	unsigned int clip_freq;
	unsigned long prev_state;
	struct device *cpu_dev;
@@ -770,7 +776,10 @@ static int cpufreq_set_cur_state(struct thermal_cooling_device *cdev,
			cpufreq_device->plat_ops->ceil_limit(cpu,
						clip_freq);
	} else {
		cpufreq_update_policy(cpu);
		if (cpumask_and(&policy_online_cpus, cpu_online_mask,
				cpufreq_device->policy->related_cpus))
			cpufreq_update_policy(cpumask_first(
						&policy_online_cpus));
	}

	return 0;
@@ -1073,6 +1082,7 @@ __cpufreq_cooling_register(struct device_node *np,
		goto put_policy;
	}

	cpufreq_dev->policy = policy;
	num_cpus = cpumask_weight(clip_cpus);
	cpufreq_dev->time_in_idle = kcalloc(num_cpus,
					    sizeof(*cpufreq_dev->time_in_idle),