drm/i915: Don't cancel/schedule drrs work if the pipe wasn't affected
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 15 Mar 2022 13:27:48 +0000 (15:27 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 16 Mar 2022 12:45:48 +0000 (14:45 +0200)
Skip all the DRRS work cancel/schedule stuff if the pipe's
frontbuffer bits were not among those affected by the frontbuffer
rendering.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220315132752.11849-6-ville.syrjala@linux.intel.com
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
drivers/gpu/drm/i915/display/intel_drrs.c

index 91aab77..f36394f 100644 (file)
@@ -278,32 +278,31 @@ static void intel_drrs_frontbuffer_update(struct drm_i915_private *dev_priv,
        for_each_intel_crtc(&dev_priv->drm, crtc) {
                unsigned int frontbuffer_bits;
 
-               cancel_delayed_work(&crtc->drrs.work);
-
                mutex_lock(&crtc->drrs.mutex);
 
-               if (!intel_drrs_is_enabled(crtc)) {
+               frontbuffer_bits = all_frontbuffer_bits & crtc->drrs.frontbuffer_bits;
+               if (!frontbuffer_bits) {
                        mutex_unlock(&crtc->drrs.mutex);
                        continue;
                }
 
-               frontbuffer_bits = all_frontbuffer_bits & crtc->drrs.frontbuffer_bits;
                if (invalidate)
                        crtc->drrs.busy_frontbuffer_bits |= frontbuffer_bits;
                else
                        crtc->drrs.busy_frontbuffer_bits &= ~frontbuffer_bits;
 
                /* flush/invalidate means busy screen hence upclock */
-               if (frontbuffer_bits)
-                       intel_drrs_set_state(crtc, DRRS_REFRESH_RATE_HIGH);
+               intel_drrs_set_state(crtc, DRRS_REFRESH_RATE_HIGH);
 
                /*
                 * flush also means no more activity hence schedule downclock, if all
                 * other fbs are quiescent too
                 */
-               if (!invalidate && !crtc->drrs.busy_frontbuffer_bits)
-                       schedule_delayed_work(&crtc->drrs.work,
-                                             msecs_to_jiffies(1000));
+               if (!crtc->drrs.busy_frontbuffer_bits)
+                       mod_delayed_work(system_wq, &crtc->drrs.work,
+                                        msecs_to_jiffies(1000));
+               else
+                       cancel_delayed_work(&crtc->drrs.work);
 
                mutex_unlock(&crtc->drrs.mutex);
        }