Skip to contentSkip to conversation

cpufreq: scmi: Fix frequency invariance in slow path

PATCH Applied Quentin Perret 4 participants 9 messages Jan 9, 2019 – Jan 11, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: scmi: Fix frequency invariance in slow path

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +2 -2
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);
Signature · 1 line
2.20.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +0 -0
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;

drivers/cpufreq/scmi-cpufreq.c scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) · line 60

Quoted 10 lines
drivers/cpufreq/scmi-cpufreq.c +2 -2
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);
Signature · 1 line
viresh
#2 lore raw
Quoted 28 lines · CET Viresh Kumar
Quoted 27 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +1 -1
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
Quoted 7 lines

drivers/cpufreq/scmi-cpufreq.c scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) · line 60

Quoted 5 lines
drivers/cpufreq/scmi-cpufreq.c +1 -1
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);

This would be stable-candidate I guess?

#3 lore raw
Quoted 37 lines · Rafael J. Wysocki
Quoted 28 lines · CET Viresh Kumar
Quoted 27 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +1 -1
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
Quoted 7 lines

drivers/cpufreq/scmi-cpufreq.c scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) · line 60

Quoted 5 lines
drivers/cpufreq/scmi-cpufreq.c +1 -1
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);
Quoted 1 line

This would be stable-candidate I guess?

I think so yes. I was hoping the 'Fixes:' tag would be enough ? Or do I still need to CC stable too ?

Thanks,
Quentin

#4 lore raw
Quoted 38 lines · CET Quentin Perret
Quoted 37 lines · Rafael J. Wysocki
Quoted 35 lines · CET Viresh Kumar
Quoted 22 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +0 -0
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;

drivers/cpufreq/scmi-cpufreq.c scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) · line 60

Quoted 10 lines
drivers/cpufreq/scmi-cpufreq.c +2 -2
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);
Quoted 3 lines
Quoted 1 line

This would be stable-candidate I guess?

I think so yes. I was hoping the 'Fixes:' tag would be enough ?

It doesn't cause -stable to pick up commits automatically if that's what you're asking about.

Quoted 1 line

Or do I still need to CC stable too ?

No, you don't need to (and should not) CC -stable yourself.

You can, however, add a Cc: <stable..> tag to the patch which helps maintainers a bit.

#5 lore raw
Quoted 46 lines · Rafael J. Wysocki
Quoted 38 lines · CET Quentin Perret
Quoted 37 lines · Rafael J. Wysocki
Quoted 35 lines · CET Viresh Kumar
Quoted 22 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +0 -0
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;

drivers/cpufreq/scmi-cpufreq.c scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) · line 60

Quoted 10 lines
drivers/cpufreq/scmi-cpufreq.c +2 -2
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);
Quoted 3 lines
Quoted 1 line

This would be stable-candidate I guess?

I think so yes. I was hoping the 'Fixes:' tag would be enough ?

It doesn't cause -stable to pick up commits automatically if that's what you're asking about.

Quoted 6 lines
Quoted 1 line

Or do I still need to CC stable too ?

No, you don't need to (and should not) CC -stable yourself.

You can, however, add a Cc: <stable..> tag to the patch which helps maintainers a bit.

OK, will do from now on.

Thanks !
Quentin

maintainer
#6 lore raw
In reply to Rafael J. Wysocki
Quoted 37 lines · Rafael J. Wysocki
Quoted 28 lines · CET Viresh Kumar
Quoted 27 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

---
 drivers/cpufreq/scmi-cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +1 -1
index 50b1551ba894..3f0693439486 100644
@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index)
 	int ret;
 	struct scmi_data *priv = policy->driver_data;
 	struct scmi_perf_ops *perf_ops = handle->perf_ops;
-	u64 freq = policy->freq_table[index].frequency * 1000;
+	u64 freq = policy->freq_table[index].frequency;
 
Quoted 7 lines

drivers/cpufreq/scmi-cpufreq.c scmi_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) · line 60

Quoted 5 lines
drivers/cpufreq/scmi-cpufreq.c +1 -1
-	ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
+	ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
 	if (!ret)
 		arch_set_freq_scale(policy->related_cpus, freq,
 				    policy->cpuinfo.max_freq);
Quoted 1 line

This would be stable-candidate I guess?

Cc 4.17+ <[email protected]> # v4.17+
Signature · 1 line
viresh
Acked-by on v1 1/1
#7 lore raw
In reply to Quentin Perret
Quoted 11 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

Good find.

--
Regards,
Sudeep

#8 lore raw
Quoted 10 lines · CET Sudeep Holla
Quoted 9 lines · Quentin Perret

The scmi-cpufreq driver calls the arch_set_freq_scale() callback on frequency changes to provide scale-invariant load-tracking signals to the scheduler. However, in the slow path, it does so while specifying the current and max frequencies in different units, hence resulting in a broken freq_scale factor.

Fix this by passing all frequencies in KHz, as stored in the CPUFreq frequency table.

Quoted 6 lines
Quoted 2 lines
Fixes 99d6bdf33877 ("cpufreq: add support for CPU DVFS based on SCMI

message protocol")

Good find.

Applied, thanks!