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

Commit 4b15241f authored by Taniya Das's avatar Taniya Das Committed by Gerrit - the friendly Code Review server
Browse files

cpufreq: qcom: Update the scheduler of throttle removal



There can be a case where the frequency at the time of throttle removal
was not the max frequency. Thus the scheduler update sent would not be
the max frequency, which would result in wrong capacity calculation,
even though the CPU frequency is bumped to max frequency later.

Thus update the scheduler with the cpuinfo max frequency before enabling
the throttle IRQ.

Change-Id: I3fe95e326a81fba9af1e0ea86d5281d291a2c9b6
Signed-off-by: default avatarTaniya Das <tdas@codeaurora.org>
parent a6ae9f82
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -108,13 +108,25 @@ static ssize_t dcvsh_freq_limit_show(struct device *dev,
	return scnprintf(buf, PAGE_SIZE, "%lu\n", c->dcvsh_freq_limit);
}

static unsigned long limits_mitigation_notify(struct cpufreq_qcom *c)
static unsigned long limits_mitigation_notify(struct cpufreq_qcom *c,
					bool limit)
{
	struct cpufreq_policy *policy;
	u32 cpu;
	unsigned long freq;

	if (limit) {
		freq = readl_relaxed(c->base + offsets[REG_DOMAIN_STATE]) &
				GENMASK(7, 0);
		freq = DIV_ROUND_CLOSEST_ULL(freq * xo_rate, 1000);
	} else {
		cpu = cpumask_first(&c->related_cpus);
		policy = cpufreq_cpu_get_raw(cpu);
		if (!policy)
			freq = U32_MAX;
		else
			freq = policy->cpuinfo.max_freq;
	}

	sched_update_cpu_freq_min_max(&c->related_cpus, 0, freq);
	trace_dcvsh_freq(cpumask_first(&c->related_cpus), freq);
@@ -134,7 +146,7 @@ static void limits_dcvsh_poll(struct work_struct *work)

	cpu = cpumask_first(&c->related_cpus);

	freq_limit = limits_mitigation_notify(c);
	freq_limit = limits_mitigation_notify(c, true);

	dcvsh_freq = qcom_cpufreq_hw_get(cpu);

@@ -142,6 +154,9 @@ static void limits_dcvsh_poll(struct work_struct *work)
		mod_delayed_work(system_highpri_wq, &c->freq_poll_work,
				msecs_to_jiffies(LIMITS_POLLING_DELAY_MS));
	} else {
		/* Update scheduler for throttle removal */
		limits_mitigation_notify(c, false);

		regval = readl_relaxed(c->base + offsets[REG_INTR_CLR]);
		regval |= GT_IRQ_STATUS;
		writel_relaxed(regval, c->base + offsets[REG_INTR_CLR]);
@@ -167,7 +182,7 @@ static irqreturn_t dcvsh_handle_isr(int irq, void *data)
	if (c->is_irq_enabled) {
		c->is_irq_enabled = false;
		disable_irq_nosync(c->dcvsh_irq);
		limits_mitigation_notify(c);
		limits_mitigation_notify(c, true);
		mod_delayed_work(system_highpri_wq, &c->freq_poll_work,
				msecs_to_jiffies(LIMITS_POLLING_DELAY_MS));