blob: edf44cfffbd3c81e6c368723ddabea2b2b31838d [file] [log] [blame]
From 4b3b48481a74a3bd155f3e45f581a254cfe7a0c0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= <ville.syrjala@linux.intel.com>
Date: Mon, 16 Sep 2013 17:38:29 +0300
Subject: drm/i915: Refactor power well refcount inc/dec operations
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We increase/decrease the power well refcount in several places now, and
all of those places need to do the same thing, so pull that code into
a few small helper functions.
v2: Rename the funcs to __intel_power_well_{get,put}
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
(cherry picked from commit 2d66aef508fc47aa75ed196bc4638636e28d1b42)
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
---
drivers/gpu/drm/i915/intel_pm.c | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 147334dc3956..99f4eadb1af3 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -5345,6 +5345,19 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
}
}
+static void __intel_power_well_get(struct i915_power_well *power_well)
+{
+ if (!power_well->count++)
+ __intel_set_power_well(power_well->device, true);
+}
+
+static void __intel_power_well_put(struct i915_power_well *power_well)
+{
+ WARN_ON(!power_well->count);
+ if (!--power_well->count)
+ __intel_set_power_well(power_well->device, false);
+}
+
void intel_display_power_get(struct drm_device *dev,
enum intel_display_power_domain domain)
{
@@ -5367,8 +5380,7 @@ void intel_display_power_get(struct drm_device *dev,
case POWER_DOMAIN_TRANSCODER_B:
case POWER_DOMAIN_TRANSCODER_C:
spin_lock_irq(&power_well->lock);
- if (!power_well->count++)
- __intel_set_power_well(power_well->device, true);
+ __intel_power_well_get(power_well);
spin_unlock_irq(&power_well->lock);
return;
default:
@@ -5398,9 +5410,7 @@ void intel_display_power_put(struct drm_device *dev,
case POWER_DOMAIN_TRANSCODER_B:
case POWER_DOMAIN_TRANSCODER_C:
spin_lock_irq(&power_well->lock);
- WARN_ON(!power_well->count);
- if (!--power_well->count)
- __intel_set_power_well(power_well->device, false);
+ __intel_power_well_put(power_well);
spin_unlock_irq(&power_well->lock);
return;
default:
@@ -5417,8 +5427,7 @@ void i915_request_power_well(void)
return;
spin_lock_irq(&hsw_pwr->lock);
- if (!hsw_pwr->count++)
- __intel_set_power_well(hsw_pwr->device, true);
+ __intel_power_well_get(hsw_pwr);
spin_unlock_irq(&hsw_pwr->lock);
}
EXPORT_SYMBOL_GPL(i915_request_power_well);
@@ -5430,9 +5439,7 @@ void i915_release_power_well(void)
return;
spin_lock_irq(&hsw_pwr->lock);
- WARN_ON(!hsw_pwr->count);
- if (!--hsw_pwr->count)
- __intel_set_power_well(hsw_pwr->device, false);
+ __intel_power_well_put(hsw_pwr);
spin_unlock_irq(&hsw_pwr->lock);
}
EXPORT_SYMBOL_GPL(i915_release_power_well);
@@ -5479,14 +5486,10 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
power_well->i915_request = enable;
- if (enable) {
- if (!power_well->count++)
- __intel_set_power_well(dev, true);
- } else {
- WARN_ON(!power_well->count);
- if (!--power_well->count)
- __intel_set_power_well(dev, false);
- }
+ if (enable)
+ __intel_power_well_get(power_well);
+ else
+ __intel_power_well_put(power_well);
out:
spin_unlock_irq(&power_well->lock);
--
1.8.5.rc3