stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
       [not found] <20190903115947.26618-1-finley.xiao@rock-chips.com>
@ 2020-06-23 11:42 ` Finley Xiao
  2020-06-25 14:53   ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Finley Xiao @ 2020-06-23 11:42 UTC (permalink / raw)
  To: xf; +Cc: Finley Xiao, # v4 . 13+

The function cpu_power_to_freq is used to find a frequency and set the
cooling device to consume at most the power to be converted. For example,
if the power to be converted is 80mW, and the em table is as follow.
struct em_cap_state table[] = {
	/* KHz     mW */
	{ 1008000, 36, 0 },
	{ 1200000, 49, 0 },
	{ 1296000, 59, 0 },
	{ 1416000, 72, 0 },
	{ 1512000, 86, 0 },
};
The target frequency should be 1416000KHz, not 1512000KHz.

Fixes: 349d39dc5739 ("thermal: cpu_cooling: merge frequency and power tables")
Cc: <stable@vger.kernel.org> # v4.13+
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/thermal/cpufreq_cooling.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thermal/cpufreq_cooling.c b/drivers/thermal/cpufreq_cooling.c
index 9e124020519f..6c0e1b053126 100644
--- a/drivers/thermal/cpufreq_cooling.c
+++ b/drivers/thermal/cpufreq_cooling.c
@@ -123,12 +123,12 @@ static u32 cpu_power_to_freq(struct cpufreq_cooling_device *cpufreq_cdev,
 {
 	int i;
 
-	for (i = cpufreq_cdev->max_level - 1; i >= 0; i--) {
-		if (power > cpufreq_cdev->em->table[i].power)
+	for (i = cpufreq_cdev->max_level; i >= 0; i--) {
+		if (power >= cpufreq_cdev->em->table[i].power)
 			break;
 	}
 
-	return cpufreq_cdev->em->table[i + 1].frequency;
+	return cpufreq_cdev->em->table[i].frequency;
 }
 
 /**
-- 
2.11.0




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
  2020-06-23 11:42 ` [PATCH v1] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power Finley Xiao
@ 2020-06-25 14:53   ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2020-06-25 14:53 UTC (permalink / raw)
  To: Sasha Levin, Finley Xiao, xf; +Cc: Finley Xiao, stable

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 349d39dc5739 ("thermal: cpu_cooling: merge frequency and power tables").

The bot has tested the following trees: v5.7.5, v5.4.48, v4.19.129, v4.14.185.

v5.7.5: Build OK!
v5.4.48: Failed to apply! Possible dependencies:
    5a4e5b78956a5 ("thermal: cpu_cooling: Make the power-related code depend on IPA")
    a4e893e802e6a ("thermal: cpu_cooling: Migrate to using the EM framework")

v4.19.129: Failed to apply! Possible dependencies:
    18c49926c4bf4 ("cpufreq: Add QoS requests for userspace constraints")
    2acb9bdae92d0 ("cpufreq: Explain the kobject_put() in cpufreq_policy_alloc()")
    2d8b39a62a5d3 ("ACPI: processor: Avoid NULL pointer dereferences at init time")
    3000ce3c52f8b ("cpufreq: Use per-policy frequency QoS")
    348a2ec5f5a5a ("cpufreq: Reorder and simplify cpufreq_update_policy()")
    4ebe36c94aed9 ("cpufreq: Fix kobject memleak")
    540a375822a40 ("cpufreq: Add cpufreq_cpu_acquire() and cpufreq_cpu_release()")
    5a4e5b78956a5 ("thermal: cpu_cooling: Make the power-related code depend on IPA")
    5c238a8b599f1 ("cpufreq: Auto-register the driver as a thermal cooling device if asked")
    67d874c3b2c69 ("cpufreq: Register notifiers with the PM QoS framework")
    70a59fde6e69d ("cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update()")
    a0dbb819b84f8 ("cpufreq: Add kerneldoc comments for two core functions")
    a4e893e802e6a ("thermal: cpu_cooling: Migrate to using the EM framework")
    d15ce412737ac ("ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier")

v4.14.185: Failed to apply! Possible dependencies:
    18c49926c4bf4 ("cpufreq: Add QoS requests for userspace constraints")
    2acb9bdae92d0 ("cpufreq: Explain the kobject_put() in cpufreq_policy_alloc()")
    2d8b39a62a5d3 ("ACPI: processor: Avoid NULL pointer dereferences at init time")
    3000ce3c52f8b ("cpufreq: Use per-policy frequency QoS")
    348a2ec5f5a5a ("cpufreq: Reorder and simplify cpufreq_update_policy()")
    4ebe36c94aed9 ("cpufreq: Fix kobject memleak")
    540a375822a40 ("cpufreq: Add cpufreq_cpu_acquire() and cpufreq_cpu_release()")
    5a4e5b78956a5 ("thermal: cpu_cooling: Make the power-related code depend on IPA")
    5c238a8b599f1 ("cpufreq: Auto-register the driver as a thermal cooling device if asked")
    67d874c3b2c69 ("cpufreq: Register notifiers with the PM QoS framework")
    70a59fde6e69d ("cpufreq: Avoid calling cpufreq_verify_current_freq() from handle_update()")
    a0dbb819b84f8 ("cpufreq: Add kerneldoc comments for two core functions")
    a4e893e802e6a ("thermal: cpu_cooling: Migrate to using the EM framework")
    d15ce412737ac ("ACPI: cpufreq: Switch to QoS requests instead of cpufreq notifier")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

-- 
Thanks
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-25 14:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20190903115947.26618-1-finley.xiao@rock-chips.com>
2020-06-23 11:42 ` [PATCH v1] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power Finley Xiao
2020-06-25 14:53   ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).