aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/power/runtime.c
diff options
context:
space:
mode:
authorVincent Guittot <vincent.guittot@linaro.org>2019-01-10 10:00:40 +0100
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2019-01-10 10:55:52 +0100
commitca27e4cd0bdd87e33fda38e6e3d18d36d54356d4 (patch)
tree49bd82769e80a8965b392052f744057830aefa9a /drivers/base/power/runtime.c
parentPM-runtime: Fix 'jiffies' in comments after switch to hrtimers (diff)
downloadlinux-dev-ca27e4cd0bdd87e33fda38e6e3d18d36d54356d4.tar.xz
linux-dev-ca27e4cd0bdd87e33fda38e6e3d18d36d54356d4.zip
PM-runtime: Fix autosuspend_delay on 32bits arch
Cast autosuspend_delay to 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 converting 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> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to '')
-rw-r--r--drivers/base/power/runtime.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index a282e74d1a16..457be03b744d 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;