]> git.ipfire.org Git - people/arne_f/kernel.git/commitdiff
cpufreq / CPPC: Set platform specific transition_delay_us
authorPrashanth Prakash <pprakash@codeaurora.org>
Fri, 27 Apr 2018 17:35:27 +0000 (11:35 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 22 Jul 2018 12:28:42 +0000 (14:28 +0200)
commit d4f3388afd488ed15368fa7413b8bd6d1f98bb1d upstream.

Add support to specify platform specific transition_delay_us instead
of using the transition delay derived from PCC.

With commit 3d41386d556d (cpufreq: CPPC: Use transition_delay_us
depending transition_latency) we are setting transition_delay_us
directly and not applying the LATENCY_MULTIPLIER. Because of that,
on Qualcomm Centriq we can end up with a very high rate of frequency
change requests when using the schedutil governor (default
rate_limit_us=10 compared to an earlier value of 10000).

The PCC subspace describes the rate at which the platform can accept
commands on the CPPC's PCC channel. This includes read and write
command on the PCC channel that can be used for reasons other than
frequency transitions. Moreover the same PCC subspace can be used by
multiple freq domains and deriving transition_delay_us from it as we
do now can be sub-optimal.

Moreover if a platform does not use PCC for desired_perf register then
there is no way to compute the transition latency or the delay_us.

CPPC does not have a standard defined mechanism to get the transition
rate or the latency at the moment.

Given the above limitations, it is simpler to have a platform specific
transition_delay_us and rely on PCC derived value only if a platform
specific value is not available.

Signed-off-by: Prashanth Prakash <pprakash@codeaurora.org>
Cc: 4.14+ <stable@vger.kernel.org> # 4.14+
Fixes: 3d41386d556d (cpufreq: CPPC: Use transition_delay_us depending transition_latency)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/cpufreq/cppc_cpufreq.c

index 8b432d6e846d9677e03c21604b6e495f453a14fa..c9ce716247c1550b06ebcae6b35b11103f16edee 100644 (file)
@@ -126,6 +126,49 @@ static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy)
                                cpu->perf_caps.lowest_perf, cpu_num, ret);
 }
 
+/*
+ * The PCC subspace describes the rate at which platform can accept commands
+ * on the shared PCC channel (including READs which do not count towards freq
+ * trasition requests), so ideally we need to use the PCC values as a fallback
+ * if we don't have a platform specific transition_delay_us
+ */
+#ifdef CONFIG_ARM64
+#include <asm/cputype.h>
+
+static unsigned int cppc_cpufreq_get_transition_delay_us(int cpu)
+{
+       unsigned long implementor = read_cpuid_implementor();
+       unsigned long part_num = read_cpuid_part_number();
+       unsigned int delay_us = 0;
+
+       switch (implementor) {
+       case ARM_CPU_IMP_QCOM:
+               switch (part_num) {
+               case QCOM_CPU_PART_FALKOR_V1:
+               case QCOM_CPU_PART_FALKOR:
+                       delay_us = 10000;
+                       break;
+               default:
+                       delay_us = cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+                       break;
+               }
+               break;
+       default:
+               delay_us = cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+               break;
+       }
+
+       return delay_us;
+}
+
+#else
+
+static unsigned int cppc_cpufreq_get_transition_delay_us(int cpu)
+{
+       return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+}
+#endif
+
 static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 {
        struct cppc_cpudata *cpu;
@@ -163,8 +206,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
        policy->cpuinfo.max_freq = cppc_dmi_max_khz;
 
        policy->cpuinfo.transition_latency = cppc_get_transition_latency(cpu_num);
-       policy->transition_delay_us = cppc_get_transition_latency(cpu_num) /
-               NSEC_PER_USEC;
+       policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu_num);
        policy->shared_type = cpu->shared_type;
 
        if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {