From patchwork Thu Jan 10 09:00:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 155127 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1656222jaa; Thu, 10 Jan 2019 01:00:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN4UzT9lACqJYAnmwirNh8fzo2+UGg4FJYEt686jSu6AB+Pglex8gmfrncrennNdmZkoBAZj X-Received: by 2002:a63:b30f:: with SMTP id i15mr8641971pgf.240.1547110849699; Thu, 10 Jan 2019 01:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547110849; cv=none; d=google.com; s=arc-20160816; b=vNJP8BTfN1VAW6oC6Tly4NbuudQw/u2SzMkvIAY99yFTCvYanyksZ83YThV3ur7A/Z GfW6+xHzhQgLMTc/2NuTIJIwLznSOspnaqUQbsntWwzGjFgevLuEcp/iOJFnopaosbuZ S7xZtuVu2zWej9K9LZ2eQEtX4EOUz449HDnHjh4DW9eZd2hN9rnpRVGLs5KLo/1E9IUE u1ygJUYnGlb5X+LDgzPTVOj9iG0dQEAiFSD7yMaBlmNm2dmaS7mg2NAzjw97qn/dfQ8M R77/uAIfL93KSyY0eAAZQHD7M3lvJpei22ijW4rtOYaa6TTgfK/bi3G2CgI4UJ0wbsaS 4e7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=18XqnmtxO2ZjWnroEVY6EZhQhDEBrpPKdAHEWSzf+WU=; b=V8Jx4Wxwb5+fsp8kuOErqebePRzX2QdLuJNhZKGNG0lBmr1tmwdUAZqjtWKNowKHpD I6wettlkQTMjPI6M1p1tgEGJ2ACEAEQ1CRtrA/ASPSSJdhW46UWsUSOse7QNNKb0kduO SrjjaxBEYn9U2Kxf//5qkq2OJA2ohjwtWtCWKta/atum0L0QYyvmzRCRl4ryZr00ccDD ciLaeM/3VxND/08sSE9B1yzRFT2xG/ZAl++yOz1ZWJ3a/pwuPbXI1pg2ThIMCYXhi0ZE kdxSdZ8BCpa7EE4aUeuyil/HTH0TrZ13h1r6F98IepfxmtSDuolas6Q432PwARWJbQSl IGrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=StTE4o0X; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20si67942330plr.106.2019.01.10.01.00.49; Thu, 10 Jan 2019 01:00:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=StTE4o0X; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727535AbfAJJAs (ORCPT + 11 others); Thu, 10 Jan 2019 04:00:48 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45648 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727534AbfAJJAs (ORCPT ); Thu, 10 Jan 2019 04:00:48 -0500 Received: by mail-wr1-f65.google.com with SMTP id t6so10358344wrr.12 for ; Thu, 10 Jan 2019 01:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=18XqnmtxO2ZjWnroEVY6EZhQhDEBrpPKdAHEWSzf+WU=; b=StTE4o0XcaXOhXmbEVctoZSfkYDxDJftLBtLSB+aOMwy6xCkH0BcV5DvLurqinEZ5d yotV4lgYIg217pLo1xVL3QfUFxxYzaI2ib4kkbGm7ufUkybttnVtZdjCnJemClaJw0EL 5kheEW6GNU4boUXUB/G+HMnhl3E+Z2XB+REkc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=18XqnmtxO2ZjWnroEVY6EZhQhDEBrpPKdAHEWSzf+WU=; b=B471cNMDnEVEgPpwGJZtUMjq1s183RHKXawl5aaWW6JlLjLwMb2kR2zOToC67cl4eh t+zvd/I4JbJpplDtLstsL+bqLhWAeM3p6oHlGlDMldgdz2tLIKmEyRflUZXzfsP+IGWh GFJnYUVbnJRlQGIRXzoRcSe/EKSLUbzFHrDbxHiqWUXCFk6lFEdJUebNyZRVq8NKHKf0 ZP0jbg2F9oGO1Txct0IlO1nFjRPQsQa5b0DLD3CnEH0S08q9dgbRsqYgGb23muqLaTjJ jIiuWv232q+THp3x3XZFqn6WaIqTKIF8zxAL9DEvhBt77J5vcu2z7ao3CdWpmkP/gVNY M2+A== X-Gm-Message-State: AJcUuke5W0bHTIq9NgzmaAA4Oo1RIbfJ7zQIB4fX4pnpqNzSd1pIle9s PwwpizsuMs5HKsyHW/ASIZGS4U47Ond0TQ== X-Received: by 2002:adf:f101:: with SMTP id r1mr8434701wro.32.1547110846578; Thu, 10 Jan 2019 01:00:46 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:e487:f4e5:a382:9ce9]) by smtp.gmail.com with ESMTPSA id v1sm78383304wrw.90.2019.01.10.01.00.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jan 2019 01:00:45 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, rjw@rjwysocki.net, ulf.hansson@linaro.org, tony@atomide.com, ladis@linux-mips.org Cc: Vincent Guittot Subject: [PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch Date: Thu, 10 Jan 2019 10:00:40 +0100 Message-Id: <1547110840-15396-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Tested-by: Tony Lindgren Signed-off-by: Vincent Guittot --- Change since v1: - add u64 cast for slack computation drivers/base/power/runtime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 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;