Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Luca Coelho <luciano.coelho@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 6/6] drm/i915/wm: move method selection and calculation to a separate function
Date: Fri, 19 Sep 2025 21:00:09 +0300	[thread overview]
Message-ID: <aM2aKbpma-4Ss6ik@intel.com> (raw)
In-Reply-To: <20250908073734.1180687-7-luciano.coelho@intel.com>

On Mon, Sep 08, 2025 at 10:35:35AM +0300, Luca Coelho wrote:
> Isolate the code that handles method selection and calculation, so
> skl_compute_plane_wm() doesn't get too long.
> 
> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
> ---
>  drivers/gpu/drm/i915/display/skl_watermark.c | 51 ++++++++++++--------
>  1 file changed, 31 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/skl_watermark.c b/drivers/gpu/drm/i915/display/skl_watermark.c
> index 21f8d52ec1d2..33853a18ee9c 100644
> --- a/drivers/gpu/drm/i915/display/skl_watermark.c
> +++ b/drivers/gpu/drm/i915/display/skl_watermark.c
> @@ -1806,25 +1806,14 @@ static bool xe3_auto_min_alloc_capable(struct intel_plane *plane, int level)
>  	return DISPLAY_VER(display) >= 30 && level == 0 && plane->id != PLANE_CURSOR;
>  }
>  
> -static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
> -				 struct intel_plane *plane,
> -				 int level,
> -				 unsigned int latency,
> -				 const struct skl_wm_params *wp,
> -				 const struct skl_wm_level *result_prev,
> -				 struct skl_wm_level *result /* out */)
> +static uint_fixed_16_16_t
> +skl_wm_run_method(struct intel_display *display,

I was confused what a "run method" is, but I guess "run" is supposed
to be a verb here.

However this thing does a lot more than "run a method", so I don't
really like this.

I susepct it would make more sense to carve up skl_compute_plane_wm()
into several smaller (possibly platform dependent) pieces. Eg.
the result selection part seems like one thing that could extracted
into a small function. The min_ddb_alloc calculation would be another
clear piece that can be extracted.

> +		  const struct intel_crtc_state *crtc_state,
> +		  const struct skl_wm_params *wp,
> +		  unsigned int latency)
>  {
> -	struct intel_display *display = to_intel_display(crtc_state);
>  	uint_fixed_16_16_t method1, method2;
>  	uint_fixed_16_16_t selected_result;
> -	u32 blocks, lines, min_ddb_alloc = 0;
> -
> -	if (latency == 0 ||
> -	    (use_minimal_wm0_only(crtc_state, plane) && level > 0)) {
> -		/* reject it */
> -		result->min_ddb_alloc = U16_MAX;
> -		return;
> -	}
>  
>  	method1 = skl_wm_method1(display, wp->plane_pixel_rate,
>  				 wp->cpp, latency, wp->dbuf_block_size);
> @@ -1837,7 +1826,9 @@ static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
>  	case WM_TILING_Y_FAMILY:
>  		selected_result = max_fixed16(method2, wp->y_tile_minimum);
>  		break;
> -
> +	default:
> +		MISSING_CASE(wp->tiling);
> +		fallthrough;
>  	case WM_TILING_LINEAR:
>  	case WM_TILING_X_TILED:
>  		/*
> @@ -1862,12 +1853,32 @@ static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
>  			selected_result = method1;
>  		}
>  		break;
> +	}
>  
> -	default:
> -		drm_err(display->drm, "Invalid tiling mode\n", wp->tiling);
> -		break;
> +	return selected_result;
> +}
> +
> +static void skl_compute_plane_wm(const struct intel_crtc_state *crtc_state,
> +				 struct intel_plane *plane,
> +				 int level,
> +				 unsigned int latency,
> +				 const struct skl_wm_params *wp,
> +				 const struct skl_wm_level *result_prev,
> +				 struct skl_wm_level *result /* out */)
> +{
> +	struct intel_display *display = to_intel_display(crtc_state);
> +	uint_fixed_16_16_t selected_result;
> +	u32 blocks, lines, min_ddb_alloc = 0;
> +
> +	if (latency == 0 ||
> +	    (use_minimal_wm0_only(crtc_state, plane) && level > 0)) {
> +		/* reject it */
> +		result->min_ddb_alloc = U16_MAX;
> +		return;
>  	}
>  
> +	selected_result = skl_wm_run_method(display, crtc_state, wp, latency);
> +
>  	blocks = fixed16_to_u32_round_up(selected_result);
>  	if (DISPLAY_VER(display) < 30)
>  		blocks++;
> -- 
> 2.50.1

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2025-09-19 18:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-08  7:35 [PATCH 0/6] drm/i915/wm: some clean-ups and a bit of refactoring Luca Coelho
2025-09-08  7:35 ` [PATCH 1/6] drm/i915/wm: clarify watermark ops with comments Luca Coelho
2025-09-16  8:52   ` Govindapillai, Vinod
2025-09-22 10:26     ` Luca Coelho
2025-09-08  7:35 ` [PATCH 2/6] drm/i915/wm: move intel_sagv_init() to avoid forward declaration Luca Coelho
2025-09-16  8:53   ` Govindapillai, Vinod
2025-09-08  7:35 ` [PATCH 3/6] drm/i915/wm: remove stale FIXME in skl_needs_memory_bw_wa() Luca Coelho
2025-09-16  9:21   ` Govindapillai, Vinod
2025-09-08  7:35 ` [PATCH 4/6] drm/i915/wm: convert x/y-tiling bools to an enum Luca Coelho
2025-09-08 12:43   ` Gustavo Sousa
2025-09-08 12:53     ` Luca Coelho
2025-09-19  8:36   ` Ville Syrjälä
2025-09-22 12:38     ` Luca Coelho
2025-09-22 12:48       ` Ville Syrjälä
2025-09-08  7:35 ` [PATCH 5/6] drm/i915/wm: convert tiling mode check in slk_compute_plane_wm() to a switch-case Luca Coelho
2025-09-08 12:51   ` Gustavo Sousa
2025-09-08 12:57     ` Luca Coelho
2025-09-08  7:35 ` [PATCH 6/6] drm/i915/wm: move method selection and calculation to a separate function Luca Coelho
2025-09-19 18:00   ` Ville Syrjälä [this message]
2025-09-29  7:21     ` Luca Coelho
2025-09-08 17:20 ` ✓ i915.CI.BAT: success for drm/i915/wm: some clean-ups and a bit of refactoring Patchwork
2025-09-09  2:47 ` ✗ 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=aM2aKbpma-4Ss6ik@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=luciano.coelho@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