drm/i915: Track power reference taken to disable power well functionality
authorImre Deak <imre.deak@intel.com>
Tue, 1 Dec 2020 16:13:40 +0000 (18:13 +0200)
committerImre Deak <imre.deak@intel.com>
Thu, 3 Dec 2020 13:31:55 +0000 (15:31 +0200)
Add wakeref tracking for the display power domain reference taken to
keep the display power well functionality disabled.

v2: Add missing wakeref zeroing to intel_power_domains_driver_remove()

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20201201161340.2879202-2-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_display_power.c
drivers/gpu/drm/i915/display/intel_display_power.h

index 75e805d..1b3b2de 100644 (file)
@@ -5663,8 +5663,11 @@ void intel_power_domains_init_hw(struct drm_i915_private *i915, bool resume)
                intel_display_power_get(i915, POWER_DOMAIN_INIT);
 
        /* Disable power support if the user asked so. */
-       if (!i915->params.disable_power_well)
-               intel_display_power_get(i915, POWER_DOMAIN_INIT);
+       if (!i915->params.disable_power_well) {
+               drm_WARN_ON(&i915->drm, power_domains->disable_wakeref);
+               i915->power_domains.disable_wakeref = intel_display_power_get(i915,
+                                                                             POWER_DOMAIN_INIT);
+       }
        intel_power_domains_sync_hw(i915);
 
        power_domains->initializing = false;
@@ -5688,7 +5691,8 @@ void intel_power_domains_driver_remove(struct drm_i915_private *i915)
 
        /* Remove the refcount we took to keep power well support disabled. */
        if (!i915->params.disable_power_well)
-               intel_display_power_put_unchecked(i915, POWER_DOMAIN_INIT);
+               intel_display_power_put(i915, POWER_DOMAIN_INIT,
+                                       fetch_and_zero(&i915->power_domains.disable_wakeref));
 
        intel_display_power_flush_work_sync(i915);
 
@@ -5777,7 +5781,8 @@ void intel_power_domains_suspend(struct drm_i915_private *i915,
         * power wells if power domains must be deinitialized for suspend.
         */
        if (!i915->params.disable_power_well)
-               intel_display_power_put_unchecked(i915, POWER_DOMAIN_INIT);
+               intel_display_power_put(i915, POWER_DOMAIN_INIT,
+                                       fetch_and_zero(&i915->power_domains.disable_wakeref));
 
        intel_display_power_flush_work(i915);
        intel_power_domains_verify_state(i915);
index 34de548..2ef95ce 100644 (file)
@@ -213,6 +213,7 @@ struct i915_power_domains {
        int power_well_count;
 
        intel_wakeref_t init_wakeref;
+       intel_wakeref_t disable_wakeref;
 
        struct mutex lock;
        int domain_use_count[POWER_DOMAIN_NUM];