linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch
@ 2019-01-10  9:00 Vincent Guittot
  2019-01-10 16:44 ` Tony Lindgren
  0 siblings, 1 reply; 3+ messages in thread
From: Vincent Guittot @ 2019-01-10  9:00 UTC (permalink / raw)
  To: linux-pm, linux-kernel, linux-arm-kernel, linux-omap, rjw,
	ulf.hansson, tony, ladis
  Cc: Vincent Guittot

Cast autosuspend_delay in u64 to make sure that the full computation of
expires or slack will be done in u64, even on 32bits arch.
Otherwise, any delay greater than 2^31 nsec can overflow if signed 32bits
is used when moving delay from msec to nsec

Fixes: 8234f6734c5d ("PM-runtime: Switch autosuspend over to using hrtimers")
Reported-by: Tony Lindgren <tony@atomide.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
---

Change since v1:
- add u64 cast for slack computation

 drivers/base/power/runtime.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 7062469..76d0676 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -141,7 +141,7 @@ u64 pm_runtime_autosuspend_expiration(struct device *dev)
 
 	last_busy = READ_ONCE(dev->power.last_busy);
 
-	expires = last_busy + autosuspend_delay * NSEC_PER_MSEC;
+	expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC;
 	if (expires <= now)
 		expires = 0;	/* Already expired. */
 
@@ -525,7 +525,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
 				 * We add a slack of 25% to gather wakeups
 				 * without sacrificing the granularity.
 				 */
-				u64 slack = READ_ONCE(dev->power.autosuspend_delay) *
+				u64 slack = (u64)READ_ONCE(dev->power.autosuspend_delay) *
 						    (NSEC_PER_MSEC >> 2);
 
 				dev->power.timer_expires = expires;
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch
  2019-01-10  9:00 [PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch Vincent Guittot
@ 2019-01-10 16:44 ` Tony Lindgren
  2019-01-11 10:39   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Tony Lindgren @ 2019-01-10 16:44 UTC (permalink / raw)
  To: Vincent Guittot
  Cc: ulf.hansson, ladis, linux-pm, rjw, linux-kernel, linux-omap,
	linux-arm-kernel

* Vincent Guittot <vincent.guittot@linaro.org> [190110 09:00]:
> Cast autosuspend_delay in u64 to make sure that the full computation of
> expires or slack will be done in u64, even on 32bits arch.
> Otherwise, any delay greater than 2^31 nsec can overflow if signed 32bits
> is used when moving delay from msec to nsec
> 
> Fixes: 8234f6734c5d ("PM-runtime: Switch autosuspend over to using hrtimers")
> Reported-by: Tony Lindgren <tony@atomide.com>
> Tested-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> ---
> 
> Change since v1:
> - add u64 cast for slack computation

Still works for me.

Thanks,

Tony

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch
  2019-01-10 16:44 ` Tony Lindgren
@ 2019-01-11 10:39   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2019-01-11 10:39 UTC (permalink / raw)
  To: Tony Lindgren, Vincent Guittot
  Cc: ulf.hansson, ladis, linux-pm, linux-kernel, linux-omap, linux-arm-kernel

On Thursday, January 10, 2019 5:44:31 PM CET Tony Lindgren wrote:
> * Vincent Guittot <vincent.guittot@linaro.org> [190110 09:00]:
> > Cast autosuspend_delay in u64 to make sure that the full computation of
> > expires or slack will be done in u64, even on 32bits arch.
> > Otherwise, any delay greater than 2^31 nsec can overflow if signed 32bits
> > is used when moving delay from msec to nsec
> > 
> > Fixes: 8234f6734c5d ("PM-runtime: Switch autosuspend over to using hrtimers")
> > Reported-by: Tony Lindgren <tony@atomide.com>
> > Tested-by: Tony Lindgren <tony@atomide.com>
> > Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
> > ---
> > 
> > Change since v1:
> > - add u64 cast for slack computation
> 
> Still works for me.

Applied, thanks!


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-11 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10  9:00 [PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch Vincent Guittot
2019-01-10 16:44 ` Tony Lindgren
2019-01-11 10:39   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).