powerpc/powernv/idle: Round up latency and residency values
Subsystems (2)
PATCH 1/1 powerpc/powernv/idle: Round up latency and residency values
On PowerNV platforms, firmware provides exit latency and target residency for each of the idle states in nano seconds. Cpuidle framework expects the values in micro seconds. Round up to nearest micro seconds to avoid errors in cases where the values are defined as fractional micro seconds.
Default idle state of 'snooze' has exit latency of zero. If other states have fractional micro second exit latency, they would get rounded down to zero micro second and make cpuidle framework choose deeper idle state when snooze loop is the right choice.
--- drivers/cpuidle/cpuidle-powernv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpuidle/cpuidle-powernv.c +2 -2
@@ -383,9 +383,9 @@ static int powernv_add_idle_states(void)* Firmware passes residency and latency values in ns. * cpuidle expects it in us. */ - exit_latency = latency_ns[i] /1000 ; + exit_latency =DIV_ROUND_UP (latency_ns[i],1000 );if (!rc) - target_residency = residency_ns[i] /1000 ; + target_residency =DIV_ROUND_UP (residency_ns[i],1000 );else target_residency =0 ;
Signature · 1 line
2.13.5
Hi Vaidy,
On Thu, Aug 24, 2017 at 12:28:41AM +0530, Vaidyanathan Srinivasan wrote:
Cc'ing Rafael and linux-pm list.
Quoted 7 lines
On PowerNV platforms, firmware provides exit latency and target residency for each of the idle states in nano seconds. Cpuidle framework expects the values in micro seconds. Round up to nearest micro seconds to avoid errors in cases where the values are defined as fractional micro seconds.
Quoted 8 lines
Default idle state of 'snooze' has exit latency of zero. If other states have fractional micro second exit latency, they would get rounded down to zero micro second and make cpuidle framework choose deeper idle state when snooze loop is the right choice.
Reported-by Anton Blanchard <[email protected]>Signed-off-by Vaidyanathan Srinivasan <[email protected]>
This looks good to me.
Quoted 23 lines
--- drivers/cpuidle/cpuidle-powernv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/cpuidle/cpuidle-powernv.c +2
-2@@ -383,9 +383,9 @@ static int powernv_add_idle_states(void)* Firmware passes residency and latency values in ns. * cpuidle expects it in us. */ - exit_latency = latency_ns[i] /1000 ; + exit_latency =DIV_ROUND_UP (latency_ns[i],1000 );if (!rc) - target_residency = residency_ns[i] /1000 ; + target_residency =DIV_ROUND_UP (residency_ns[i],1000 );else target_residency =0 ;Signature · 1 line
2.13.5
Michael Ellerman
reviewerQuoted 7 lines · Vaidyanathan Srinivasan
On PowerNV platforms, firmware provides exit latency and target residency for each of the idle states in nano seconds. Cpuidle framework expects the values in micro seconds. Round up to nearest micro seconds to avoid errors in cases where the values are defined as fractional micro seconds.
Quoted 8 lines
Default idle state of 'snooze' has exit latency of zero. If other states have fractional micro second exit latency, they would get rounded down to zero micro second and make cpuidle framework choose deeper idle state when snooze loop is the right choice.
Reported-by Anton Blanchard <[email protected]>Signed-off-by Vaidyanathan Srinivasan <[email protected]>
This sounds like a fairly bad bug, does it need a Fixes / Cc stable tag?
cheers
Quoted 15 lines · Michael Ellerman
Quoted 13 lines · Vaidyanathan Srinivasan
On PowerNV platforms, firmware provides exit latency and target residency for each of the idle states in nano seconds. Cpuidle framework expects the values in micro seconds. Round up to nearest micro seconds to avoid errors in cases where the values are defined as fractional micro seconds.
Default idle state of 'snooze' has exit latency of zero. If other states have fractional micro second exit latency, they would get rounded down to zero micro second and make cpuidle framework choose deeper idle state when snooze loop is the right choice.
Quoted 4 lines
Quoted 2 lines
Reported-by Anton Blanchard <[email protected]>Signed-off-by Vaidyanathan Srinivasan <[email protected]>This sounds like a fairly bad bug, does it need a Fixes / Cc stable tag?
Yes, we will need this on stable kernel that runs on POWER9. On older platforms the latencies are larger and hence no impact :)
I will post to stable after this fix hits your -next tree.
--Vaidy
Michael Ellerman
AppliedQuoted 13 lines · Vaidyanathan Srinivasan
On PowerNV platforms, firmware provides exit latency and target residency for each of the idle states in nano seconds. Cpuidle framework expects the values in micro seconds. Round up to nearest micro seconds to avoid errors in cases where the values are defined as fractional micro seconds.
Default idle state of 'snooze' has exit latency of zero. If other states have fractional micro second exit latency, they would get rounded down to zero micro second and make cpuidle framework choose deeper idle state when snooze loop is the right choice.
Quoted 3 lines
Reported-by Anton Blanchard <[email protected]>Signed-off-by Vaidyanathan Srinivasan <[email protected]>Reviewed-by Gautham R. Shenoy <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/8d4e10e9ed9450e18fbbf6a8872be0
cheers