[PATCH] powerpc/powernv/idle: Round up latency and residency values

Gautham R Shenoy ego at linux.vnet.ibm.com
Thu Aug 24 14:35:24 AEST 2017


Hi Vaidy,
On Thu, Aug 24, 2017 at 12:28:41AM +0530, Vaidyanathan Srinivasan
wrote:

Cc'ing Rafael and linux-pm list.

> 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 at samba.org>
> Signed-off-by: Vaidyanathan Srinivasan <svaidy at linux.vnet.ibm.com>

This looks good to me.

Reviewed-by: Gautham R. Shenoy <ego at linux.vnet.ibm.com>
> ---
>  drivers/cpuidle/cpuidle-powernv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
> index 42896a67aeae..5f3922392059 100644
> --- a/drivers/cpuidle/cpuidle-powernv.c
> +++ b/drivers/cpuidle/cpuidle-powernv.c
> @@ -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;
> 
> -- 
> 2.13.5
> 



More information about the Linuxppc-dev mailing list