drm/i915: Call the sync_hw hook for power wells without a domain
authorImre Deak <imre.deak@intel.com>
Fri, 17 Feb 2017 15:39:43 +0000 (17:39 +0200)
committerImre Deak <imre.deak@intel.com>
Mon, 20 Feb 2017 12:51:12 +0000 (14:51 +0200)
So far the sync_hw hook wasn't called for power wells not belonging to
any power domain, that is the GEN9 PW1 and MISC_IO power wells. This
wasn't a problem so far since the goal of the sync_hw hook - to clear
the corresponding BIOS request bit - was guaranteed by clearing the
whole BIOS request register elsewhere. This will change with the next
patch, so fix up the inconsistency.

While at it clean up the power well iterator helpers and move them to
the rest of iterators.

v2:
- Clean up the power well iterator helpers. (Ander)
- Move the helpers to i915_drv.h.

Cc: Ander Conselvan de Oliveira <conselvan2@gmail.com>
Cc: David Weinehall <david.weinehall@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Ander Conselvan de Oliveira <conselvan2@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1487345986-26511-3-git-send-email-imre.deak@intel.com
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_runtime_pm.c

index 2a7b277a86de95673175c78d53bb3209f72e0d66..1fe4010d4f2b867a6431abeaf5dd861afa84aeaf 100644 (file)
@@ -500,6 +500,26 @@ struct i915_hotplug {
        for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++)     \
                for_each_if (BIT_ULL(domain) & (mask))
 
+#define for_each_power_well(__dev_priv, __power_well)                          \
+       for ((__power_well) = (__dev_priv)->power_domains.power_wells;  \
+            (__power_well) - (__dev_priv)->power_domains.power_wells < \
+               (__dev_priv)->power_domains.power_well_count;           \
+            (__power_well)++)
+
+#define for_each_power_well_rev(__dev_priv, __power_well)                      \
+       for ((__power_well) = (__dev_priv)->power_domains.power_wells +         \
+                             (__dev_priv)->power_domains.power_well_count - 1; \
+            (__power_well) - (__dev_priv)->power_domains.power_wells >= 0;     \
+            (__power_well)--)
+
+#define for_each_power_domain_well(__dev_priv, __power_well, __domain_mask)    \
+       for_each_power_well(__dev_priv, __power_well)                           \
+               for_each_if ((__power_well)->domains & (__domain_mask))
+
+#define for_each_power_domain_well_rev(__dev_priv, __power_well, __domain_mask) \
+       for_each_power_well_rev(__dev_priv, __power_well)                       \
+               for_each_if ((__power_well)->domains & (__domain_mask))
+
 struct drm_i915_private;
 struct i915_mm_struct;
 struct i915_mmu_object;
index 0f64bc12f308068d4f3b70678cd882dffcba1056..9bbbdbc1c843379df33bb15a0da13932df191cfe 100644 (file)
  * present for a given platform.
  */
 
-#define for_each_power_well(i, power_well, domain_mask, power_domains) \
-       for (i = 0;                                                     \
-            i < (power_domains)->power_well_count &&                   \
-                ((power_well) = &(power_domains)->power_wells[i]);     \
-            i++)                                                       \
-               for_each_if ((power_well)->domains & (domain_mask))
-
-#define for_each_power_well_rev(i, power_well, domain_mask, power_domains) \
-       for (i = (power_domains)->power_well_count - 1;                  \
-            i >= 0 && ((power_well) = &(power_domains)->power_wells[i]);\
-            i--)                                                        \
-               for_each_if ((power_well)->domains & (domain_mask))
-
 bool intel_display_power_well_is_enabled(struct drm_i915_private *dev_priv,
                                    int power_well_id);
 
@@ -198,19 +185,15 @@ static bool hsw_power_well_enabled(struct drm_i915_private *dev_priv,
 bool __intel_display_power_is_enabled(struct drm_i915_private *dev_priv,
                                      enum intel_display_power_domain domain)
 {
-       struct i915_power_domains *power_domains;
        struct i915_power_well *power_well;
        bool is_enabled;
-       int i;
 
        if (dev_priv->pm.suspended)
                return false;
 
-       power_domains = &dev_priv->power_domains;
-
        is_enabled = true;
 
-       for_each_power_well_rev(i, power_well, BIT_ULL(domain), power_domains) {
+       for_each_power_domain_well_rev(dev_priv, power_well, BIT_ULL(domain)) {
                if (power_well->always_on)
                        continue;
 
@@ -1663,9 +1646,8 @@ __intel_display_power_get_domain(struct drm_i915_private *dev_priv,
 {
        struct i915_power_domains *power_domains = &dev_priv->power_domains;
        struct i915_power_well *power_well;
-       int i;
 
-       for_each_power_well(i, power_well, BIT_ULL(domain), power_domains)
+       for_each_power_domain_well(dev_priv, power_well, BIT_ULL(domain))
                intel_power_well_get(dev_priv, power_well);
 
        power_domains->domain_use_count[domain]++;
@@ -1749,7 +1731,6 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
 {
        struct i915_power_domains *power_domains;
        struct i915_power_well *power_well;
-       int i;
 
        power_domains = &dev_priv->power_domains;
 
@@ -1760,7 +1741,7 @@ void intel_display_power_put(struct drm_i915_private *dev_priv,
             intel_display_power_domain_str(domain));
        power_domains->domain_use_count[domain]--;
 
-       for_each_power_well_rev(i, power_well, BIT_ULL(domain), power_domains)
+       for_each_power_domain_well_rev(dev_priv, power_well, BIT_ULL(domain))
                intel_power_well_put(dev_priv, power_well);
 
        mutex_unlock(&power_domains->lock);
@@ -2424,10 +2405,9 @@ static void intel_power_domains_sync_hw(struct drm_i915_private *dev_priv)
 {
        struct i915_power_domains *power_domains = &dev_priv->power_domains;
        struct i915_power_well *power_well;
-       int i;
 
        mutex_lock(&power_domains->lock);
-       for_each_power_well(i, power_well, POWER_DOMAIN_MASK, power_domains) {
+       for_each_power_well(dev_priv, power_well) {
                power_well->ops->sync_hw(dev_priv, power_well);
                power_well->hw_enabled = power_well->ops->is_enabled(dev_priv,
                                                                     power_well);