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: 10755401 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 8D91A13BF for ; Thu, 10 Jan 2019 09:00:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E62C2918C for ; Thu, 10 Jan 2019 09:00:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7300929192; Thu, 10 Jan 2019 09:00:59 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E85372918C for ; Thu, 10 Jan 2019 09:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=SJEoS2+lsAurDH5i8opYlZAzjFOwIWAm5ESoFxs1lWQ=; b=SHL 4X+cs3wXlIDQYyr+jxQW/0tvrJ1QVJcIX2TmKfCwA6BU6TTh1ulp04/gHyNDyPCt31HYKc9xTglq8 xq6xsuq0OepQ++FhwT0I8Qtq0cOL+CsZuu9BsKMk7l7oWOP6d5iDgRkNq81X8WmLEEKtvII40fMEn 5JGNRddsqS9b3/XdNT25yfVFFSvjfe7iPu12l1i/LbpTe16zZPTrkB5ATa+UyxCTm8+d0cCOh1d7R RzmH7gcyBEj2tvIt7MKEq6lhLQGeE6QrcNoLIhWxTPQ0tk45pbuJT4DG7URBeCnuyy4IJI/1kd7yH Et35kw0Tj6Rea5FH6Qan0NZthufQP5g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghWCt-0001Jo-NM; Thu, 10 Jan 2019 09:00:55 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghWCm-0001Iy-Ih for linux-arm-kernel@lists.infradead.org; Thu, 10 Jan 2019 09:00:54 +0000 Received: by mail-wr1-x441.google.com with SMTP id x10so10383223wrs.8 for ; Thu, 10 Jan 2019 01:00:48 -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=ADtfnvwQqTlRufBiMEK9EnEgQwXSxQIh5JFClP6lncQZltv8cOTINiIiTBs/E/tSmm yyJ/t2v/rjpPyeYDh47OjwuLY/MTqDq7VBdV7YlBLSc78GMOqKe25e/zRiR57zBnr6o9 NLauzFlg/LEe79jglrTUxS1lCLxqRDei0iJKZYx29gu32zG4q30GHV1Cxx3/IwBcC1E/ U+X9rVutfG7HSGg7MMrItSkNjA09YY3E9na94OamgofevER0zPkAWT4TKUeo2AVFysKA BFA4DpeXIeBTq3l5MYmV3t1xYJSTFWsBtkh1K/tORtMgMtXacupCpOHJl7BMbEJYmQvk Ky8Q== X-Gm-Message-State: AJcUukfC2vmfSTxyPKYQlx7A2UGiyt7NEnslfeECrCRT/fpvtVQ42aeq k5eIglYBiJvaQ84YKhjtjwLsuw== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190110_010048_644858_DF5950C9 X-CRM114-Status: GOOD ( 14.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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;