Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Michał Grzelak" <michal.grzelak@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: ville.syrjala@linux.intel.com, nemesa.garg@intel.com,
	"Michał Grzelak" <michal.grzelak@intel.com>
Subject: [PATCH v3 7/9] drm/i915/scaler: unloop scaler readout that is run once
Date: Sat,  9 May 2026 18:40:46 +0200	[thread overview]
Message-ID: <20260509164048.627399-8-michal.grzelak@intel.com> (raw)
In-Reply-To: <20260509164048.627399-1-michal.grzelak@intel.com>

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>
---
 drivers/gpu/drm/i915/display/skl_scaler.c | 36 +++++++++++------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
index 6d9080ec74ce..4e2f4c4ffc45 100644
--- a/drivers/gpu/drm/i915/display/skl_scaler.c
+++ b/drivers/gpu/drm/i915/display/skl_scaler.c
@@ -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)
-- 
2.45.2


  parent reply	other threads:[~2026-05-09 16:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-09 16:40 [PATCH v3 0/9] casf & scaler refactoring Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 1/9] drm/i915/casf: fix comment typos Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 2/9] drm/i915/casf: rename *_coef*() into *_coeff*() Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 3/9] drm/i915: rename t into tap Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 4/9] drm/i915/casf: rename sumcoeff into sum_coeff Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 5/9] drm/i915/scaler: s/i/scaler_id/ where appropriate Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 6/9] drm/i915/scaler: remove id in favor of scaler_id Michał Grzelak
2026-05-09 16:40 ` Michał Grzelak [this message]
2026-05-09 16:40 ` [PATCH v3 8/9] drm/i915/scaler: abstract scaler searching loop Michał Grzelak
2026-05-09 16:40 ` [PATCH v3 9/9] drm/i915/scaler: eliminate dead code Michał Grzelak
2026-05-09 17:39 ` ✓ i915.CI.BAT: success for casf & scaler refactoring Patchwork
2026-05-10  4:25 ` ✗ i915.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260509164048.627399-8-michal.grzelak@intel.com \
    --to=michal.grzelak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=nemesa.garg@intel.com \
    --cc=ville.syrjala@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox