From patchwork Wed Jan 23 07:50:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 156344 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp435401jaa; Tue, 22 Jan 2019 23:50:25 -0800 (PST) X-Google-Smtp-Source: ALg8bN7VO6z3Af2VVg/VAv8qJW6kkcNhBQLLxScmeNXhbYPAhMWoTOCskTBzy86PoTnRbm+EN8iv X-Received: by 2002:a63:920a:: with SMTP id o10mr1064157pgd.141.1548229825166; Tue, 22 Jan 2019 23:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548229825; cv=none; d=google.com; s=arc-20160816; b=y104EuzwyA2LVyx7mt7ZL8D32eSoc2aXQ1v5BAT/DE0uwHSuY8Iz7ddGuLcDNS/TgB JcZjeQNl1K4CoShWWxiB+f1zQMY2ULJaVLYldAUyd4ryNXtM7fJT8MHwBEppD0c9L3xX uwvsjllCh2fVYaD6Ug7VlbJJ5Q7IYRjC0/BkMM8CvxdPul4zcFyh3oxQt3fudfoTYIVV GnCcUrKfzvfX/auwn5hel/GWU6l0c8n04O3XKjBguHs5J5ux6l8/fZzsnKtZFTVhwXoo fQ0Uf4WwOPr+7mrAaeNubMuYnIZHnHTC2L3PYGDefFQTNNMkUJMdi4B84bTkjJXhOSFL QxXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dm1djdLVSS6M3bvErQJB+/zSgJ56gxH1n+KiZojviIM=; b=iqaENcNEN4O+Vt7fufUfsNSuwd6pPjuhPjsxSE8nOELcN4zS5wcigshjPjPgoadJh2 DBvJ2ijqW7pPmsVXGWHHybO4lLeiBh4JRctWwYuEuXankdWQ6+LCByT9TpziT1ufY4Bd ONoNYsgm5XW2g+RLHJ2CW10+CRoIp4wzIWf6zktEaCHGCLEs28o2HE/YhRTjo9JpkOh2 Sm7WBu+e0yecr5WNhao3Z+SmXDHYPuJh4D8ufmPMWVERGoTvr9Bk5GWY8Znv+97BXMoA 0+4M3di4Jxn6IgP+pHhqW+f/ZolLszYo+MqoVIz1DE7XDohbSlMeaFVUTja9K/NUDPSI TPbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BUabxBkQ; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p10si15378676pgi.549.2019.01.22.23.50.24; Tue, 22 Jan 2019 23:50:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BUabxBkQ; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727015AbfAWHuX (ORCPT + 11 others); Wed, 23 Jan 2019 02:50:23 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:45507 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbfAWHuW (ORCPT ); Wed, 23 Jan 2019 02:50:22 -0500 Received: by mail-wr1-f68.google.com with SMTP id t6so1164213wrr.12 for ; Tue, 22 Jan 2019 23:50:21 -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:in-reply-to:references; bh=dm1djdLVSS6M3bvErQJB+/zSgJ56gxH1n+KiZojviIM=; b=BUabxBkQ80rAjig3sHrjRpICpMA5l8DxYnd61NyX7VsUZaeF8Q+yY3sayjbTXdCDQx Ho7N26ZLjOaKxTeEN894vBwYx2rVgSmsjAngx0OVLrK3gq7P1LV6r4cLcmOI5yAn2ZWN GqlL9OnXaCzCyE0eo9/sz4z4z227wF84QCC5s= 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:in-reply-to :references; bh=dm1djdLVSS6M3bvErQJB+/zSgJ56gxH1n+KiZojviIM=; b=UczxK7akc3N/0KctnATgE+xXelteUcuUbml/CpNCW3tEuVX1SBruBzOCk9tBLwTxG7 RvQ3ppicyu2Sj7AmETVNU1CiWQeFWA/g+PKcHtAKzmH5RxlrCF1d0dYOpzHDRic+yIY5 rSjCPAx/DqaxKm1QI69jWbC84eNuZ/dGuheW8OYFhvxcre3fK2rEsWTw+exUJE8aTpFF cGKHWnTOUYGh3gwkZyddICpOYWxuDdfP9+GXIpDmX92WNswoCdCc7OFpDbhGakd/z8FE NrThXrXuBFjkbYOz7VejMnw5WTNkpf4odU07JcW+3L5c6MJYR0vV9W2fEIg9DdHVnktD 0AMA== X-Gm-Message-State: AJcUukeo6cdCWt0YbHyaBkLpi7LI6wItI980qw4RD25z+l6adM387CaP Th+QCWeI4ZxZda/TKUC75dy9BCc6dyaQFw== X-Received: by 2002:a5d:4ccb:: with SMTP id c11mr1455765wrt.241.1548229820000; Tue, 22 Jan 2019 23:50:20 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:5ca6:2921:648b:56b6]) by smtp.gmail.com with ESMTPSA id i186sm70138787wmd.19.2019.01.22.23.50.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Jan 2019 23:50:18 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, thara.gopinath@linaro.org, linux@roeck-us.net Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH v7 1/2] PM-runtime: update accounting_timestamp only when enable Date: Wed, 23 Jan 2019 08:50:13 +0100 Message-Id: <1548229814-24913-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548229814-24913-1-git-send-email-vincent.guittot@linaro.org> References: <1548229814-24913-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Initializing accounting_timestamp to something different from 0 during pm_runtime_init() doesn't make sense and put useless ordering constraint between timekeeping_init() and pm_runtime_init(). PM runtime should start accounting time only when it is enable and discard the period when disabled. Set accounting_timestamp to now when enabling PM runtime. Suggested-by: "Rafael J. Wysocki" Signed-off-by: Vincent Guittot --- drivers/base/power/runtime.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index fb5e2b6..eccd37f1 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -1306,10 +1306,15 @@ void pm_runtime_enable(struct device *dev) spin_lock_irqsave(&dev->power.lock, flags); - if (dev->power.disable_depth > 0) + if (dev->power.disable_depth > 0) { dev->power.disable_depth--; - else + + /* About to enable runtime pm, set accounting_timestamp to now */ + if (!dev->power.disable_depth) + dev->power.accounting_timestamp = jiffies; + } else { dev_warn(dev, "Unbalanced %s!\n", __func__); + } WARN(!dev->power.disable_depth && dev->power.runtime_status == RPM_SUSPENDED && @@ -1506,7 +1511,7 @@ void pm_runtime_init(struct device *dev) dev->power.request_pending = false; dev->power.request = RPM_REQ_NONE; dev->power.deferred_resume = false; - dev->power.accounting_timestamp = jiffies; + dev->power.accounting_timestamp = 0; INIT_WORK(&dev->power.work, pm_runtime_work); dev->power.timer_expires = 0;