]> git.karo-electronics.de Git - linux-beck.git/commitdiff
drm/i915: add always-on power wells instead of special casing them
authorImre Deak <imre.deak@intel.com>
Mon, 25 Nov 2013 15:15:30 +0000 (17:15 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 26 Nov 2013 19:06:11 +0000 (20:06 +0100)
Instead of using a separate function to check whether a power domain is
is always on, add an always-on power well covering all these power
domains and do the usual get/put on these unconditionally. Since we
don't assign a .set handler for these the get/put won't have any effect
besides the adjusted refcount.

This makes the code more readable and provides debug info also on the
use of always-on power wells (once the relevant debugfs entry is added.)

v3: make is_always_on to be bool instead of a bit field (Paulo)

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Paulo Zanoni <paulo.zanoni@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_pm.c

index bb09dbf65fe8a5c5bdd8b23908b3932236243b67..e3e732bd832c0036cc5134e01349eb9f4cede139 100644 (file)
@@ -951,6 +951,7 @@ struct intel_ilk_power_mgmt {
 /* Power well structure for haswell */
 struct i915_power_well {
        const char *name;
+       bool always_on;
        /* power well enable/disable usage count */
        int count;
        unsigned long domains;
index 2b31734152125c9b487b08f0d5a2d4c2517114d5..9230781824e5c8b8b10a94ef925126fe192ed47d 100644 (file)
@@ -5608,25 +5608,6 @@ void intel_suspend_hw(struct drm_device *dev)
                lpt_suspend_hw(dev);
 }
 
-static bool is_always_on_power_domain(struct drm_device *dev,
-                                     enum intel_display_power_domain domain)
-{
-       unsigned long always_on_domains;
-
-       BUG_ON(BIT(domain) & ~POWER_DOMAIN_MASK);
-
-       if (IS_BROADWELL(dev)) {
-               always_on_domains = BDW_ALWAYS_ON_POWER_DOMAINS;
-       } else if (IS_HASWELL(dev)) {
-               always_on_domains = HSW_ALWAYS_ON_POWER_DOMAINS;
-       } else {
-               WARN_ON(1);
-               return true;
-       }
-
-       return BIT(domain) & always_on_domains;
-}
-
 #define for_each_power_well(i, power_well, domain_mask, power_domains) \
        for (i = 0;                                                     \
             i < (power_domains)->power_well_count &&                   \
@@ -5666,15 +5647,15 @@ bool intel_display_power_enabled(struct drm_device *dev,
        if (!HAS_POWER_WELL(dev))
                return true;
 
-       if (is_always_on_power_domain(dev, domain))
-               return true;
-
        power_domains = &dev_priv->power_domains;
 
        is_enabled = true;
 
        mutex_lock(&power_domains->lock);
        for_each_power_well_rev(i, power_well, BIT(domain), power_domains) {
+               if (power_well->always_on)
+                       continue;
+
                if (!power_well->is_enabled(dev, power_well)) {
                        is_enabled = false;
                        break;
@@ -5776,9 +5757,6 @@ void intel_display_power_get(struct drm_device *dev,
        if (!HAS_POWER_WELL(dev))
                return;
 
-       if (is_always_on_power_domain(dev, domain))
-               return;
-
        power_domains = &dev_priv->power_domains;
 
        mutex_lock(&power_domains->lock);
@@ -5798,9 +5776,6 @@ void intel_display_power_put(struct drm_device *dev,
        if (!HAS_POWER_WELL(dev))
                return;
 
-       if (is_always_on_power_domain(dev, domain))
-               return;
-
        power_domains = &dev_priv->power_domains;
 
        mutex_lock(&power_domains->lock);
@@ -5840,6 +5815,11 @@ void i915_release_power_well(void)
 EXPORT_SYMBOL_GPL(i915_release_power_well);
 
 static struct i915_power_well hsw_power_wells[] = {
+       {
+               .name = "always-on",
+               .always_on = 1,
+               .domains = HSW_ALWAYS_ON_POWER_DOMAINS,
+       },
        {
                .name = "display",
                .domains = POWER_DOMAIN_MASK & ~HSW_ALWAYS_ON_POWER_DOMAINS,
@@ -5849,6 +5829,11 @@ static struct i915_power_well hsw_power_wells[] = {
 };
 
 static struct i915_power_well bdw_power_wells[] = {
+       {
+               .name = "always-on",
+               .always_on = 1,
+               .domains = BDW_ALWAYS_ON_POWER_DOMAINS,
+       },
        {
                .name = "display",
                .domains = POWER_DOMAIN_MASK & ~BDW_ALWAYS_ON_POWER_DOMAINS,