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: 154336 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6237927ljp; Thu, 20 Dec 2018 06:16:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/URUEbnPJUlINQy9vKg8/2V3mlV9IlG3ipKLh36Z6IH84wO3BSOwUQIlM/xJTWRcQaaR13o X-Received: by 2002:a62:4181:: with SMTP id g1mr24382223pfd.45.1545315398197; Thu, 20 Dec 2018 06:16:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545315398; cv=none; d=google.com; s=arc-20160816; b=b2Nx7OJjv4Z9gjRiemVRWI0My9/aeQ1mwcd1dsCeQF9t/tbo8JeQaPP3AF+TT6mgSz 5f8w+0ESdoV5i4uBZ9RTV3TWgc10s/mfApHFx2Tox4UiszHBx+/nQoG4mPnc2D/t+PQ8 PfFN+vMsoacZJyrlmmIdN9CtNSnHrwG5wiwTomDClbxdZupGm/osL++LeYz9CMCYbhlw UNzk9zRWQfyQ656xBa++LC6JFx+WI9vsSXvVEu7wniDSBia75qOYAZHN0cczFaCN5RcN uUQd2S1jzjpQnuzJ5Eq/08bCLje0Bg3CDu3CJVaAMx1fNHzdjUN0qlrfz9vCcIgmhBS9 SIYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:delivered-to; bh=UXgqEw400iR3KwAIXEwyYlRx1qZvb0gRoRXIA/vVb2E=; b=CgNv1vKjteALlp4rx5StaOaR9EzOAk3TZPQ99yVOXEcJVAIS9x2/UxrzFU3pnTgFZW J5IW52Xw9SrhlE+njdXDdwV3NllN7ZUOQbSxIz48tJWIIMxHHSxhd1ccNiwRsRgK2pSv iemsESaNupfwyAYwctnuDc3YTmcN6kzDgVNzubWMNxXOS30+nQlng8z3PEf4AvPZDmY8 8X2ukWpBVMOYDj67KCbLPSfnx6gpYhiZHDehxkL3n/HPzxTeXojwdgwnKq8Arye1q0E9 9DfIKunHEIKAWlDKpbs67trAUJ1Eu67vK1JegAtPyxm4GnzfS/LqLpcjY/o2ZEngYHuJ g32Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id r8si17650489plo.203.2018.12.20.06.16.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 06:16:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C77926F3C1; Thu, 20 Dec 2018 14:16:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 580D16F3C2 for ; Thu, 20 Dec 2018 14:16:33 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id q18so1924600wrx.9 for ; Thu, 20 Dec 2018 06:16:33 -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=8H/YiHauv71s0EVIedV1buJib0rVCedGsQtekdc1nA8=; b=IwtI++xTUhdF6HSC/tp+MtEpMZkm8xrJotZtjIjvI+ZRv2t4fvUH47Yzgv8KIy3EE2 gCr/ZtwbLdAsnLyBahYxqhDIyMmtBHGc7byrmT6gdOx8UpL6mVYRQ/AtBB83R9vjsTQV oYaBB/ImJryHyEBmAeClWkJaORz2o7vZZwkDmY294JzT4XJEsqZEi4htTTzq3s6Qy+Db m/O25HTiXYpnnBxZgdgUdaiN8Zqoxxw4bU9jmkukYSgOdltOPqy8/XPpDD+wrwH3FIqO R6i1uh/VBTfZqySscKh+r0AgK5d8UttFSFdJ4q7FLGZWGn7ZF9HGAPfZJCGWuvEibyf/ mDaQ== X-Gm-Message-State: AA+aEWYbyxVGbcjGh+m1I5B5562iBNB1GZmNJFcw7/K+O9iD4tsspx0F SZ9bYBIFhVoH2rKSoi/mJrxCjA== 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 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> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, Vincent Guittot MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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: 154337 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6238501ljp; Thu, 20 Dec 2018 06:17:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/W3itDcKezs6yCx8+jKW5CsK+aNUgiQQjTDGbVg9oFqUAgu+sZYCjG8XI2e5pQptT/Y1V+S X-Received: by 2002:a63:9712:: with SMTP id n18mr6693022pge.295.1545315425584; Thu, 20 Dec 2018 06:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545315425; cv=none; d=google.com; s=arc-20160816; b=MkwCwoNOr6WAS+enObcfEieFS1g4IKVyTJrAL/Sr3k8gXUA1BoJ7SJAQGuTJoylP8h 5ldm7afHUy8A5Merx0z+Na1BE1oMXMZhC094Y+dDVdVkAl1W4mEsFosdEGrq+HovqNh+ iS8BYiiOSWSLmMuN7E6rWW1z4eD02bPRIY0sB+WYn1B2lkCpepNSWlfuUgltlH+hVRkT PvknR8BoI8fDc+8UWv+YGe+aU/pXBJ7qOcL2oO+vTG6+jRhpYscoQ6QAp5roArScy7Jk K6XXiYofg3xoFQRoh66wT34ul1FYzJYnoFf3psOs/pGgDMH4wIJRFboF5OM/RcgwaYQn pA5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to; bh=ncOdOW+mAjvCcdOVe0mODFnmyK2pHzHh37OOOKZ32Mw=; b=WgaBw6M1HkvFmtxzwv3WYB7ksz1mBE2B5s6fIYSiNRgI7nNWt/QrUb/lomzqyYFIkT OfdEcqfmvTO+zKj8RV5dSLHeqDGktkg0CjjmEiYub0PRESRCWkOoNOQRCMNTxD8yYLCS HkJSW7G1fqC8Q+EAfSBMewiWvrzJXexaEqsWIoKq6OHd4l4RYpGQ5dmU41pyAJE1fdDS 4pfpBsVq8IxQxhI4rWXq6Tm0H4Tmdchn9rBvwN/oQJw/yUEA72hShE6p94W4UUTezbPP TR/8SpGBFR9FAB+F+4KOahF+jsMC/Cne44+/mEsPOsGGKAXeJSUkBYFxQo5Q19DQtnY5 agog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id n28si19585962pfb.88.2018.12.20.06.17.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 06:17:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D19A6F3C7; Thu, 20 Dec 2018 14:17:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 1DAE96F3C8 for ; Thu, 20 Dec 2018 14:17:03 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id m1so2221184wml.2 for ; Thu, 20 Dec 2018 06:17:03 -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; bh=dl0vWZ2OmuLRkr6rXUIz7t6LbyxfogMj8WkEhaEhsA0=; b=DltAS1mCzqBlOinWZcLmffRslEG+f0d7mu/8Ei35nRmEUBqbBVzsYe0zX9E8Ds5+VG HqcYrgK6gYSLyftLWbVDu+Zr+EjKv0chHR7uqtiCU/6XVsvJI50xwOHoqPvomhzNedHw 4RVHGXk+/WGrRhBT+REH1nCg5YJXlPELytrnBaRc6shrRsGMBWz9Sflq3k6Hyr5Vsvoo axOeVAl8cdZIbRp9ARTQm4UY+UqxlFiyDLalsIFnfmNDfV0GsRdkA1eKwcOHAcHwBX1A CIctsOrwpA7n8StDbTWK4PQ3FvKKsvDnmSMxYHFGVoRABtay2frSd/kwVqxl3S3mvs0u UYYQ== X-Gm-Message-State: AA+aEWbYDetpL4TAJiINJLJQKlRtdVhg3ednqHRilCqJGojaTN/JPUsf fIX/QPfhnCw3SbzryA8MKk5GFQ== 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, Vincent Guittot MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use the new pm runtime interface to get the accounted suspended time: pm_runtime_accounted_time_get() Signed-off-by: Vincent Guittot --- 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: 154338 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6238700ljp; Thu, 20 Dec 2018 06:17:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/XzlkXOtcFFfASJ8ygqt9dZqvprXolZFWPjtF0eFEJVzTUV7YLux7KdgaLsg/xWUh7bbD+F X-Received: by 2002:aa7:868f:: with SMTP id d15mr24155797pfo.225.1545315434621; Thu, 20 Dec 2018 06:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545315434; cv=none; d=google.com; s=arc-20160816; b=F9IwjXL1sopE8NaTkSxvjIJHSPIkzCia7NNByxG98ufDAMphSPKozV565MShMJZuSs Cz2/0SfaawcSf8QC9iPdojC10WNYKp0uRL+kAo6K+w1ECWQPi7ZvQVl0ApTo13uFAWL1 q5HRnWZK8FbXKebImMdLDgxjF7d8Sp6eL0ghz5Ldij/SRcMoFbgah9D2F89uqVW02c4s jo/4OFagyh9ZoeJWuhnfUGDJ2LfDlZEY4jUELLzCHr6dQ3oqhQvu+J/Tm7ti8mdTRmY+ r8Aq0xs+Q19x8QtTV90He57k5KqVN/TvGBqYYRE1HLl81HUVYKcWv+8VPII1O9G5/u+C 861w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to; bh=NyM3K8uh/pUoGlE2EussyPqXEIJ17a+ZErdwR0Nz5ec=; b=j0umjy/JyN7tSrBqR6uKH6OiXkeaEUurZ21NNoWXDqXPwZTvlfm36YytOCIx+jUlhm 6D/hKOii9mTE6Rxq+Z5j1Vndulp0GQ/TAwWIc4jAhUthy/uqkpm5aU+4b0iaMMNMkh+a TkC25RtH0Zb2JrWuCTfwm+CFT8ubyHvHyWu9fXO8GI1EQlm77H4YZY94VQ8RS80kKtsB s1BuzPObzx2u6CGQuzfdfMvD0HvuTO7ATzJBd0USQUtL/Y8rW/gXT9xjw4pJmF2TB3q3 Erp2h+5zgYswDeo4mUqWsKhkkjr8EMTB6jpWAuswRKEVDPtus1W1OnXg1PgS4Bkz8ned V2yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 26si19191209pgu.190.2018.12.20.06.17.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 06:17:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5B266F3CA; Thu, 20 Dec 2018 14:17:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id C17846F3C9 for ; Thu, 20 Dec 2018 14:17:10 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id c126so2371772wmh.0 for ; Thu, 20 Dec 2018 06:17:10 -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; bh=Knn4iUcnejv9TyDbBm0a94Rk0LLVciIk4+jKF5JXBmY=; b=GtAAlEwjj8TEjKtS2zu6bA03pjD0nEkZ9Dm1YvcF/GJ2HrE26AdQkzh/orlVOQpPRw arjIKovMBjMdL3faQusERQ1ffay5NnRBRasUvOQIn+pl/M20IuKOeAG3798/n3O1yc7b Sa+QS/3P/zgI0gq2Dfv9X3tp9UTqVfV8a6cj9rc+H7PNUriBBRp13vB2a21SaDDCAdKO zpm1B6bDdAcAHVokhAbDghf2SWZ1Y118yFNLTWIDptgztMDD0jpogJ7vE2CuxytFnlqV teh8cPTSSSVyPnfs8M6PhLRk3LrT6TVlFvV25y08R2eozt/vUkqgeIXDT2WP2pveALDt XouA== X-Gm-Message-State: AA+aEWZ0SZCO4lcCrTdRLbEFzKSNxdxUFar6uhHIuHx19j1XsXhqkJxr emzRLWKKZmBS7waPqo0hsaN7SQ== 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 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, Vincent Guittot MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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);