From patchwork Fri Dec 21 10:33:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10740299 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 74E1F746 for ; Fri, 21 Dec 2018 10:34:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 649A32855E for ; Fri, 21 Dec 2018 10:34:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 588D7285E1; Fri, 21 Dec 2018 10:34:17 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2FC9A2855E for ; Fri, 21 Dec 2018 10:34:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F3436F5C0; Fri, 21 Dec 2018 10:34:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id C855E6E007 for ; Fri, 21 Dec 2018 10:34:05 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id l9so4677322wrt.13 for ; Fri, 21 Dec 2018 02:34:05 -0800 (PST) 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=Ep7ki1gNWA79DVfUoUUmYu7v+nAqJfeGtUHFVJPz20Y=; b=VfAm1C0tA1rV3NKnXgfhREJ0Ou59YL6Vvj4sFof2hIdcgP/peKrMuVgBa41atwSz+6 qvXpCaKxdGfkwjMpUku/JSqHLNBoQF1+wNBKGLB8M69j4xi1HMrYb12DGjXFYA/JyjCv jSc6mITCqNUankWhS14yjXo5XstH1SEaBSLzZce1GLlhGRI62dbsQpMy/IiuA9BCDVc4 wl787mOrv+ejCE+2DF1nHqwjO+WT1Pt59h3L7nPBs2D5SKOa5n9jCaDgfx2PsT7psaQe 8DsLj1enlHjJpTso0DyAC1mcNz61DI2VmnMuy3BPz3XabwPW6oZ7GUOSQFK8ZB3WBd/5 x9OA== X-Gm-Message-State: AJcUukd31bsfKPKy5U23qC9QvFLCTFNabd1HBI6opRlE6up/Ld4p/Byn Q/lIaDfYJW61DwMb9AgWbXY6DA== X-Google-Smtp-Source: ALg8bN4wjkJW3YmjRm7yuLqlqUPIK2Y/fHiGy1wakXSLaRrbSjXoVQZEO/6eTCscAFtVLPpsgClsmg== X-Received: by 2002:a5d:528e:: with SMTP id c14mr1974240wrv.236.1545388444380; Fri, 21 Dec 2018 02:34:04 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:ac05:2372:f02d:b03f]) by smtp.gmail.com with ESMTPSA id h10sm10573685wmf.44.2018.12.21.02.34.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Dec 2018 02:34:03 -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 Date: Fri, 21 Dec 2018 11:33:54 +0100 Message-Id: <1545388436-7489-2-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> References: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> Subject: [Intel-gfx] [PATCH v5 1/3] PM/runtime: Add a new interface to get accounted time X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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. Reviewed-by: Ulf Hansson Signed-off-by: Vincent Guittot --- 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 Fri Dec 21 10:33:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10740293 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 2C4F0746 for ; Fri, 21 Dec 2018 10:34:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C67A2855E for ; Fri, 21 Dec 2018 10:34:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CFBE285E1; Fri, 21 Dec 2018 10:34:14 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C7B102855E for ; Fri, 21 Dec 2018 10:34:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F1176E01C; Fri, 21 Dec 2018 10:34:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id E09286E007 for ; Fri, 21 Dec 2018 10:34:06 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id j2so4715896wrw.1 for ; Fri, 21 Dec 2018 02:34:06 -0800 (PST) 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=vhYWlU36PKEBPCWfg+y/jovhINShmKXiUFstQKgZjEM=; b=RK4aPoQbrRtE8hG36YucNs300KbY6pX8vrt8vCvEJugnSIFPptTMrq/QGmPxSEPnaf GPe8+BpMHZmpMV+Gdd8m5AwuY+tu0LqxoMlwZK822j4qqQdAlPsZaoDzkDlUdAbeEpEq d7rtjD/v34gEGQ31j/xpzSltUiQb9YJOV1Vf+hVvFpn2Rs9boQvxG/AtqFG3l/UDbvBN E3yELnnd+bzBigHaTowxavtEiQuqfi/XSsxaJIVB+snjamorhuY+qwuSuFpMuhsaseah IxVd20FwMZ1hblGSwwZwY+fnsOQMTHf+flS1SEIulhcwwquv1+sN16wJcpjre2JeUZjf 7TBw== X-Gm-Message-State: AJcUukeax8/Er34gHQak6xIGuCKsOYnK8CjQlp4PJCNg7hKECzayPbi/ o5y9To50ypVjSDmdouP8LjVXwA== X-Google-Smtp-Source: ALg8bN4rkuE9s4ovYN0PMaQ4hUXlMXfh/Z75T+PscgGWnGvSru5l7X8CPIksEEVTtl3LNVBIWgchsw== X-Received: by 2002:adf:ee46:: with SMTP id w6mr2034596wro.261.1545388445505; Fri, 21 Dec 2018 02:34:05 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:ac05:2372:f02d:b03f]) by smtp.gmail.com with ESMTPSA id h10sm10573685wmf.44.2018.12.21.02.34.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Dec 2018 02:34:04 -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 Date: Fri, 21 Dec 2018 11:33:55 +0100 Message-Id: <1545388436-7489-3-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> References: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> Subject: [Intel-gfx] [PATCH v5 2/3] drm/i915: Move on the new pm runtime interface X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Use the new pm runtime interface to get the accounted suspended time: pm_runtime_suspended_time(). This new interface helps to simplify and cleanup the code that computes __I915_SAMPLE_RC6_ESTIMATED and to remove direct access to internals of PM runtime. Reviewed-by: Ulf Hansson Signed-off-by: Vincent Guittot Reviewed-by: Tvrtko Ursulin --- 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 Fri Dec 21 10:33:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 10740295 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 0F11313BF for ; Fri, 21 Dec 2018 10:34:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B102855E for ; Fri, 21 Dec 2018 10:34:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E63A5285E1; Fri, 21 Dec 2018 10:34:14 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A67FC2855E for ; Fri, 21 Dec 2018 10:34:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 865CA6F5BC; Fri, 21 Dec 2018 10:34:09 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 75A3D6E01C for ; Fri, 21 Dec 2018 10:34:08 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id n190so4831882wmd.0 for ; Fri, 21 Dec 2018 02:34:08 -0800 (PST) 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=bPgIAywPM9tC5+7zzbz0/QmHiK8KUKT68feND5QntSw=; b=eZRcGp/tAUix+Av18Yf2H9FYDutAQ2vbK2Z7/+x/8G5qcvKvuUUG/krQpcN5SNqxh+ cVyaMIsFkjHtBgscTgcqakJPlcS2WRSLA2q2xOQazouN9VPSdPWTp/QMeCe8GcIyStzs +TE2T02xrR89arQekjSOWZ7zCd9pwrxWxXn7gAWIFXExa9XbFKocw8GalLRCTzfd295s n46jWo7HQWfdaeAMXAg3z8I76fBpBTG27bsSdmokjLFr4u234GLOpm9bWjC/Zftw51em n+knYOAkpezICZWxM+fcn4QN33mBMDBanWJEEclbBGFpQeUQg8IouDCiLtQaTuTNtzPp emwQ== X-Gm-Message-State: AA+aEWZftdbMDsmjBW5Q2h7b8ED3MiQu97jE2TM0Z32DiqECdmQGcnfr u1ym7fX5ofbjiQwQJef3gqaVBQ== X-Google-Smtp-Source: ALg8bN5V0fT9/T/ZMqUCNnA2Dyv9WjpfIr7MKFC5vro0wkNQIgjgeMOLqSK2w9vrlzzi1cmY/uKYHg== X-Received: by 2002:a1c:570d:: with SMTP id l13mr2344052wmb.139.1545388446921; Fri, 21 Dec 2018 02:34:06 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:ac05:2372:f02d:b03f]) by smtp.gmail.com with ESMTPSA id h10sm10573685wmf.44.2018.12.21.02.34.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 21 Dec 2018 02:34:06 -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 Date: Fri, 21 Dec 2018 11:33:56 +0100 Message-Id: <1545388436-7489-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> References: <1545388436-7489-1-git-send-email-vincent.guittot@linaro.org> Subject: [Intel-gfx] [PATCH v5 3/3] PM/runtime:Replace jiffies based accounting with ktime based accounting X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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. timekeeping is initialized before pm_runtime_init() so ktime_get() will be ready before first call. In fact, timekeeping_init() is called early in start_kernel() which is way before driver_init() (and that's when devices can start to be initialized) called from rest_init() via kernel_init_freeable() and do_basic_setup(). Signed-off-by: Thara Gopinath [move from ktime to raw nsec] Signed-off-by: Vincent Guittot Reviewed-by: Ulf Hansson --- 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);