From: Gautham R. Shenoy <hidden> Date: 2017-12-07 05:59:45
From: "Gautham R. Shenoy" <redacted>
On POWERNV platform, Pstates are 8-bit values. On POWER8 they are
negatively numbered while on POWER9 they are positively
numbered. Thus, on POWER9, the maximum number of pstates could be as
high as 256.
The current code interprets pstates as a signed 8-bit value. This
causes a problem on POWER9 platforms which have more than 128 pstates.
On such systems, on a CPU that is in a lower pstate whose number is
greater than 128, querying the current pstate returns a "pstate X is
out of bound" error message and the current pstate is reported as the
nominal pstate.
This patch fixes the aforementioned issue by correctly differentiating
the sign whenever a pstate value read, depending on whether the
pstates are positively numbered or negatively numbered.
Fixes: commit 09ca4c9b5958 ("cpufreq: powernv: Replacing pstate_id with frequency table index")
Cc: <redacted> #v4.8
Signed-off-by: Gautham R. Shenoy <redacted>
Tested-and-reviewed-by: Shilpasri G Bhat [off-list ref]
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/powernv-cpufreq.c | 43 ++++++++++++++++++++++++++++++---------
1 file changed, 33 insertions(+), 10 deletions(-)
@@ -64,6 +67,12 @@/* Interval after which the timer is queued to bring down global pstate */#define GPSTATE_TIMER_INTERVAL 2000+/*+*OnPOWER8thepstatesarenegativelynumbered.OnPOWER9,theyare+*positivelynumbered.Usethisflagtotrackwhetherwehave+*positiveornegativenumberedpstates.+*/+staticboolpos_pstates;/***structglobal_pstate_info-Perpolicydatastructuretomaintainhistoryof
@@ -164,7 +173,7 @@ static inline unsigned int pstate_to_idx(int pstate)intmin=powernv_freqs[powernv_pstate_info.min].driver_data;intmax=powernv_freqs[powernv_pstate_info.max].driver_data;-if(min>0){+if(pos_pstates){if(unlikely((pstate<max)||(pstate>min))){pr_warn_once("pstate %d is out of bound\n",pstate);returnpowernv_pstate_info.nominal;
@@ -301,6 +310,9 @@ static int init_powernv_pstates(void)}}+if((int)pstate_min>0)+pos_pstates=true;+/* End of list marker entry */powernv_freqs[i].frequency=CPUFREQ_TABLE_END;return0;
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2017-12-07 21:25:18
On Thu, Dec 7, 2017 at 6:59 AM, Gautham R. Shenoy
[off-list ref] wrote:
From: "Gautham R. Shenoy" <redacted>
On POWERNV platform, Pstates are 8-bit values. On POWER8 they are
negatively numbered while on POWER9 they are positively
numbered. Thus, on POWER9, the maximum number of pstates could be as
high as 256.
The current code interprets pstates as a signed 8-bit value. This
causes a problem on POWER9 platforms which have more than 128 pstates.
On such systems, on a CPU that is in a lower pstate whose number is
greater than 128, querying the current pstate returns a "pstate X is
out of bound" error message and the current pstate is reported as the
nominal pstate.
This patch fixes the aforementioned issue by correctly differentiating
the sign whenever a pstate value read, depending on whether the
pstates are positively numbered or negatively numbered.
Fixes: commit 09ca4c9b5958 ("cpufreq: powernv: Replacing pstate_id with frequency table index")
Cc: <redacted> #v4.8
Signed-off-by: Gautham R. Shenoy <redacted>
Tested-and-reviewed-by: Shilpasri G Bhat [off-list ref]
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
I'm going to apply this, or please let me know if you want to route it
differently.
@@ -64,6 +67,12 @@/* Interval after which the timer is queued to bring down global pstate */#define GPSTATE_TIMER_INTERVAL 2000+/*+*OnPOWER8thepstatesarenegativelynumbered.OnPOWER9,theyare+*positivelynumbered.Usethisflagtotrackwhetherwehave+*positiveornegativenumberedpstates.+*/+staticboolpos_pstates;/***structglobal_pstate_info-Perpolicydatastructuretomaintainhistoryof
@@ -164,7 +173,7 @@ static inline unsigned int pstate_to_idx(int pstate)intmin=powernv_freqs[powernv_pstate_info.min].driver_data;intmax=powernv_freqs[powernv_pstate_info.max].driver_data;-if(min>0){+if(pos_pstates){if(unlikely((pstate<max)||(pstate>min))){pr_warn_once("pstate %d is out of bound\n",pstate);returnpowernv_pstate_info.nominal;
@@ -301,6 +310,9 @@ static int init_powernv_pstates(void)}}+if((int)pstate_min>0)+pos_pstates=true;+/* End of list marker entry */powernv_freqs[i].frequency=CPUFREQ_TABLE_END;return0;
On Thu, Dec 7, 2017 at 4:59 PM, Gautham R. Shenoy
[off-list ref] wrote:
From: "Gautham R. Shenoy" <redacted>
On POWERNV platform, Pstates are 8-bit values. On POWER8 they are
negatively numbered while on POWER9 they are positively
numbered. Thus, on POWER9, the maximum number of pstates could be as
high as 256.
The current code interprets pstates as a signed 8-bit value. This
causes a problem on POWER9 platforms which have more than 128 pstates.
On such systems, on a CPU that is in a lower pstate whose number is
greater than 128, querying the current pstate returns a "pstate X is
out of bound" error message and the current pstate is reported as the
nominal pstate.
This patch fixes the aforementioned issue by correctly differentiating
the sign whenever a pstate value read, depending on whether the
pstates are positively numbered or negatively numbered.
Can you hide all of this in pstate_to_idx(), do the casting inside? I
was reviewing this
code earlier before being distracted with something else, this did
come across as
strange and I was looking at using abs values to simplify the code,
but I did not get
to it.
Balbir Singh.
From: Michael Ellerman <mpe@ellerman.id.au> Date: 2017-12-08 11:47:42
"Rafael J. Wysocki" [off-list ref] writes:
On Thu, Dec 7, 2017 at 6:59 AM, Gautham R. Shenoy
[off-list ref] wrote:
quoted
From: "Gautham R. Shenoy" <redacted>
On POWERNV platform, Pstates are 8-bit values. On POWER8 they are
negatively numbered while on POWER9 they are positively
numbered. Thus, on POWER9, the maximum number of pstates could be as
high as 256.
The current code interprets pstates as a signed 8-bit value. This
causes a problem on POWER9 platforms which have more than 128 pstates.
On such systems, on a CPU that is in a lower pstate whose number is
greater than 128, querying the current pstate returns a "pstate X is
out of bound" error message and the current pstate is reported as the
nominal pstate.
This patch fixes the aforementioned issue by correctly differentiating
the sign whenever a pstate value read, depending on whether the
pstates are positively numbered or negatively numbered.
Fixes: commit 09ca4c9b5958 ("cpufreq: powernv: Replacing pstate_id with frequency table index")
Cc: <redacted> #v4.8
Signed-off-by: Gautham R. Shenoy <redacted>
Tested-and-reviewed-by: Shilpasri G Bhat [off-list ref]
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
I'm going to apply this, or please let me know if you want to route it
differently.
Do you mind waiting for now, we're still debating how to fix it.
cheers
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2017-12-08 14:08:32
On Fri, Dec 8, 2017 at 12:47 PM, Michael Ellerman [off-list ref] wrote:
"Rafael J. Wysocki" [off-list ref] writes:
quoted
On Thu, Dec 7, 2017 at 6:59 AM, Gautham R. Shenoy
[off-list ref] wrote:
quoted
From: "Gautham R. Shenoy" <redacted>
On POWERNV platform, Pstates are 8-bit values. On POWER8 they are
negatively numbered while on POWER9 they are positively
numbered. Thus, on POWER9, the maximum number of pstates could be as
high as 256.
The current code interprets pstates as a signed 8-bit value. This
causes a problem on POWER9 platforms which have more than 128 pstates.
On such systems, on a CPU that is in a lower pstate whose number is
greater than 128, querying the current pstate returns a "pstate X is
out of bound" error message and the current pstate is reported as the
nominal pstate.
This patch fixes the aforementioned issue by correctly differentiating
the sign whenever a pstate value read, depending on whether the
pstates are positively numbered or negatively numbered.
Fixes: commit 09ca4c9b5958 ("cpufreq: powernv: Replacing pstate_id with frequency table index")
Cc: <redacted> #v4.8
Signed-off-by: Gautham R. Shenoy <redacted>
Tested-and-reviewed-by: Shilpasri G Bhat [off-list ref]
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
I'm going to apply this, or please let me know if you want to route it
differently.
Do you mind waiting for now, we're still debating how to fix it.
No problem. :-)
Just please let me know when you're ready.
From: Gautham R Shenoy <hidden> Date: 2017-12-11 05:24:59
Hi Balbir,
On Fri, Dec 08, 2017 at 02:44:40PM +1100, Balbir Singh wrote:
On Thu, Dec 7, 2017 at 4:59 PM, Gautham R. Shenoy
[off-list ref] wrote:
quoted
From: "Gautham R. Shenoy" <redacted>
On POWERNV platform, Pstates are 8-bit values. On POWER8 they are
negatively numbered while on POWER9 they are positively
numbered. Thus, on POWER9, the maximum number of pstates could be as
high as 256.
The current code interprets pstates as a signed 8-bit value. This
causes a problem on POWER9 platforms which have more than 128 pstates.
On such systems, on a CPU that is in a lower pstate whose number is
greater than 128, querying the current pstate returns a "pstate X is
out of bound" error message and the current pstate is reported as the
nominal pstate.
This patch fixes the aforementioned issue by correctly differentiating
the sign whenever a pstate value read, depending on whether the
pstates are positively numbered or negatively numbered.
Yikes! Is there no better way of fixing this?
There is. In fact, I am working on cleaning up the whole thing to make
it not depend on the sign until it is really needed (and that is to
check whether the pstate that we read from the PMSR is within bounds)
Besides, currently the kernel code assumes a few things that the
device-tree doesn't guarantee, such as the continguity of pstates.
Can you hide all of this in pstate_to_idx(), do the casting inside? I
was reviewing this
code earlier before being distracted with something else, this did
come across as
strange and I was looking at using abs values to simplify the code,
but I did not get
to it.
Balbir Singh.