Commit 48d1c812 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Mark up sysfs with rpm wakeref tracking

As sysfs has a simple pattern of taking a rpm wakeref around the user
access, we can track the local reference and drop it as soon as
possible.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: default avatarMika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190114142129.24398-5-chris@chris-wilson.co.uk
parent 183e260b
...@@ -42,11 +42,12 @@ static inline struct drm_i915_private *kdev_minor_to_i915(struct device *kdev) ...@@ -42,11 +42,12 @@ static inline struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
static u32 calc_residency(struct drm_i915_private *dev_priv, static u32 calc_residency(struct drm_i915_private *dev_priv,
i915_reg_t reg) i915_reg_t reg)
{ {
intel_wakeref_t wakeref;
u64 res; u64 res;
intel_runtime_pm_get(dev_priv); wakeref = intel_runtime_pm_get(dev_priv);
res = intel_rc6_residency_us(dev_priv, reg); res = intel_rc6_residency_us(dev_priv, reg);
intel_runtime_pm_put_unchecked(dev_priv); intel_runtime_pm_put(dev_priv, wakeref);
return DIV_ROUND_CLOSEST_ULL(res, 1000); return DIV_ROUND_CLOSEST_ULL(res, 1000);
} }
...@@ -258,9 +259,10 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev, ...@@ -258,9 +259,10 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
intel_wakeref_t wakeref;
int ret; int ret;
intel_runtime_pm_get(dev_priv); wakeref = intel_runtime_pm_get(dev_priv);
mutex_lock(&dev_priv->pcu_lock); mutex_lock(&dev_priv->pcu_lock);
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
...@@ -274,7 +276,7 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev, ...@@ -274,7 +276,7 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev,
} }
mutex_unlock(&dev_priv->pcu_lock); mutex_unlock(&dev_priv->pcu_lock);
intel_runtime_pm_put_unchecked(dev_priv); intel_runtime_pm_put(dev_priv, wakeref);
return snprintf(buf, PAGE_SIZE, "%d\n", ret); return snprintf(buf, PAGE_SIZE, "%d\n", ret);
} }
...@@ -354,6 +356,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, ...@@ -354,6 +356,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
{ {
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
struct intel_rps *rps = &dev_priv->gt_pm.rps; struct intel_rps *rps = &dev_priv->gt_pm.rps;
intel_wakeref_t wakeref;
u32 val; u32 val;
ssize_t ret; ssize_t ret;
...@@ -361,7 +364,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, ...@@ -361,7 +364,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
if (ret) if (ret)
return ret; return ret;
intel_runtime_pm_get(dev_priv); wakeref = intel_runtime_pm_get(dev_priv);
mutex_lock(&dev_priv->pcu_lock); mutex_lock(&dev_priv->pcu_lock);
...@@ -371,7 +374,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, ...@@ -371,7 +374,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
val > rps->max_freq || val > rps->max_freq ||
val < rps->min_freq_softlimit) { val < rps->min_freq_softlimit) {
mutex_unlock(&dev_priv->pcu_lock); mutex_unlock(&dev_priv->pcu_lock);
intel_runtime_pm_put_unchecked(dev_priv); intel_runtime_pm_put(dev_priv, wakeref);
return -EINVAL; return -EINVAL;
} }
...@@ -392,7 +395,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, ...@@ -392,7 +395,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
mutex_unlock(&dev_priv->pcu_lock); mutex_unlock(&dev_priv->pcu_lock);
intel_runtime_pm_put_unchecked(dev_priv); intel_runtime_pm_put(dev_priv, wakeref);
return ret ?: count; return ret ?: count;
} }
...@@ -412,6 +415,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, ...@@ -412,6 +415,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
{ {
struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
struct intel_rps *rps = &dev_priv->gt_pm.rps; struct intel_rps *rps = &dev_priv->gt_pm.rps;
intel_wakeref_t wakeref;
u32 val; u32 val;
ssize_t ret; ssize_t ret;
...@@ -419,7 +423,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, ...@@ -419,7 +423,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
if (ret) if (ret)
return ret; return ret;
intel_runtime_pm_get(dev_priv); wakeref = intel_runtime_pm_get(dev_priv);
mutex_lock(&dev_priv->pcu_lock); mutex_lock(&dev_priv->pcu_lock);
...@@ -429,7 +433,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, ...@@ -429,7 +433,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
val > rps->max_freq || val > rps->max_freq ||
val > rps->max_freq_softlimit) { val > rps->max_freq_softlimit) {
mutex_unlock(&dev_priv->pcu_lock); mutex_unlock(&dev_priv->pcu_lock);
intel_runtime_pm_put_unchecked(dev_priv); intel_runtime_pm_put(dev_priv, wakeref);
return -EINVAL; return -EINVAL;
} }
...@@ -446,7 +450,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, ...@@ -446,7 +450,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
mutex_unlock(&dev_priv->pcu_lock); mutex_unlock(&dev_priv->pcu_lock);
intel_runtime_pm_put_unchecked(dev_priv); intel_runtime_pm_put(dev_priv, wakeref);
return ret ?: count; return ret ?: count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment