From patchwork Tue Dec 18 14:55:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154148 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3805593ljp; Tue, 18 Dec 2018 06:55:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/UTa+DEf+Ma49q+f8eSKwiglEPMJejzXZV8B2exEpOobXZmBcSTeGsqijaXBZrEsOB0WYKu X-Received: by 2002:a17:902:bd46:: with SMTP id b6mr16585063plx.231.1545144944583; Tue, 18 Dec 2018 06:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545144944; cv=none; d=google.com; s=arc-20160816; b=jmx4vMwh57S7pqLTqNt9cT0h2eix4lGwPfLFJS48dXMeBB4uzojwOWJ4KpiIKPDFYf cpXqVJq3kR1BzAVfpfWot/n9DTbbtti4j6/m57HWp5rtHo57nqrDdYP0c8UrOLN2u7c0 M6hHT1mn0qEMy913WV56/syRsNtvDEsSqcVEH2o/u5WxWXzH0K+B6XevJ7RoTkyCeYyn 8XBkr2p4OkQwbHGgOpuVsgynHmPH9QeAZaNNaHB6ONQ/eXePrAtE9FGUwsJwKaJceMHn TfCMj8C2iKcEtP7Em0XpuoyhY5viSGSKGhJhmU/DbAglQzix1Jl7NZUWjImgUKDwpIY/ H1Dw== 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=NjMh1hlHnaU/XWOpjKkttorbhNkixdC3H52jnc/A7+E=; b=pvUkMMK26KsUOU64Pb6+5Hc38LJh9R479INmgHTxlyvMoK91vpgtFnrhlFokttL/Qd Jg0MAJicwJurz0RMsxxRs+Fhs0vPUx3X7QoZpxm1DgSwLyVDX1ADkfR0qkeealoaPFdZ 5B8/BvgEHOgkIQrDnX+bsscxABQAriqcAO4ZFtT9utpp3YPrcEafhvgVY02uCVNJ/kgS B3LxabDIZq5f9GMB1FXXiqZq6HO5U18k8TKN2C8Aqx2nQUK89aLBFxJ9xpMi40FH+dio EwkAHH6ePpNocXEjxp2gaeq3L1P1+gsdhpUVZbVEKMOXEJwPM3+bhsV7BQ0yIlkr73IV JnUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jcmFxoVW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 m39si13613654plg.315.2018.12.18.06.55.44; Tue, 18 Dec 2018 06:55:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=jcmFxoVW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726817AbeLROzm (ORCPT + 31 others); Tue, 18 Dec 2018 09:55:42 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:50429 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbeLROzh (ORCPT ); Tue, 18 Dec 2018 09:55:37 -0500 Received: by mail-wm1-f66.google.com with SMTP id n190so2978280wmd.0 for ; Tue, 18 Dec 2018 06:55:35 -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=NjMh1hlHnaU/XWOpjKkttorbhNkixdC3H52jnc/A7+E=; b=jcmFxoVWCkT1rXUrzn8599cUiFQ6td+R2XheLYPnKmboKxVYTulP1VrUyIhoVGpTuU 38dBbP/4Nb72UBugkBCjG5xnnXFEbH7e8e5/f7HszVOPAbXk2zGR5w/En6qACAOVDx4g 6eUl9U8DHRiqGurcYUGHKJsTPd+JAASXBqZMs= 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=NjMh1hlHnaU/XWOpjKkttorbhNkixdC3H52jnc/A7+E=; b=oYseG8+oDTMFV3lcQdKCSsdlhJhMNJzI9xLu6KEgqRulmAh1R95qfIif3cCtK7A3PN HagEFdI7JnHPoG6u7qEURnznWjlR92Q/j90XoeSsMVTQCCfDkowT0v0PFn5GkJthGCsU w3E5PTd6ZA5cq6FHTxx2hMVVJfx7Xt6p+D0zCz+tGYXLMGPq4/uU9P0svj/AFOtx2buZ VF+csDp8O4C3U5m4dA4GCGKa1+bo/DrHA4LOG/7rmGObueMf+HrwnW9yG9Sk7jzlGIp9 6hr4s7jHED3CRLkhPvVRgRUCj8zWejHWIj75qauTdLYMJU09aiRgbM7lNG07h6xs1xhH FV/Q== X-Gm-Message-State: AA+aEWYvYH/19c5qbPYV6bZUXdAssXUMFihvETL11c80S8rLt9K7467y 8I3TV8q0omJdN74RUk9BK6zVhw== X-Received: by 2002:a1c:c008:: with SMTP id q8mr3208517wmf.99.1545144934224; Tue, 18 Dec 2018 06:55:34 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:85e9:25c5:6cbd:73e9]) by smtp.gmail.com with ESMTPSA id n20sm1579956wmi.11.2018.12.18.06.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Dec 2018 06:55:33 -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: [RFC 2/3] drm/i915: Move on the new pm runtime interface Date: Tue, 18 Dec 2018 15:55:22 +0100 Message-Id: <1545144923-31546-3-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545144923-31546-1-git-send-email-vincent.guittot@linaro.org> References: <1545144923-31546-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 18 ++++++++---------- drivers/gpu/drm/i915/i915_pmu.h | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) -- 2.7.4 diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index d6c8f8f..ebc49ea 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,15 @@ 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) { + val = pm_runtime_accounted_time_get(kdev, RPM_SUSPENDED, true); + if (pm_runtime_status_suspended(kdev)) { if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) - i915->pmu.suspended_jiffies_last = - kdev->power.suspended_jiffies; + i915->pmu.suspended_time_last = + pm_runtime_accounted_time_get(kdev, + RPM_SUSPENDED, + false); - val = kdev->power.suspended_jiffies - - i915->pmu.suspended_jiffies_last; - val += jiffies - kdev->power.accounting_timestamp; - - 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 +509,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 Tue Dec 18 14:55: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: 154147 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3805553ljp; Tue, 18 Dec 2018 06:55:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/VZ4Ds7Oam+Ms2cMsmIW4xuZO9B+/vQ6AVPcMdBAAm7ypblmvCmfmD8CFXiWVp9uhV8f6xt X-Received: by 2002:a62:3a04:: with SMTP id h4mr16761192pfa.119.1545144942215; Tue, 18 Dec 2018 06:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545144942; cv=none; d=google.com; s=arc-20160816; b=IrHyj3UtvHWN7GT1Tcc0uU401q0RNlFCAc6T2WW7V+4O+qftTfITIvIp2ajSnvM9Ys dCPVpxXesFTnkBJs6YymKBwOvAPrroiZG5Sx1mGrw3+hRijkLetwqc1Lq4q1foxXx27P H0xiK5tmbYpi6pFAGbTB3KWLzESj1liRxAJTTEIApdbVtQ4l1tI63FWcuhmvF0zz/CaB nkes406ATzXrCOnQ+hY/NM62uNob27VF3lgI//QI9YnYha7NCQCBpURxbeahOipqvqXJ xjvMQqFBxnsrJxgwrX2OWt1Udfh1oWNDHeW7oSuKndfFysxo+syI9X+X/8HKYDRMp3cn 56Ow== 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=gUwbwmeADuEc2X4Ia538ZUBklszWDge9MdrlOIVIBqg=; b=ASbXiqeYTE8Ssh+0xWGNpuTNxuTtIpxG1mr3XoS/HZM5s35ZZJTgKHTgMsSRHpPuAR lJIsopWAytIYw2DCUbHOLSh7hjZgzp3tfw5D5F8ieqiwpPUNL89gIsQGjf6RnTPHVtfm X3m07667AqWzUnpvDgdpovgnZQyKnRtsA/xCfjqTX3fycpabpa6fNg9rFI0RPPayS6ng t7h9SRbbe2DlOXHG+KA3eIyHVsGjdsJMOtI7cl4tHK+Cjift/1oQgioWutPWJDuykYOz HB9p0YOhTJfsxLsRrzaLfcUna8MSL9iQ/R+/FeP5jaq2W9HZ0aa4Psj5MxdTuWE0H7Hg Ltmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YpMcJy+o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 b19si14641632pfm.100.2018.12.18.06.55.41; Tue, 18 Dec 2018 06:55:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=YpMcJy+o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726802AbeLROzk (ORCPT + 31 others); Tue, 18 Dec 2018 09:55:40 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43990 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbeLROzh (ORCPT ); Tue, 18 Dec 2018 09:55:37 -0500 Received: by mail-wr1-f67.google.com with SMTP id r10so16188876wrs.10 for ; Tue, 18 Dec 2018 06:55:36 -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=gUwbwmeADuEc2X4Ia538ZUBklszWDge9MdrlOIVIBqg=; b=YpMcJy+oov1I6Sv6Xa3HOejixQCR0FjNZ6zfWc7eRx7Y7qeUibf3JeP+h6MhGzGrUe gxnsBy8U9VN0BFhJl9S4R1nHxIaRNBeHqmfqPnMwQLbqsYcxUkS9Cmb+F/fLq36EjRCF nrmRCqAMrzG9W9zj8uClaRVMDh9YpyCl6MHSg= 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=gUwbwmeADuEc2X4Ia538ZUBklszWDge9MdrlOIVIBqg=; b=WMFVDgxey8QKEW1kernhmDuk2suputArHKRqbiouDeygQm/AELQtu5OrnmlbzL7i7b VrHKYjgR2yK9V26qB4AeNPw6SGF/tsIub0dyfGQrav7SwZ1Xvw4UxYAM0V4ziB5WNlOs rXfbsTMIBuMKO8nYrtRuqRiNc3Yrkm7j7AZrgFz17rmUZZwSpvPK7l+kJMXPWYtrSQxr zbahxC5IIczPaoxzA6ystB5OyJg/qinCClpIjhT+ElX7T4zs7vMHRNsx4A/0oVaaLc7I kPjyhd3AclEUqR7doTSdVMoytzPZyabsTIAvXaCgOJXiIrQAcp6bhlp9loCY5GvTuVvr +awQ== X-Gm-Message-State: AA+aEWanmM/bUCuboWZI9b2RotpzvgoC+ijJq0BlfITJrS0kh7Be7Jep 2xeRRq2rs/WYcL6jLEh1O6Sh9Q== X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr14781326wrq.38.1545144935389; Tue, 18 Dec 2018 06:55:35 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:85e9:25c5:6cbd:73e9]) by smtp.gmail.com with ESMTPSA id n20sm1579956wmi.11.2018.12.18.06.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Dec 2018 06:55:34 -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 3/3] PM/runtime:Replace jiffies based accounting with ktime based accounting Date: Tue, 18 Dec 2018 15:55:23 +0100 Message-Id: <1545144923-31546-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545144923-31546-1-git-send-email-vincent.guittot@linaro.org> References: <1545144923-31546-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 10 +++++----- drivers/base/power/sysfs.c | 11 ++++++++--- include/linux/pm.h | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 6461469..5c18e28 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -66,8 +66,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; @@ -77,9 +77,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) @@ -1517,7 +1517,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 0bd9de1..3d2cbf9 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -633,9 +633,9 @@ struct dev_pm_info { int runtime_error; int autosuspend_delay; u64 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);