]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915: Skip bw stuff if per-crtc sagv state doesn't change
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 26 Mar 2025 16:25:43 +0000 (18:25 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 4 Apr 2025 17:02:46 +0000 (20:02 +0300)
If there are no changes to intel_crtc_can_enable_sagv() there
is no need to do all the sagv bw_state recomputation.

The only slight caveat here is hw state takeover where we
initially disable SAGV, and want it to get re-enabled once
we've determined that it's safe to do so.  That can now be
achieved by having intel_crtc_can_enable_sagv() reject SAGV
as long as the crtc_state->inherited flag is set. Once the
flag gets cleared (during initial commit for inactive pipes,
during the first userspace commit for active pipes), we
will naturally recompute all the sagv related state.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250326162544.3642-14-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/display/intel_bw.c
drivers/gpu/drm/i915/display/skl_watermark.c

index b8bb2e395bb7e1b43d6f0e0d51fc4b40fa8af11a..e819db78dfbdece8849f7ffa26408206979fcb46 100644 (file)
@@ -1447,13 +1447,19 @@ static int intel_bw_check_sagv_mask(struct intel_atomic_state *state)
 {
        struct intel_display *display = to_intel_display(state);
        struct drm_i915_private *i915 = to_i915(display->drm);
+       const struct intel_crtc_state *old_crtc_state;
        const struct intel_crtc_state *new_crtc_state;
        const struct intel_bw_state *old_bw_state = NULL;
        struct intel_bw_state *new_bw_state = NULL;
        struct intel_crtc *crtc;
        int ret, i;
 
-       for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
+       for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
+                                           new_crtc_state, i) {
+               if (intel_crtc_can_enable_sagv(old_crtc_state) ==
+                   intel_crtc_can_enable_sagv(new_crtc_state))
+                       continue;
+
                new_bw_state = intel_atomic_get_bw_state(state);
                if (IS_ERR(new_bw_state))
                        return PTR_ERR(new_bw_state);
index baf345039deb5a911c2a8922a3e02b950b22af4d..8b51f0b42785efb7041925e2dbd581b4414cb7ff 100644 (file)
@@ -434,6 +434,14 @@ bool intel_crtc_can_enable_sagv(const struct intel_crtc_state *crtc_state)
        if (!i915->display.params.enable_sagv)
                return false;
 
+       /*
+        * SAGV is initially forced off because its current
+        * state can't be queried from pcode. Allow SAGV to
+        * be enabled upon the first real commit.
+        */
+       if (crtc_state->inherited)
+               return false;
+
        if (DISPLAY_VER(i915) >= 12)
                return tgl_crtc_can_enable_sagv(crtc_state);
        else
@@ -458,8 +466,7 @@ static int intel_compute_sagv_mask(struct intel_atomic_state *state)
        struct intel_crtc_state *new_crtc_state;
        int i;
 
-       for_each_new_intel_crtc_in_state(state, crtc,
-                                        new_crtc_state, i) {
+       for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
                struct skl_pipe_wm *pipe_wm = &new_crtc_state->wm.skl.optimal;
 
                /*