All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
@ 2020-06-19  9:08 ` Finley Xiao
  0 siblings, 0 replies; 6+ messages in thread
From: Finley Xiao @ 2020-06-19  9:08 UTC (permalink / raw)
  To: heiko, amit.kachhap, daniel.lezcano, viresh.kumar, javi.merino,
	rui.zhang, amit.kucheria
  Cc: linux-rockchip, linux-kernel, linux-pm, stable, huangtao,
	tony.xie, cl, Finley Xiao

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] 6+ messages in thread

* [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
@ 2020-06-19  9:08 ` Finley Xiao
  0 siblings, 0 replies; 6+ messages in thread
From: Finley Xiao @ 2020-06-19  9:08 UTC (permalink / raw)
  To: heiko-4mtYJXux2i+zQB+pC5nmwQ,
	amit.kachhap-Re5JQEeQqe8AvxtiuMwx3w,
	daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A,
	viresh.kumar-QSEj5FYQhm4dnm+yROfE0A,
	javi.merino-DgEjT+Ai2ygdnm+yROfE0A,
	rui.zhang-ral2JQCrhuEAvxtiuMwx3w,
	amit.kucheria-LY4KaoCqKrnby3iVrkZq2A
  Cc: huangtao-TNX95d0MmH7DzftRWevZcw, linux-pm-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	stable-u79uwXL29TY76Z2rM5mHXA,
	linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	tony.xie-TNX95d0MmH7DzftRWevZcw, Finley Xiao,
	cl-TNX95d0MmH7DzftRWevZcw

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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # v4.13+
Signed-off-by: Finley Xiao <finley.xiao-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Acked-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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] 6+ messages in thread

* Re: [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
  2020-06-19  9:08 ` Finley Xiao
  (?)
@ 2020-06-23  7:00 ` Amit Kucheria
  -1 siblings, 0 replies; 6+ messages in thread
From: Amit Kucheria @ 2020-06-23  7:00 UTC (permalink / raw)
  To: Finley Xiao
  Cc: Heiko Stuebner, Amit Daniel Kachhap, Daniel Lezcano,
	Viresh Kumar, Javi Merino, Zhang Rui, linux-rockchip, LKML,
	Linux PM list, stable, huangtao, tony.xie, cl

Hi Finley,

Please use versioning (v2) when resending a patch.

On Fri, Jun 19, 2020 at 2:39 PM Finley Xiao <finley.xiao@rock-chips.com> wrote:
>
> 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>

Reviewed-by: Amit Kucheria <amit.kucheria@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	[flat|nested] 6+ messages in thread

* Re: [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
  2020-06-19  1:51 Finley Xiao
  2020-06-19  5:57 ` Viresh Kumar
@ 2020-06-22  9:15 ` Amit Kucheria
  1 sibling, 0 replies; 6+ messages in thread
From: Amit Kucheria @ 2020-06-22  9:15 UTC (permalink / raw)
  To: Finley Xiao
  Cc: xf, Heiko Stuebner, Amit Daniel Kachhap, Daniel Lezcano,
	Viresh Kumar, Javi Merino, Zhang Rui, linux-rockchip, LKML,
	Linux PM list, huangtao, tony.xie, cl

On Fri, Jun 19, 2020 at 7:21 AM Finley Xiao <finley.xiao@rock-chips.com> wrote:
>
> 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")
> Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>

Reviewed-by: Amit Kucheria <amit.kucheria@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	[flat|nested] 6+ messages in thread

* Re: [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
  2020-06-19  1:51 Finley Xiao
@ 2020-06-19  5:57 ` Viresh Kumar
  2020-06-22  9:15 ` Amit Kucheria
  1 sibling, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2020-06-19  5:57 UTC (permalink / raw)
  To: Finley Xiao
  Cc: xf, heiko, amit.kachhap, daniel.lezcano, javi.merino, rui.zhang,
	amit.kucheria, linux-rockchip, linux-kernel, linux-pm, huangtao,
	tony.xie, cl

On 19-06-20, 09:51, Finley Xiao wrote:
> 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.
> 

Cc: v4.13+ <stable@vger.kernel.org> # v4.13+

> Fixes: 349d39dc5739 ("thermal: cpu_cooling: merge frequency and power tables")
> Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
> ---
>  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;
>  }

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power
@ 2020-06-19  1:51 Finley Xiao
  2020-06-19  5:57 ` Viresh Kumar
  2020-06-22  9:15 ` Amit Kucheria
  0 siblings, 2 replies; 6+ messages in thread
From: Finley Xiao @ 2020-06-19  1:51 UTC (permalink / raw)
  To: xf, heiko, amit.kachhap, daniel.lezcano, viresh.kumar,
	javi.merino, rui.zhang, amit.kucheria
  Cc: linux-rockchip, linux-kernel, linux-pm, huangtao, tony.xie, cl,
	Finley Xiao

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")
Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
---
 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] 6+ messages in thread

end of thread, other threads:[~2020-06-23  7:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-19  9:08 [PATCH] thermal/drivers/cpufreq_cooling: Fix wrong frequency converted from power Finley Xiao
2020-06-19  9:08 ` Finley Xiao
2020-06-23  7:00 ` Amit Kucheria
  -- strict thread matches above, loose matches on Subject: below --
2020-06-19  1:51 Finley Xiao
2020-06-19  5:57 ` Viresh Kumar
2020-06-22  9:15 ` Amit Kucheria

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.