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

Commit 76c926de authored by Taniya Das's avatar Taniya Das
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 bc904ccd
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -104,13 +104,25 @@ static ssize_t dcvsh_freq_limit_show(struct device *dev,
	return snprintf(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->reg_bases[REG_DOMAIN_STATE]) &
				GENMASK(7, 0);
		freq = DIV_ROUND_CLOSEST_ULL(freq * c->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);
@@ -130,7 +142,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);

@@ -138,6 +150,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->reg_bases[REG_INTR_CLR]);
		regval |= GT_IRQ_STATUS;
		writel_relaxed(regval, c->reg_bases[REG_INTR_CLR]);
@@ -163,7 +178,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));