From patchwork Thu Dec 20 14:16:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10738953 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 9AEEB17E1 for ; Thu, 20 Dec 2018 14:16:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89F86287D2 for ; Thu, 20 Dec 2018 14:16:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D7532882F; Thu, 20 Dec 2018 14:16:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BBE82881C for ; Thu, 20 Dec 2018 14:16:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387508AbeLTOQe (ORCPT ); Thu, 20 Dec 2018 09:16:34 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36547 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387500AbeLTOQe (ORCPT ); Thu, 20 Dec 2018 09:16:34 -0500 Received: by mail-wr1-f66.google.com with SMTP id u4so1937796wrp.3 for ; Thu, 20 Dec 2018 06:16:32 -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=8H/YiHauv71s0EVIedV1buJib0rVCedGsQtekdc1nA8=; b=HWOftnI1mbulWmgJlFO7aGeHWxAy4tAgurVqR4AzNFAaWCbHc62oW2cosYjrIZIb4X uSSwhJ6YoAZ6twfHq/T6FVcFdNl4nGla9mEkByn18fj9z315qL9GxtZ0kknoFjZcHJxh K3rj9v1SYuakV97U6Ri6wqz5ZqOd6EQWh2vbU= 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=8H/YiHauv71s0EVIedV1buJib0rVCedGsQtekdc1nA8=; b=oS9kJR9S0Nyq3PYfJ7yt75cc8lraBYue58bPGVXrC8P59kw9QSVxOAmBbhvis3N3t9 hwFLl2mV3HzVfKxKW2dqfEo8DMNSA0NzSUQ371o1zm1oSFW8+dTVemOXxDt2z7jLZgxL rJxzSv77MJRzlTvj29aDFJxsNMOte2TRhmsgVyiANxVF9G/UKyOMq79Iw3wCy/HkSETM em/0/zILai4kS9qgINOWm2M9kq+L7pq6JFhaaSr5mmSj6/ABrruVDrzbZJKybJBajSTm HORwanMV8gw/+GwDA6STrZVLAwoUuLNjg2hQQC+t/TpY4u9h1x4YMjNNGx29Snl/YeJk 2x1g== X-Gm-Message-State: AA+aEWYyPfxa6C916mMBMFikveo8fBLAWzAKkWNw56n0T/I/Cdyk/x6j KffHb0xswWYNEUTxtPC6ADYB37vDo6mlaA== X-Google-Smtp-Source: AFSGD/V4TD2tOUeyfiPk/ZY5x1XnKKv3F8PgpZ/bjzw1x2UBkOVGRgM38l2dEU2qFclUyFk8ChWvQw== X-Received: by 2002:adf:db01:: with SMTP id s1mr22055723wri.214.1545315391844; Thu, 20 Dec 2018 06:16:31 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:f9b3:37c1:b11a:64ce]) by smtp.gmail.com with ESMTPSA id 127sm2313218wmm.45.2018.12.20.06.16.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 06:16:30 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, thara.gopinath@linaro.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH v4 1/3] PM/runtime: Add a new interface to get accounted time Date: Thu, 20 Dec 2018 15:16:23 +0100 Message-Id: <1545315385-14384-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545315385-14384-1-git-send-email-vincent.guittot@linaro.org> References: <1545315385-14384-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 X-Virus-Scanned: ClamAV using ClamSMTP Some drivers (like i915/drm) needs to get the accounted suspended time. pm_runtime_suspended_time() will return the suspended accounted time in ns unit. Signed-off-by: Vincent Guittot Reviewed-by: Ulf Hansson --- drivers/base/power/runtime.c | 16 ++++++++++++++++ include/linux/pm_runtime.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index beb85c3..e695544 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -86,6 +86,22 @@ 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) +{ + unsigned long flags, time; + + spin_lock_irqsave(&dev->power.lock, flags); + + update_pm_runtime_accounting(dev); + + time = dev->power.suspended_jiffies; + + spin_unlock_irqrestore(&dev->power.lock, flags); + + return jiffies_to_nsecs(time); +} +EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); + /** * pm_runtime_deactivate_timer - Deactivate given device's suspend timer. * @dev: Device to handle. diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h index f0fc470..d479707 100644 --- a/include/linux/pm_runtime.h +++ b/include/linux/pm_runtime.h @@ -113,6 +113,8 @@ static inline bool pm_runtime_is_irq_safe(struct device *dev) return dev->power.irq_safe; } +extern u64 pm_runtime_suspended_time(struct device *dev); + #else /* !CONFIG_PM */ static inline bool queue_pm_work(struct work_struct *work) { return false; } From patchwork Thu Dec 20 14:16:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10738957 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 2488D13AD for ; Thu, 20 Dec 2018 14:17:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 148102881C for ; Thu, 20 Dec 2018 14:17:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0894528960; Thu, 20 Dec 2018 14:17:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE5132881C for ; Thu, 20 Dec 2018 14:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732680AbeLTORE (ORCPT ); Thu, 20 Dec 2018 09:17:04 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35841 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731194AbeLTORE (ORCPT ); Thu, 20 Dec 2018 09:17:04 -0500 Received: by mail-wm1-f65.google.com with SMTP id p6so2371065wmc.1 for ; Thu, 20 Dec 2018 06:17:02 -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=dl0vWZ2OmuLRkr6rXUIz7t6LbyxfogMj8WkEhaEhsA0=; b=b9k/Hf8kAni+gkKuoX2ym92n5HEjdT1XxxzZEnhXqz4HBR/UWmLNTNR65gknoyaiPS KQ7vdCJft5lHDbGZMc+hB1IcrMbr5rLQAhONL4CdHHRRF12Qfd0KfbnEFPOhHum+QSRf IXsUzEhArcfQkxTl9/q008nk/WHsIa0GS6ciY= 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=dl0vWZ2OmuLRkr6rXUIz7t6LbyxfogMj8WkEhaEhsA0=; b=ZZGgSZt5iOoGj+sqA5vRMCwNMUIPLSbhWDgOYB92HTk+DeClAN7ujhLqEAFRdhlYJr jeeMkLFy66Kph8IDepQSfWf+UQgsA5rhE7/r7iTVTdI0opJP8CPotQSnAe7mPiYUB6Zi 2O5ifYNBJZlc5tg8Ikyr8BYjKq+8iYtA5RneJpeagD2JMd/CAhaSX6AZ6Btkol651e22 CRdua42lFAbKQ+kIOs9rG45adUTwOc9xDzL1npd77iJlWCihSMX5mrEqiDHq8Cn+z8ce MF+6traZ0IXemeniBbLUQagp6iwEWZ2IbY9+0TFI13jzBI6gI7ROR/ookn2Q/xGYdd1c QocA== X-Gm-Message-State: AA+aEWaccXbMdefAADDfYm2K9LiZbmh9pB16Y1S0Z6AJYVeKnjWRudas gQXiJVh3kKIK6ys6j+rxtdNQXqXeBkAoGA== X-Google-Smtp-Source: AFSGD/UNrjs/0zRvq0PN+NwLus3oyFp12NHZqRJ3E0lyn8bH8ARB6+LrmxNY9dWK2HJNuuvGzxKNpw== X-Received: by 2002:a1c:128b:: with SMTP id 133mr12239546wms.22.1545315421678; Thu, 20 Dec 2018 06:17:01 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:f9b3:37c1:b11a:64ce]) by smtp.gmail.com with ESMTPSA id v132sm7855024wme.20.2018.12.20.06.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 06:17:00 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, thara.gopinath@linaro.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH v4 2/3] drm/i915: Move on the new pm runtime interface Date: Thu, 20 Dec 2018 15:16:57 +0100 Message-Id: <1545315417-14483-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new pm runtime interface to get the accounted suspended time: pm_runtime_accounted_time_get() Signed-off-by: Vincent Guittot Reviewed-by: Ulf Hansson --- drivers/gpu/drm/i915/i915_pmu.c | 16 ++++++---------- drivers/gpu/drm/i915/i915_pmu.h | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index d6c8f8f..3f76f60 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -5,6 +5,7 @@ */ #include +#include #include "i915_pmu.h" #include "intel_ringbuffer.h" #include "i915_drv.h" @@ -478,7 +479,6 @@ static u64 get_rc6(struct drm_i915_private *i915) * counter value. */ spin_lock_irqsave(&i915->pmu.lock, flags); - spin_lock(&kdev->power.lock); /* * After the above branch intel_runtime_pm_get_if_in_use failed @@ -491,16 +491,13 @@ static u64 get_rc6(struct drm_i915_private *i915) * suspended and if not we cannot do better than report the last * known RC6 value. */ - if (kdev->power.runtime_status == RPM_SUSPENDED) { - if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) - i915->pmu.suspended_jiffies_last = - kdev->power.suspended_jiffies; + if (pm_runtime_status_suspended(kdev)) { + val = pm_runtime_suspended_time(kdev); - val = kdev->power.suspended_jiffies - - i915->pmu.suspended_jiffies_last; - val += jiffies - kdev->power.accounting_timestamp; + if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) + i915->pmu.suspended_time_last = val; - val = jiffies_to_nsecs(val); + val -= i915->pmu.suspended_time_last; val += i915->pmu.sample[__I915_SAMPLE_RC6].cur; i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val; @@ -510,7 +507,6 @@ static u64 get_rc6(struct drm_i915_private *i915) val = i915->pmu.sample[__I915_SAMPLE_RC6].cur; } - spin_unlock(&kdev->power.lock); spin_unlock_irqrestore(&i915->pmu.lock, flags); } diff --git a/drivers/gpu/drm/i915/i915_pmu.h b/drivers/gpu/drm/i915/i915_pmu.h index 7f164ca..3dc2a30 100644 --- a/drivers/gpu/drm/i915/i915_pmu.h +++ b/drivers/gpu/drm/i915/i915_pmu.h @@ -95,9 +95,9 @@ struct i915_pmu { */ struct i915_pmu_sample sample[__I915_NUM_PMU_SAMPLERS]; /** - * @suspended_jiffies_last: Cached suspend time from PM core. + * @suspended_time_last: Cached suspend time from PM core. */ - unsigned long suspended_jiffies_last; + u64 suspended_time_last; /** * @i915_attr: Memory block holding device attributes. */ From patchwork Thu Dec 20 14:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10738967 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 DE76414E2 for ; Thu, 20 Dec 2018 14:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE47728834 for ; Thu, 20 Dec 2018 14:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C168628944; Thu, 20 Dec 2018 14:17:16 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 481F92882F for ; Thu, 20 Dec 2018 14:17:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733182AbeLTORO (ORCPT ); Thu, 20 Dec 2018 09:17:14 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34307 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732525AbeLTORL (ORCPT ); Thu, 20 Dec 2018 09:17:11 -0500 Received: by mail-wm1-f67.google.com with SMTP id y185so12046241wmd.1 for ; Thu, 20 Dec 2018 06:17:10 -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=Knn4iUcnejv9TyDbBm0a94Rk0LLVciIk4+jKF5JXBmY=; b=hhHwS8/0lRF2rmUVEh50/tQQR4YfVUnbFFw61w5XX8uDKj5rBQtH7hIoCknyltCyOe ey6XELSBNUWmKwVDbNg4qS9aqVS8VRJAKb4EvNfAV1MtefWuXkzz9geRF7xS+IYv0Asw 7mE8hmN9/GeEB1y5bA2RCFSKDB+VatJysdaxQ= 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=Knn4iUcnejv9TyDbBm0a94Rk0LLVciIk4+jKF5JXBmY=; b=d0Rtp1XYtZ5SbKckiE7jCtu/PUlsnUy8LAYd2zhxIscF1ZPYUf1fJ8uKUgV1zFyWTi MSKO9qPB/pwL7SyHq00OVlgbpFwov09R6TL74RNv9AHu77gJiQuJkNC58G3LDQBHo1Qz 4fzJ1710UUVrD/5ilrWl7gtF4bHt3+R6T06dFQqFY1gz0bP+dqRFva54Hhxqo7/rnnOJ 4zavHf/GNQVfvbfqBp9OuPgfzfmFxPKJCJnr9fb+02bh8//zP3eaD0/lZDzdpBARDw21 EbOhhfl3PBo/n8r1S6JqAyZa37AToXqeqU2W6F2l2Re5ACHG/zprg8fxgHSAQUWSzRNZ oUwA== X-Gm-Message-State: AA+aEWbk+wyv8T9lAc7n0E4IgguLFTe5lKpL84/rjgIIzA2uQduy7Y3g ls3mzAH57EbJYSwqUjsJW6W5Q+VBKut6dQ== X-Google-Smtp-Source: AFSGD/VKuPzumNLcozFsbpz/a4BrIzuK7Ny+9hI28yCSze3taDYSLnajo7QnIubcGb87vp+DiPvvzw== X-Received: by 2002:a1c:9806:: with SMTP id a6mr2824292wme.114.1545315429397; Thu, 20 Dec 2018 06:17:09 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:f9b3:37c1:b11a:64ce]) by smtp.gmail.com with ESMTPSA id m132sm4616849wmd.15.2018.12.20.06.17.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 06:17:08 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, thara.gopinath@linaro.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH v4 3/3] PM/runtime:Replace jiffies based accounting with ktime based accounting Date: Thu, 20 Dec 2018 15:17:06 +0100 Message-Id: <1545315426-14545-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thara Gopinath This patch replaces jiffies based accounting for runtime_active_time and runtime_suspended_time with ktime base accounting. This makes the runtime debug counters inline with genpd and other pm subsytems which uses ktime based accounting. Signed-off-by: Thara Gopinath [move from ktime to raw nsec] Signed-off-by: Vincent Guittot --- drivers/base/power/runtime.c | 17 +++++++++-------- drivers/base/power/sysfs.c | 11 ++++++++--- include/linux/pm.h | 6 +++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index e695544..f700524 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -64,8 +64,8 @@ static int rpm_suspend(struct device *dev, int rpmflags); */ void update_pm_runtime_accounting(struct device *dev) { - unsigned long now = jiffies; - unsigned long delta; + u64 now = ktime_to_ns(ktime_get()); + u64 delta; delta = now - dev->power.accounting_timestamp; @@ -75,9 +75,9 @@ void update_pm_runtime_accounting(struct device *dev) return; if (dev->power.runtime_status == RPM_SUSPENDED) - dev->power.suspended_jiffies += delta; + dev->power.suspended_time += delta; else - dev->power.active_jiffies += delta; + dev->power.active_time += delta; } static void __update_runtime_status(struct device *dev, enum rpm_status status) @@ -88,17 +88,18 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status) u64 pm_runtime_suspended_time(struct device *dev) { - unsigned long flags, time; + u64 time; + unsigned long flags; spin_lock_irqsave(&dev->power.lock, flags); update_pm_runtime_accounting(dev); - time = dev->power.suspended_jiffies; + time = dev->power.suspended_time; spin_unlock_irqrestore(&dev->power.lock, flags); - return jiffies_to_nsecs(time); + return time; } EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); @@ -1503,7 +1504,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 = ktime_to_ns(ktime_get()); INIT_WORK(&dev->power.work, pm_runtime_work); dev->power.timer_expires = 0; diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index d713738..96c8a22 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -125,9 +125,12 @@ static ssize_t runtime_active_time_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; + u64 tmp; spin_lock_irq(&dev->power.lock); update_pm_runtime_accounting(dev); - ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies)); + tmp = dev->power.active_time; + do_div(tmp, NSEC_PER_MSEC); + ret = sprintf(buf, "%llu\n", tmp); spin_unlock_irq(&dev->power.lock); return ret; } @@ -138,10 +141,12 @@ static ssize_t runtime_suspended_time_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; + u64 tmp; spin_lock_irq(&dev->power.lock); update_pm_runtime_accounting(dev); - ret = sprintf(buf, "%i\n", - jiffies_to_msecs(dev->power.suspended_jiffies)); + tmp = dev->power.suspended_time; + do_div(tmp, NSEC_PER_MSEC); + ret = sprintf(buf, "%llu\n", tmp); spin_unlock_irq(&dev->power.lock); return ret; } diff --git a/include/linux/pm.h b/include/linux/pm.h index e723b78..e5a34e2 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -632,9 +632,9 @@ struct dev_pm_info { int runtime_error; int autosuspend_delay; unsigned long last_busy; - unsigned long active_jiffies; - unsigned long suspended_jiffies; - unsigned long accounting_timestamp; + u64 active_time; + u64 suspended_time; + u64 accounting_timestamp; #endif struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ void (*set_latency_tolerance)(struct device *, s32);