From patchwork Fri Sep 29 12:34:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tvrtko Ursulin X-Patchwork-Id: 9977939 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE37D6034B for ; Fri, 29 Sep 2017 12:35:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C70E129858 for ; Fri, 29 Sep 2017 12:35:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA6AB2984F; Fri, 29 Sep 2017 12:35:26 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 284BB2984F for ; Fri, 29 Sep 2017 12:35:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CE2656EB8B; Fri, 29 Sep 2017 12:35:25 +0000 (UTC) X-Original-To: Intel-gfx@lists.freedesktop.org Delivered-To: Intel-gfx@lists.freedesktop.org Received: from mail-wr0-x244.google.com (mail-wr0-x244.google.com [IPv6:2a00:1450:400c:c0c::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 588896EB7E for ; Fri, 29 Sep 2017 12:35:16 +0000 (UTC) Received: by mail-wr0-x244.google.com with SMTP id 45so1196057wry.5 for ; Fri, 29 Sep 2017 05:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ursulin-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sJEagWAEHrl1KoGtd9A8zXpV3oz5p7gsG3I/YvIIJI0=; b=JSnMvC6rupfppCOjuKtgMr/UmgbAQo8Y3GWDNg6SHwxbWZaXjOzWLWGqWauS9+Xz+O JjHkX89831F07Vb0S4CXPNU7Tue4ivDmXtVF/Bcmo7QdpW4o1UA++euPBd/wDo+orimu oNsXC+MqDZ6Tevusvnc8KUO6/HgQSmn3cvi6l2tevv1qkXKQcxGtuXnd0Rhs8nS2r2My 5lNKBOFQYX65txQG5MuJgKvjnUnOFcybSsfMmtB0AqJ/xhPvkLgknhg3X1SGqCg3Weh6 nPd8xIsJ40mjBtcJnSW1MfDmVMl3fdQ5b5eEMM4jtv2SZA/DRN7KOQ5u8bRAx/Dmv0So qkKQ== 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=sJEagWAEHrl1KoGtd9A8zXpV3oz5p7gsG3I/YvIIJI0=; b=LuzlhYS1GROOi7q3uYEQqosVPuaS0PheKLHViLPTGVETIUVpqqFye1JEVDhcnLyxgo GA+TdL1Zq27RLDcLMTK8TkdIvpjthJ5gQCoZ0r+8i5CuMfJXTgqR2HMviRLqU5c4MFLf Ke93B2CpyCrO1mn8q+Jizrzo6awKtRogDa9taGzVpzpJTD7TrPak4YFReKPxoF6kdMAb LScnqrBGmSMZbQ8kksuf9kdntgleRQ7MfD7U/PL7YgDxw+bSVsgl5Hpkvwey5+yRZ6y4 jnnMGyQDzvRGAVC2/wJeaeDwJmkwDb1ejVFi+0v8jDPDZF4sR+VdwgN656i/W3G0h/ny pYEw== X-Gm-Message-State: AHPjjUgy5VBCfc3GrHarIby1Z+gZX2va7ICYck+5aaTw6BUgkLDUM+Fz HUxUuvj2wDFryyIrQAvs3wXEAn75 X-Google-Smtp-Source: AOwi7QCr97JwGhGVteeD0SfHzfSvxFDJZL/zWb9cnQatNgfmBhKOK/4IPS9PqHV1itckcrPkdTpsew== X-Received: by 10.223.134.157 with SMTP id 29mr7264216wrx.72.1506688514822; Fri, 29 Sep 2017 05:35:14 -0700 (PDT) Received: from t460p.intel ([95.146.151.158]) by smtp.gmail.com with ESMTPSA id j73sm8196637wmf.15.2017.09.29.05.35.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Sep 2017 05:35:14 -0700 (PDT) From: Tvrtko Ursulin X-Google-Original-From: Tvrtko Ursulin To: Intel-gfx@lists.freedesktop.org Date: Fri, 29 Sep 2017 13:34:59 +0100 Message-Id: <20170929123500.3186-10-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170929123500.3186-1-tvrtko.ursulin@linux.intel.com> References: <20170929123500.3186-1-tvrtko.ursulin@linux.intel.com> Subject: [Intel-gfx] [PATCH 09/10] drm/i915: Convert intel_rc6_residency_us to ns X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Tvrtko Ursulin Will be used for exposing the PMU counters. v2: * Move intel_runtime_pm_get/put to the callers. (Chris Wilson) * Restore full unit conversion precision. Signed-off-by: Tvrtko Ursulin Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_drv.h | 8 +++++++- drivers/gpu/drm/i915/i915_sysfs.c | 9 +++++++-- drivers/gpu/drm/i915/intel_pm.c | 27 +++++++++++++-------------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a88f5be0229c..d5d0a8dbcf67 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -4162,11 +4162,17 @@ void vlv_phy_reset_lanes(struct intel_encoder *encoder); int intel_gpu_freq(struct drm_i915_private *dev_priv, int val); int intel_freq_opcode(struct drm_i915_private *dev_priv, int val); -u64 intel_rc6_residency_us(struct drm_i915_private *dev_priv, +u64 intel_rc6_residency_ns(struct drm_i915_private *dev_priv, const i915_reg_t reg); u32 intel_get_cagf(struct drm_i915_private *dev_priv, u32 rpstat1); +static inline u64 intel_rc6_residency_us(struct drm_i915_private *dev_priv, + const i915_reg_t reg) +{ + return DIV_ROUND_UP_ULL(intel_rc6_residency_ns(dev_priv, reg), 1000); +} + #define I915_READ8(reg) dev_priv->uncore.funcs.mmio_readb(dev_priv, (reg), true) #define I915_WRITE8(reg, val) dev_priv->uncore.funcs.mmio_writeb(dev_priv, (reg), (val), true) diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index 3bcf1c8c0dd9..2f74ae55332d 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c @@ -42,8 +42,13 @@ static inline struct drm_i915_private *kdev_minor_to_i915(struct device *kdev) static u32 calc_residency(struct drm_i915_private *dev_priv, i915_reg_t reg) { - return DIV_ROUND_CLOSEST_ULL(intel_rc6_residency_us(dev_priv, reg), - 1000); + u64 res; + + intel_runtime_pm_get(dev_priv); + res = intel_rc6_residency_us(dev_priv, reg); + intel_runtime_pm_put(dev_priv); + + return DIV_ROUND_CLOSEST_ULL(res, 1000); } static ssize_t diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index c682ae4c98e9..e765c553e17e 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -9343,36 +9343,35 @@ static u64 vlv_residency_raw(struct drm_i915_private *dev_priv, return lower | (u64)upper << 8; } -u64 intel_rc6_residency_us(struct drm_i915_private *dev_priv, +u64 intel_rc6_residency_ns(struct drm_i915_private *dev_priv, const i915_reg_t reg) { - u64 time_hw, units, div; + u64 time_hw; + u32 mul, div; if (!intel_enable_rc6()) return 0; - intel_runtime_pm_get(dev_priv); - /* On VLV and CHV, residency time is in CZ units rather than 1.28us */ if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { - units = 1000; + mul = 1000000; div = dev_priv->czclk_freq; - time_hw = vlv_residency_raw(dev_priv, reg); - } else if (IS_GEN9_LP(dev_priv)) { - units = 1000; - div = 1200; /* 833.33ns */ - time_hw = I915_READ(reg); } else { - units = 128000; /* 1.28us */ - div = 100000; + /* 833.33ns units on Gen9LP, 1.28us elsewhere. */ + if (IS_GEN9_LP(dev_priv)) { + mul = 10000; + div = 12; + } else { + mul = 1280; + div = 1; + } time_hw = I915_READ(reg); } - intel_runtime_pm_put(dev_priv); - return DIV_ROUND_UP_ULL(time_hw * units, div); + return DIV_ROUND_UP_ULL(time_hw * mul, div); } u32 intel_get_cagf(struct drm_i915_private *dev_priv, u32 rpstat)