From patchwork Tue Mar 5 12:55:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 159642 Delivered-To: patches@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4937594jad; Tue, 5 Mar 2019 04:55:32 -0800 (PST) X-Received: by 2002:a19:4b0d:: with SMTP id y13mr723552lfa.58.1551790532123; Tue, 05 Mar 2019 04:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551790532; cv=none; d=google.com; s=arc-20160816; b=KxUNnDqmLzTt80IaMukakfitzQ216qL0jisXFPBtlanOjmJu8ZLTtF79j/z4MM/d0L JHgDDFwIPkQ5OjykBlyERYQS8gVFzSTq35hxGId/ZT67DxR4WkxAFJ5YxyWkGZcHZhQg 5siasY12atLRuTCI9Kj+KcBdSAPJeYOn0tzJzwYiIMGVLwbW5cVl1dmqpMivDAOPY/zA i+rZqaMNh8vK+4nBEcuv5DneX59o9ueRnjTtjBldEP2qEuqQ0kTsdnobgc3mnXjRm6/H B+TGEAXM8DadNajuhfw6t2JmJAdIAvDeWjQ0PbwuVu9/4ait3dGt2QABwLIHn0gDXZPZ NH8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=gWyEqHA/4lgOIuTcQX9h9/NrX1gZ//qhXqd0YHJexV4=; b=KxUPAuT68j/0qrLnMsFYH4KPv3R+sYPpksAjUHN45dX1v6Twmd2szYORCw8pbBlshQ FuRLghS72gdcdLq+nSw/ygULj31q33pA27QZNVjFMujejhsfr0n7c87dM8rIv1bV6HcT eYwKUZiz18zu5+nNrcI4/Cw9kMv6vekjZVj+pdbf5d4ByI5+Cyry4Jr1uXC2HCAo03NP pQPMw5nT4kr34jLd1yY9Dy9tLTE3kwGtwuAFzxWEC0dwlQUnYfG71Pyl+ApLRPLulxw5 u3PQrgDK4JVcGXP4cvi4H9wd9op/YkpybhtcTqA2A4Y4MzGY9nl1v8xKwwaBuUzKFIAd AetQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Lvt/2Ps1"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id e9sor4990782ljk.10.2019.03.05.04.55.31 for (Google Transport Security); Tue, 05 Mar 2019 04:55:32 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Lvt/2Ps1"; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=gWyEqHA/4lgOIuTcQX9h9/NrX1gZ//qhXqd0YHJexV4=; b=Lvt/2Ps1sQsZNLREbbQRguwhDwfRM3dChaip9tVgk9TLS3bFs0qdNMIFa05LbPanHZ N9zqUUv1hVoc8/B8t5vWsH4Xex4+5xGf+/0fLASd/FA6nbzw4das4awKIDyPLZt4h4Ag B072r3reqV+ug8iU91tfbr2gDgWZYHm99FzMOqfKXilkSILchk14bzdPaBe0oog6XOD4 XTa1qzf7IB+qienZIiZw0clEcn7MfQf9zeoj6+7g9m7lUssnGxtLjRNZ+QP+d89d4ozq mmF16CGeG6MDQTegZ3avZbMlIJA45R862GQNEuVwYZDG2hiF8e2S2bN0+VL9EMokUW9J sOLA== 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=gWyEqHA/4lgOIuTcQX9h9/NrX1gZ//qhXqd0YHJexV4=; b=ZK7iqNIPNQjmqKKev4//qFSfpTXCG8fsN4YVqBOmYOFMBZrCw1zRt8EKB3R7BTobd/ RRyP7kr+Rycr0NBe51++1leFwJvdX3GvBOJEHfDJDtw+U4aiR5Yv1TutyW4sQOgBQ7oh AXgUTrMoaSIfjSUgNk+w0S5gBEsla2xn9qGLmn5YhsM3RAsUtzPpr+6BZYCS8GC0yo1C tfcAaih6NxhUG54yFHMRydOzTgxhfee0OLO7l2sAOWXFperBoOL/jL6e+E6v8jwVGFAd wj37RVXIz9niBwpwGvx9/CgOOBjzK7L5yAlXdt6oZusctd4ROcdYbH2dsyqGF2wXg5JH 23yg== X-Gm-Message-State: APjAAAWKmYM+ArAwTt6YUv+93BHMHZrkUKpNiI3eH39/rjZH97i7bZaa cU4N8+e7Y9pGHnaMISXftBbwZOjy X-Google-Smtp-Source: APXvYqykXo951xPI4G3ZyPY38e+LHgEgCM/dc0wcZ9IMF+6vbQFvK5Cy1GjbQv1p0/K9Ia5RJBLsww== X-Received: by 2002:a2e:780a:: with SMTP id t10mr11978377ljc.19.1551790531531; Tue, 05 Mar 2019 04:55:31 -0800 (PST) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id l20sm2104499ljb.24.2019.03.05.04.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 04:55:30 -0800 (PST) From: Ulf Hansson To: "Rafael J . Wysocki" , linux-pm@vger.kernel.org Cc: Ulf Hansson , Vincent Guittot , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] PM / Runtime: Consolidate code to get active/suspended time Date: Tue, 5 Mar 2019 13:55:26 +0100 Message-Id: <20190305125526.21360-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In a step to consolidate code around fetching the runtime PM active/suspend time for a device, let's re-factor the existing pm_runtime_suspended_time() and add a new corresponding pm_runtime_active_time(). Make the latter shared internally to the PM core, as in following changes it starts making use of it. Signed-off-by: Ulf Hansson --- drivers/base/power/power.h | 1 + drivers/base/power/runtime.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h index c511def48b48..ec33fbdb919b 100644 --- a/drivers/base/power/power.h +++ b/drivers/base/power/power.h @@ -21,6 +21,7 @@ static inline void pm_runtime_early_init(struct device *dev) extern void pm_runtime_init(struct device *dev); extern void pm_runtime_reinit(struct device *dev); extern void pm_runtime_remove(struct device *dev); +extern u64 pm_runtime_active_time(struct device *dev); #define WAKE_IRQ_DEDICATED_ALLOCATED BIT(0) #define WAKE_IRQ_DEDICATED_MANAGED BIT(1) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 78937c45278c..d1908fc422cc 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -98,7 +98,7 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status) dev->power.runtime_status = status; } -u64 pm_runtime_suspended_time(struct device *dev) +static u64 rpm_account_time(struct device *dev, bool suspend) { u64 time; unsigned long flags; @@ -106,12 +106,22 @@ u64 pm_runtime_suspended_time(struct device *dev) spin_lock_irqsave(&dev->power.lock, flags); update_pm_runtime_accounting(dev); - time = dev->power.suspended_time; + time = suspend ? dev->power.suspended_time : dev->power.active_time; spin_unlock_irqrestore(&dev->power.lock, flags); return time; } + +u64 pm_runtime_active_time(struct device *dev) +{ + return rpm_account_time(dev, false); +} + +u64 pm_runtime_suspended_time(struct device *dev) +{ + return rpm_account_time(dev, true); +} EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); /**