From patchwork Thu Jan 10 09:51:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 10755481 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 0A6E46C2 for ; Thu, 10 Jan 2019 09:51:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E90EF29335 for ; Thu, 10 Jan 2019 09:51:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E734D2935B; Thu, 10 Jan 2019 09:51:38 +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,UNPARSEABLE_RELAY 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 7747C29335 for ; Thu, 10 Jan 2019 09:51:38 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date: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=a1eHoYbVs433AlQVVgOKH0jEqgtTaq7UEMg9lJb+aAo=; b=CZCY4LBMo1UQb/ qjCb16Rrgrx/VrLwDq/qqUT2Z92ea34yGdI8b0sD0zwx+aE+OVWX1kSyBAuK9cNbfIn4/uu35yTxm GzwvjZd9X1oRrgKz00/aKhSN6ehx3vMWUYJt8ymTxoInA9NhXkfLtWpoFZKEnSIzqikd5TBvA+wyC DRgshW8oAi3mTrSlO9s76vDwlfNLLX3rdo8ARptVibVDK9oMRNptyP3zMCznT+ym3MGUo3Fe3o9TW M9neZAgvdq0gV/XN6dl3heG7U99D6NTgOXoiu9x+Rt87Q/FnUHfRWxg+RQhOnuK7H4tLHKPs+7+iI 24jpML/PS/GbqrPd7Bkw==; 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 1ghWzu-0006QY-Tz; Thu, 10 Jan 2019 09:51:34 +0000 Received: from eddie.linux-mips.org ([148.251.95.138] helo=cvs.linux-mips.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghWzq-0006Ix-2c for linux-arm-kernel@lists.infradead.org; Thu, 10 Jan 2019 09:51:32 +0000 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990946AbfAJJv1YEa7P (ORCPT ); Thu, 10 Jan 2019 10:51:27 +0100 Date: Thu, 10 Jan 2019 10:51:25 +0100 From: Ladislav Michl To: "Rafael J. Wysocki" Subject: [PATCH] PM/runtime: Do not needlessly call ktime_get Message-ID: <20190110095125.GA4491@lenoch> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190110_015130_549028_666EDC8E X-CRM114-Status: GOOD ( 11.69 ) 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: Ulf Hansson , Vincent Guittot , Linux PM , Tony Lindgren , "Rafael J. Wysocki" , Linux Kernel Mailing List , Linux OMAP Mailing List , Linux ARM 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 pm_runtime_autosuspend_expiration calls ktime_get even when its returned value may be unused. Therefore get current time later and remove gotos while there. Signed-off-by: Ladislav Michl Acked-by: Tony Lindgren Acked-by: Vincent Guittot --- NOTE: Depends on Vincent's "[PATCH v2] PM/runtime: Fix autosuspend_delay on 32bits arch"! drivers/base/power/runtime.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 457be03b744d..836b1b8784eb 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -129,24 +129,21 @@ static void pm_runtime_cancel_pending(struct device *dev) u64 pm_runtime_autosuspend_expiration(struct device *dev) { int autosuspend_delay; - u64 last_busy, expires = 0; - u64 now = ktime_to_ns(ktime_get()); + u64 expires; if (!dev->power.use_autosuspend) - goto out; + return 0; autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay); if (autosuspend_delay < 0) - goto out; - - last_busy = READ_ONCE(dev->power.last_busy); + return 0; - expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC; - if (expires <= now) - expires = 0; /* Already expired. */ + expires = READ_ONCE(dev->power.last_busy); + expires += (u64)autosuspend_delay * NSEC_PER_MSEC; + if (expires > ktime_to_ns(ktime_get())) + return expires; /* Expires in the future */ - out: - return expires; + return 0; } EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);