cpuidle: pseries: Fix CEDE latency conversion from tb to us
authorGautham R. Shenoy <ego@linux.vnet.ibm.com>
Thu, 3 Sep 2020 09:27:27 +0000 (14:57 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 8 Sep 2020 07:14:42 +0000 (17:14 +1000)
commit1d3ee7df009a46440c58508b8819213c09503acd
tree1a1f92614efe90b297b759f162391f61c49cba98
parent437ef802e0adc9f162a95213a3488e8646e5fc03
cpuidle: pseries: Fix CEDE latency conversion from tb to us

Commit d947fb4c965c ("cpuidle: pseries: Fixup exit latency for
CEDE(0)") sets the exit latency of CEDE(0) based on the latency values
of the Extended CEDE states advertised by the platform. The values
advertised by the platform are in timebase ticks. However the cpuidle
framework requires the latency values in microseconds.

If the tb-ticks value advertised by the platform correspond to a value
smaller than 1us, during the conversion from tb-ticks to microseconds,
in the current code, the result becomes zero. This is incorrect as it
puts a CEDE state on par with the snooze state.

This patch fixes this by rounding up the result obtained while
converting the latency value from tb-ticks to microseconds. It also
prints a warning in case we discover an extended-cede state with
wakeup latency to be 0. In such a case, ensure that CEDE(0) has a
non-zero wakeup latency.

Fixes: d947fb4c965c ("cpuidle: pseries: Fixup exit latency for CEDE(0)")
Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1599125247-28488-1-git-send-email-ego@linux.vnet.ibm.com
drivers/cpuidle/cpuidle-pseries.c