public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Michał Grzelak" <michal.grzelak@intel.com>
Cc: intel-gfx@lists.freedesktop.org, Nemesa Garg <nemesa.garg@intel.com>
Subject: Re: [PATCH v2 09/10] drm/i915/scaler: abstract scaler searching loop
Date: Mon, 13 Apr 2026 15:45:27 +0300	[thread overview]
Message-ID: <adzlZzTcNo7Ampmj@intel.com> (raw)
In-Reply-To: <20260411174526.2850179-10-michal.grzelak@intel.com>

On Sat, Apr 11, 2026 at 07:45:25PM +0200, Michał Grzelak wrote:
> Add a helper function hiding the search for scaler_id.
> 
> 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>
> ---
>  drivers/gpu/drm/i915/display/skl_scaler.c | 29 ++++++++++++++---------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/skl_scaler.c b/drivers/gpu/drm/i915/display/skl_scaler.c
> index 4e2f4c4ffc45a..1f47c5fc1802f 100644
> --- a/drivers/gpu/drm/i915/display/skl_scaler.c
> +++ b/drivers/gpu/drm/i915/display/skl_scaler.c
> @@ -836,6 +836,21 @@ void skl_pfit_enable(const struct intel_crtc_state *crtc_state)
>  			  PS_WIN_XSIZE(width) | PS_WIN_YSIZE(height));
>  }
>  
> +static int skl_pipe_scaler_get_hw_state(struct intel_crtc_state *crtc_state)
> +{
> +	struct intel_display *display = to_intel_display(crtc_state);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +	u32 ctl;

'ctl' could stay inside the loop.

I suppose technically 'display' could go there as well, but
we've established the convention that 'display' (if needed inside
the function) is the first variable declared. So that one should
stay here.

> +
> +	for (int scaler_id = 0; scaler_id < crtc->num_scalers; scaler_id++) {
> +		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))
> +			return scaler_id;
> +	}
> +
> +	return -1;
> +}
> +
>  void
>  skl_program_plane_scaler(struct intel_dsb *dsb,
>  			 struct intel_plane *plane,
> @@ -950,19 +965,11 @@ void skl_scaler_get_config(struct intel_crtc_state *crtc_state)
>  	struct intel_display *display = to_intel_display(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;
> -
> -		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))
> -			break;
> -	}
> +	int scaler_id = skl_pipe_scaler_get_hw_state(crtc_state);

I don't like hiding stuff with potential side effects
inside the variable declaration block. Only pure
functions should be called there. So it's better to
do the function call+assignment just before the <0 check.

Apart from that it all looks good to me. So with that adjusted
the series is
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

But looks like you forgot to cc intel-xe@. We do want xe CI results
before merging...

> +	u32 pos, size;
>  
> -	if (scaler_id == crtc->num_scalers)
> +	if (scaler_id < 0)
>  		return;
>  
>  	if (scaler_has_casf(display, scaler_id))
> -- 
> 2.45.2

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2026-04-13 12:45 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11 17:45 [PATCH v2 00/10] drm/i915: casf & scaler refactoring Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 01/10] drm/i915/casf: fix comment typos Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 02/10] drm/i915/casf: rename *_coeff*() into *_coef*() Michał Grzelak
2026-04-12 21:49   ` Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 03/10] drm/i915: rename t into tap Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 04/10] drm/i915/casf: rename sumcoeff into sum_coeff Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 05/10] drm/i915/scaler: s/i/scaler_id where appropriate Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 06/10] drm/i915/scaler: remove id in favor of scaler_id Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 07/10] drm/i915/scaler: unloop scaler readout that is run once Michał Grzelak
2026-04-14  8:01   ` Garg, Nemesa
2026-04-20  8:22     ` Grzelak, Michal
2026-04-11 17:45 ` [PATCH v2 08/10] drm/i915/scaler: invert loop's breaking logic Michał Grzelak
2026-04-11 17:45 ` [PATCH v2 09/10] drm/i915/scaler: abstract scaler searching loop Michał Grzelak
2026-04-13 12:45   ` Ville Syrjälä [this message]
2026-04-20  8:19     ` Grzelak, Michal
2026-04-11 17:45 ` [PATCH v2 10/10] drm/i915/scaler: eliminate dead code Michał Grzelak
2026-04-11 18:41 ` ✓ i915.CI.BAT: success for drm/i915: casf & scaler refactoring (rev2) Patchwork
2026-04-11 23:56 ` ✗ 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=adzlZzTcNo7Ampmj@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=michal.grzelak@intel.com \
    --cc=nemesa.garg@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