Skip to contentSkip to conversation

cpufreq / CPPC: Set platform specific transition_delay_us

PATCH Superseded Prashanth Prakash 2 participants 5 messages Apr 25, 2018 – Apr 27, 2018

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 cpufreq / CPPC: Set platform specific transition_delay_us

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. With this on Qualcomm Centriq we can end up with a very high rate of frequency change requests when using 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.

Cc Viresh Kumar <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes 3d41386d556d ("cpufreq: CPPC: Use transition_delay_us depending

transition_latency)
---
v2:
* Return final delay_us from cppc_cpufreq_get_transition_delay_us (Viresh)

---
 drivers/cpufreq/cppc_cpufreq.c | 43 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +41 -2
index bc5fc16..b1e32ad 100644
@@ -126,6 +126,46 @@ 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
+ */
+#if defined(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;
+		}
+		break;
+	}
+
+	if (!delay_us)
+		delay_us = cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+
+	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;
@@ -162,8 +202,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 		cpu->perf_caps.highest_perf;
 	policy->cpuinfo.max_freq = cppc_dmi_max_khz;
 
-	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) {
Signature · 3 lines
Qualcomm Datacenter Technologies on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
maintainer
#1 lore raw
Quoted 45 lines · Prashanth Prakash

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. With this on Qualcomm Centriq we can end up with a very high rate of frequency change requests when using 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.

Cc Viresh Kumar <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes 3d41386d556d ("cpufreq: CPPC: Use transition_delay_us depending

transition_latency)
---
v2:
* Return final delay_us from cppc_cpufreq_get_transition_delay_us (Viresh)

---
 drivers/cpufreq/cppc_cpufreq.c | 43 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +0 -0
index bc5fc16..b1e32ad 100644

drivers/cpufreq/cppc_cpufreq.c static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) · line 135

Quoted 10 lines
drivers/cpufreq/cppc_cpufreq.c +7 -0
@@ -126,6 +126,46 @@ 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
+ */
+#if defined(CONFIG_ARM64)

You can use #ifdef here instead.

Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c +7 -0
+#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;

drivers/cpufreq/cppc_cpufreq.c static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) · line 152

Quoted 10 lines
drivers/cpufreq/cppc_cpufreq.c +10 -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;
+		}
+		break;

What about adding a default: case here and moving the below code into that ?

Quoted 33 lines
drivers/cpufreq/cppc_cpufreq.c +17 -2
+	}
+
+	if (!delay_us)
+		delay_us = cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+
+	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;
@@ -162,8 +202,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 		cpu->perf_caps.highest_perf;
 	policy->cpuinfo.max_freq = cppc_dmi_max_khz;
 
-	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) {
Signature · 3 lines
Qualcomm Datacenter Technologies on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
Signature · 1 line
viresh
#2 lore raw
Quoted 49 lines · Viresh Kumar
Quoted 48 lines · Prashanth Prakash

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. With this on Qualcomm Centriq we can end up with a very high rate of frequency change requests when using 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.

Cc Viresh Kumar <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes 3d41386d556d ("cpufreq: CPPC: Use transition_delay_us depending

transition_latency)
---
v2:
* Return final delay_us from cppc_cpufreq_get_transition_delay_us (Viresh)

---
 drivers/cpufreq/cppc_cpufreq.c | 43 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +0 -0
index bc5fc16..b1e32ad 100644
@@ -126,6 +126,46 @@ static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy)
 				cpu->perf_caps.lowest_perf, cpu_num, ret);
 }
 
Quoted 8 lines

drivers/cpufreq/cppc_cpufreq.c static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) · line 135

Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c +7 -0
+/*
+ * 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
+ */
+#if defined(CONFIG_ARM64)

You can use #ifdef here instead.

I will update.

Quoted 11 lines
Quoted 11 lines
drivers/cpufreq/cppc_cpufreq.c +10 -0
+#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:
Quoted 8 lines

drivers/cpufreq/cppc_cpufreq.c static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) · line 152

Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c +7 -0
+		switch (part_num) {
+		case QCOM_CPU_PART_FALKOR_V1:
+		case QCOM_CPU_PART_FALKOR:
+			delay_us = 10000;
+			break;
+		}
+		break;

What about adding a default: case here and moving the below code into that ?

Agree, it will much cleaner.. I will update.

Quoted 34 lines
Quoted 34 lines
drivers/cpufreq/cppc_cpufreq.c +17 -2
+	}
+
+	if (!delay_us)
+		delay_us = cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+
+	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;
@@ -162,8 +202,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 		cpu->perf_caps.highest_perf;
 	policy->cpuinfo.max_freq = cppc_dmi_max_khz;
 
-	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) {
Signature · 3 lines
Qualcomm Datacenter Technologies on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw

Hi Viresh,

Quoted 78 lines · Prashanth
Quoted 49 lines · Viresh Kumar
Quoted 48 lines · Prashanth Prakash

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. With this on Qualcomm Centriq we can end up with a very high rate of frequency change requests when using 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.

Cc Viresh Kumar <[email protected]>
Cc Rafael J. Wysocki <[email protected]>
Fixes 3d41386d556d ("cpufreq: CPPC: Use transition_delay_us depending

transition_latency)
---
v2:
* Return final delay_us from cppc_cpufreq_get_transition_delay_us (Viresh)

---
 drivers/cpufreq/cppc_cpufreq.c | 43 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +0 -0
index bc5fc16..b1e32ad 100644
@@ -126,6 +126,46 @@ static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy)
 				cpu->perf_caps.lowest_perf, cpu_num, ret);
 }
 
Quoted 8 lines

drivers/cpufreq/cppc_cpufreq.c static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) · line 135

Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c +7 -0
+/*
+ * 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
+ */
+#if defined(CONFIG_ARM64)

You can use #ifdef here instead.

I will update.

Quoted 10 lines
Quoted 10 lines
drivers/cpufreq/cppc_cpufreq.c +10 -0
+#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:
Quoted 8 lines

drivers/cpufreq/cppc_cpufreq.c static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy) · line 152

Quoted 7 lines
drivers/cpufreq/cppc_cpufreq.c +7 -0
+		switch (part_num) {
+		case QCOM_CPU_PART_FALKOR_V1:
+		case QCOM_CPU_PART_FALKOR:
+			delay_us = 10000;
+			break;
+		}
+		break;

What about adding a default: case here and moving the below code into that ?

Quoted 1 line

Agree, it will much cleaner.. I will update.

On second thoughts, If we have a scenario where we have a platform on which the "implementor" matches a case statement, but the "part_num" does not have a corresponding case statement. In this case we would need multiple levels of default, so I think the current implementation is simpler.

Thoughts?

Quoted 36 lines
Quoted 28 lines
Quoted 28 lines
drivers/cpufreq/cppc_cpufreq.c +17 -2
+	}
+
+	if (!delay_us)
+		delay_us = cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+
+	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;
@@ -162,8 +202,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 		cpu->perf_caps.highest_perf;
 	policy->cpuinfo.max_freq = cppc_dmi_max_khz;
 
-	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;
 
Quoted 5 lines
Quoted 5 lines
drivers/cpufreq/cppc_cpufreq.c +0 -0
 	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
Signature · 3 lines
Qualcomm Datacenter Technologies on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

--
Thanks,
Prashanth

maintainer
#4 lore raw
Quoted 4 lines · Prashanth

On second thoughts, If we have a scenario where we have a platform on which the "implementor" matches a case statement, but the "part_num" does not have a corresponding case statement. In this case we would need multiple levels of default, so I think the current implementation is simpler.

You already have multiple level of switches, multiple level of defaults shouldn't make it any worse :)

Signature · 1 line
viresh