]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm/i915: Move residency calculation into intel_pm.c
authorMika Kuoppala <mika.kuoppala@linux.intel.com>
Wed, 15 Mar 2017 15:42:59 +0000 (17:42 +0200)
committerMika Kuoppala <mika.kuoppala@intel.com>
Thu, 16 Mar 2017 10:28:28 +0000 (12:28 +0200)
Plan is to make generic residency calculation utility
function for usage outside of sysfs. As a first step
move residency calculation into intel_pm.c

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_sysfs.c
drivers/gpu/drm/i915/intel_pm.c

index 5156bcc59dea08307e0d11cf568ab17089c154e2..9f4264a461138e00038bf774f57fb5b7c686bd7e 100644 (file)
@@ -3879,6 +3879,8 @@ 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);
+u32 intel_rc6_residency(struct drm_i915_private *dev_priv,
+                       i915_reg_t reg);
 
 #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)
index af0ac9f261fd271f74e3a3b93d128420f0e9c75d..ab723e3403d3bc5d82d12ac46da6dd28272661b5 100644 (file)
@@ -42,32 +42,7 @@ 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)
 {
-       u64 raw_time; /* 32b value may overflow during fixed point math */
-       u64 units = 128ULL, div = 100000ULL;
-       u32 ret;
-
-       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 = 1;
-               div = dev_priv->czclk_freq;
-
-               if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
-                       units <<= 8;
-       } else if (IS_GEN9_LP(dev_priv)) {
-               units = 1;
-               div = 1200;             /* 833.33ns */
-       }
-
-       raw_time = I915_READ(reg) * units;
-       ret = DIV_ROUND_UP_ULL(raw_time, div);
-
-       intel_runtime_pm_put(dev_priv);
-       return ret;
+       return intel_rc6_residency(dev_priv, reg);
 }
 
 static ssize_t
index 2ca38ae4421ed02656d9601f61f24a7fff18a1f5..a4a2c231ba3bf651bfc57e87c42c60be0a47b443 100644 (file)
@@ -8349,3 +8349,34 @@ void intel_pm_setup(struct drm_i915_private *dev_priv)
        dev_priv->pm.suspended = false;
        atomic_set(&dev_priv->pm.wakeref_count, 0);
 }
+
+u32 intel_rc6_residency(struct drm_i915_private *dev_priv,
+                       i915_reg_t reg)
+{
+       u64 raw_time; /* 32b value may overflow during fixed point math */
+       u64 units = 128ULL, div = 100000ULL;
+       u32 ret;
+
+       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 = 1;
+               div = dev_priv->czclk_freq;
+
+               if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
+                       units <<= 8;
+       } else if (IS_GEN9_LP(dev_priv)) {
+               units = 1;
+               div = 1200;             /* 833.33ns */
+       }
+
+       raw_time = I915_READ(reg) * units;
+       ret = DIV_ROUND_UP_ULL(raw_time, div);
+
+       intel_runtime_pm_put(dev_priv);
+       return ret;
+}