Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1743048imu; Thu, 10 Jan 2019 02:11:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN6LE8hrNBpbEL7ZwRXcJsQM0krCa6EtAdZgVRGTseE8NppbN4P8g1eVHQpBBpo1s6QsUnNp X-Received: by 2002:a63:2849:: with SMTP id o70mr8649604pgo.155.1547115103133; Thu, 10 Jan 2019 02:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547115103; cv=none; d=google.com; s=arc-20160816; b=GNoWHi3XColY+a0EBI8Z4cgbsMV5YQzFIv+kpkpxcj3GVcsk12M5Y9ZeVFcJVI/sQ6 vBnQoAGzKAbN2hI4bgpzDuLuhXPNE69Cf4rbpACKYKtwJC+/Y12+/jYWJj1Or+cF/IhS vSji19qnA31MTfuftNT4h1nIk5s+kJm7wle3JdaY2/kWA9kw/ulZmOwDJFVW612FaE5l sjjIVcViIyaxcRA7WW+5BEEECpCvdksl48AV0/zne6/6su9NxG63Y5KgqnxspeNASS8H TkDPTeA/S0v51j4E5VT+R9rQTY/xSs3J+2RVtEzVLVVqVAxIpzgJqix8HDLAhAJzF01M bjwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date; bh=Ouy3J1ZSSnv1RtukwmYEGYH5rcbHrAIZ5DKrVdyuJxk=; b=WAN8ETAV8Qbe2zyjqM/VZUqMO3+4sPZM0SScPug0yWuEOe7GiSotA9RU14AZnQEF18 ou6spJiW7HQp4Ye9lM14nQFDKnIWy2a4B/+8wrWO5tshS8xiep+K/7UfC0Vf9IemPmLI 7VYM/QAAJ99Kq2jN1Vpeoh0DubUs2/nJ+Bu3Pi7XykqgG8dUfwSgUn6J1Yn1y4tEhKM6 BmbFktuRW7ZpadqY7JJwJMFLryJptnsnFPKzeSMmesnDpfa5IP0iEcrbo5At356RVpNu lk8voHVj/3GcJCOQyDydoRmV5G84/ECg/eJ64/WTetrzHxlWl5G99eCmeWqUJ3SMR/sf t+xQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si7397363pgq.207.2019.01.10.02.11.27; Thu, 10 Jan 2019 02:11:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbfAJJva (ORCPT + 99 others); Thu, 10 Jan 2019 04:51:30 -0500 Received: from eddie.linux-mips.org ([148.251.95.138]:59696 "EHLO cvs.linux-mips.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbfAJJv3 (ORCPT ); Thu, 10 Jan 2019 04:51:29 -0500 Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S23990946AbfAJJv1YEa7P (ORCPT + 2 others); Thu, 10 Jan 2019 10:51:27 +0100 Date: Thu, 10 Jan 2019 10:51:25 +0100 From: Ladislav Michl To: "Rafael J. Wysocki" Cc: Linux PM , Linux Kernel Mailing List , Linux ARM , Linux OMAP Mailing List , "Rafael J. Wysocki" , Ulf Hansson , Tony Lindgren , Vincent Guittot Subject: [PATCH] PM/runtime: Do not needlessly call ktime_get Message-ID: <20190110095125.GA4491@lenoch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); -- 2.20.1