]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
powerpc/powernv/idle: Round up latency and residency values
authorVaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Wed, 23 Aug 2017 18:58:41 +0000 (00:28 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 12 Nov 2017 21:00:29 +0000 (08:00 +1100)
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.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
drivers/cpuidle/cpuidle-powernv.c

index 42896a67aeae38325cbda2acb7ca655c1b43915c..5f3922392059ee10373151c205d548084ac5a648 100644 (file)
@@ -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;