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. */