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: 10755397 X-Patchwork-Delegate: rjw@sisk.pl 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 E29671515 for ; Thu, 10 Jan 2019 09:00:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D29CF2918C for ; Thu, 10 Jan 2019 09:00:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C709D29192; Thu, 10 Jan 2019 09:00:49 +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=ham 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 287E02918C for ; Thu, 10 Jan 2019 09:00:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727535AbfAJJAs (ORCPT ); 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-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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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;