Unverified Commit 05180441 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11108 cpufreq: CPPC: Eliminate the impact of cpc_read() latency error

parents 0ab269ed 8cd528ff
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -851,12 +851,25 @@ static int cppc_get_perf_ctrs_pair(void *val)
	struct fb_ctr_pair *fb_ctrs = val;
	int cpu = fb_ctrs->cpu;
	int ret;
	unsigned long timeout;

	ret = cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t0);
	if (ret)
		return ret;

	if (likely(!in_atomic() && !irqs_disabled())) {
		/*
		 * Set 1ms as sampling interval, but never schedule
		 * to the idle task to prevent the AMU counters from
		 * stopping working.
		 */
		timeout = jiffies + msecs_to_jiffies(1);
		while (!time_after(jiffies, timeout))
			cond_resched();
	} else {
		pr_warn_once("CPU%d: Get rate in atomic context", cpu);
		udelay(2); /* 2usec delay between sampling */
	}

	return cppc_get_perf_ctrs(cpu, &fb_ctrs->fb_ctrs_t1);
}