]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/scaler: unloop scaler readout that is run once
authorMichał Grzelak <michal.grzelak@intel.com>
Sat, 9 May 2026 16:40:46 +0000 (18:40 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 20 May 2026 23:55:15 +0000 (02:55 +0300)
Most of the loop's code is run once because of the continue statement at
it's start and break statement at it's end. Kick it out of the loop.

While at it, skl_scaler_get_config()'s loop is skipped when specified
condition is met and broken when the condition is not met. Equivalently,
invert the condition and break the loop.

Changelog:
v2->v3
- keep ctl inside the loop (Ville)

Cc: Nemesa Garg <nemesa.garg@intel.com>
Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Michał Grzelak <michal.grzelak@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20260509164048.627399-8-michal.grzelak@intel.com
drivers/gpu/drm/i915/display/skl_scaler.c

index 6d9080ec74ce0dc7db86781133ded7279e5f5f5b..4e2f4c4ffc45adfdeb2fde891956f428a17c82a4 100644 (file)
@@ -951,35 +951,35 @@ void skl_scaler_get_config(struct intel_crtc_state *crtc_state)
        struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
        struct intel_crtc_scaler_state *scaler_state = &crtc_state->scaler_state;
        int scaler_id;
+       u32 pos, size;
 
        /* find scaler attached to this pipe */
        for (scaler_id = 0; scaler_id < crtc->num_scalers; scaler_id++) {
-               u32 ctl, pos, size;
+               u32 ctl;
 
                ctl = intel_de_read(display, SKL_PS_CTRL(crtc->pipe, scaler_id));
-               if ((ctl & (PS_SCALER_EN | PS_BINDING_MASK)) != (PS_SCALER_EN | PS_BINDING_PIPE))
-                       continue;
+               if ((ctl & (PS_SCALER_EN | PS_BINDING_MASK)) == (PS_SCALER_EN | PS_BINDING_PIPE))
+                       break;
+       }
 
-               if (scaler_has_casf(display, scaler_id))
-                       intel_casf_sharpness_get_config(crtc_state);
+       if (scaler_id == crtc->num_scalers)
+               return;
 
-               crtc_state->pch_pfit.enabled = true;
+       if (scaler_has_casf(display, scaler_id))
+               intel_casf_sharpness_get_config(crtc_state);
 
-               pos = intel_de_read(display, SKL_PS_WIN_POS(crtc->pipe, scaler_id));
-               size = intel_de_read(display, SKL_PS_WIN_SZ(crtc->pipe, scaler_id));
+       crtc_state->pch_pfit.enabled = true;
 
-               drm_rect_init(&crtc_state->pch_pfit.dst,
-                             REG_FIELD_GET(PS_WIN_XPOS_MASK, pos),
-                             REG_FIELD_GET(PS_WIN_YPOS_MASK, pos),
-                             REG_FIELD_GET(PS_WIN_XSIZE_MASK, size),
-                             REG_FIELD_GET(PS_WIN_YSIZE_MASK, size));
+       pos = intel_de_read(display, SKL_PS_WIN_POS(crtc->pipe, scaler_id));
+       size = intel_de_read(display, SKL_PS_WIN_SZ(crtc->pipe, scaler_id));
 
-               scaler_state->scalers[scaler_id].in_use = true;
-               break;
-       }
+       drm_rect_init(&crtc_state->pch_pfit.dst,
+                     REG_FIELD_GET(PS_WIN_XPOS_MASK, pos),
+                     REG_FIELD_GET(PS_WIN_YPOS_MASK, pos),
+                     REG_FIELD_GET(PS_WIN_XSIZE_MASK, size),
+                     REG_FIELD_GET(PS_WIN_YSIZE_MASK, size));
 
-       if (scaler_id == crtc->num_scalers)
-               return;
+       scaler_state->scalers[scaler_id].in_use = true;
 
        scaler_state->scaler_id = scaler_id;
        if (scaler_id >= 0)