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: 10755399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B8B713BF for ; Thu, 10 Jan 2019 09:00:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DBC42918C for ; Thu, 10 Jan 2019 09:00:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01E402918F; Thu, 10 Jan 2019 09:00:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6AF429195 for ; Thu, 10 Jan 2019 09:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727328AbfAJJAs (ORCPT ); Thu, 10 Jan 2019 04:00:48 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40227 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727220AbfAJJAs (ORCPT ); Thu, 10 Jan 2019 04:00:48 -0500 Received: by mail-wr1-f66.google.com with SMTP id p4so10416580wrt.7 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=QBLE4Z3LCbMwKHva2uw5DJYQ4cRflC6r8U4i9w4VrjtyBQeQ8JeF4ciC1KCJ2/fRNi /jFRxjqYG66abVFWnT9IM+OGLBvo7r7NqsvOP5rw/r40CazFqLPwAQjfsPr+Yd/jjDeb CokfnBdN0A+4lKOtI2TpIEyTx0n74frCYttEPL/GzSycDv5jpi+dgAqrtPnT0r3S8VYG emhl7B+b9OiIOPWdRXGFiWFEDeJ3ce8m9E1N6nfVNvRKIRMijR/agH36m9WL/zOR63XB L4HtMyml8byoMFnzcgIEf4JQ578b3/GJ2sy5JgY6zNhqPZvOmbpi/DyU78KHUQLLEGQO 7P2Q== X-Gm-Message-State: AJcUukem64xEBSasB0tzbcNvvXHelSC0iZMwiHR0FqgbgLMMIXkFX9Ua NXfOtgaPvtJySOxG/XaPBflFYg== X-Google-Smtp-Source: ALg8bN4p1ZQuNVqDCrqwggX/aTkOENTsVdHD1g8Pgg5zQEoc+2qbWVw1fBTyboKuBWbZMFpNiZDfjw== 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-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;