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: 154388 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp750473ljp; Fri, 21 Dec 2018 02:34:10 -0800 (PST) X-Google-Smtp-Source: ALg8bN7AsHhuCDIOHS3X6Nuz+oVE3qjmlUWwAEvRNmJ16i8NwTrb974UylObvjmSDiJ9jtprX6cB X-Received: by 2002:a63:a91a:: with SMTP id u26mr1815001pge.349.1545388450454; Fri, 21 Dec 2018 02:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545388450; cv=none; d=google.com; s=arc-20160816; b=B7KIYesCa/m+sbPlWmV082B911v6xwZO2Gluwz+S30EBL0cH3MhdJL/2l4wsrAp+yd iPBlhN7RIeg+p9+zEb5N5maQU6P5drbjeBUMw1bf9RrZ3Ep16mPzs2Nie3KFYImRYWQo tkm6JQ9I9GR5PfY3aTrP1USCtkB92X1sXVJrSFb9EVXdvsnHorf5H7QudoLUrwxKOoPc qncxU42bsnhLlWOWC1uDBPxcfvRQtRTWeW8OJp+gnpW7BsR0U66Fzrd1EM3W5MUjtDlO EqsAar+UqKNGXOQ04Ri49ylTVeDsqV4rzzNELHaio9zMN78nTZopyds/2koC7oPpx15y EZuw== 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=vhYWlU36PKEBPCWfg+y/jovhINShmKXiUFstQKgZjEM=; b=diLhLFKk6lj6mBQxxcSMrl/RpBOZ+1P3tAUjbl6Hjm1lNO8FbN2QtAqSd8FSwP63ys OnhLY4UDALBDtAflupjVgDaMqPW1Cx/5Z9e8VHsexkGfb1xtFmw72DmeMfP3/gtrmAXs Qe/R/nRyxapzaiXzHwP1Z/puzM6inFo5mqhPa92Hp61UC7jMjt1Pv5s9qpr2KZTEWEJA cEchdfq5LJm2ZYXXoJBZRxkv+/+22XoIx2v/EnATasjSxnRqvtGT4KItRnbdB68WPhLW 397BlnsWXkPXbsJ7SLydrqgSF4HZX2Q0gdFt+JKM1q7hNPdEg5y/1VjUUOhbxD36l7AL eHwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MIDo50OU; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 f13si21289358plm.393.2018.12.21.02.34.10; Fri, 21 Dec 2018 02:34:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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=MIDo50OU; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S2389784AbeLUKeI (ORCPT + 11 others); Fri, 21 Dec 2018 05:34:08 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43919 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389772AbeLUKeH (ORCPT ); Fri, 21 Dec 2018 05:34:07 -0500 Received: by mail-wr1-f67.google.com with SMTP id r10so4687079wrs.10 for ; Fri, 21 Dec 2018 02:34:06 -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=vhYWlU36PKEBPCWfg+y/jovhINShmKXiUFstQKgZjEM=; b=MIDo50OUD6EVgxLArZ7ef4EB8Ao67bD0d2dLb9z9AhHaovP48bbnR4JIC/ORMmFuH/ RwHpphTGoOeZIX5rqtzH8UesZ/lVyXzxveT78VNx7urODpWwcVM9IOmry7c/xizCZKNg rQViwv3I+inpsqq9xmGU0wMiLpcmrYSj6U7EM= 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=ai0RYxCkyBK9a4VvUX1Ytq3zss0UM8t/Lm4XuZ1lcrqthSIGh5ypYaJ/TxZG9Dgi7Q FKTNI/+yR5V18GATlhMy+57Q/W8nBDJ00l7vqKbo80Xp/17RjH+u8zOU7x88+oKKfBf+ F2IPuSvs8esmkt877cr4eqzEhbGmO1S1b0bSxqRWWg9R4au9bbSLTdh8QA9ek1XItxCw EaPn5sB4LHDjIN4Jt2PopwosHzfeq6VGUifzoxhzuUyk5AnDaGnNT/P0Ay1UZhATxUgD z1xmUfbr55NQUlqKgriaV4a5+59kOCn+DseLb4P3z6AW4Ag7zJ9D9Zj+le06I7+waXkH pytw== X-Gm-Message-State: AJcUukdMXGhORAl6OcM76Z2LG5X9gzcq14C0Ay0LamjnuZ0JZ+XuKYWa X8GltT7IbgNufWdYtOPoFYbXDaT0s1N8/w== 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 Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH v5 2/3] drm/i915: Move on the new pm runtime interface 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> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 --- drivers/gpu/drm/i915/i915_pmu.c | 16 ++++++---------- drivers/gpu/drm/i915/i915_pmu.h | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Tvrtko Ursulin 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. */