Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: intel-xe@lists.freedesktop.org
Subject: [PATCH 4/9] drm/i915/ips: Eliminate the cdclk_state stuff from hsw_ips_compute_config()
Date: Mon, 13 Oct 2025 23:12:31 +0300	[thread overview]
Message-ID: <20251013201236.30084-5-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20251013201236.30084-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reorganize the IPS CDCLK handling such that the computed CDCLK
frequency will always satisfy the IPS requirements. The only
exceptional case is if IPS would push the CDCLK above the platform
max, but in that case we can simply disable IPS.

To make this 100% race free we must move the enable_ips modparam
check out from the min CDCLK computation path so that there is no
chance of hsw_min_cdclk() and hsw_ips_compute_config() observing
a different enable_ips value during the same commit.

This allows us to completely remove the cdclk_state stuff
from the IPS code. We only ever have to compare the IPS min
CDCLK against the platform max CDCLK. Thus we eliminate any ordering
requirements between intel_cdclk_atomic_check() and
hsw_ips_compute_config().

Additionally we reduce the three copies of the code doing the
95% calculation into just one.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/hsw_ips.c | 61 ++++++++++++--------------
 1 file changed, 28 insertions(+), 33 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/hsw_ips.c b/drivers/gpu/drm/i915/display/hsw_ips.c
index 927fe56aec77..f444c5b7a27b 100644
--- a/drivers/gpu/drm/i915/display/hsw_ips.c
+++ b/drivers/gpu/drm/i915/display/hsw_ips.c
@@ -191,45 +191,46 @@ bool hsw_crtc_supports_ips(struct intel_crtc *crtc)
 
 static bool hsw_crtc_state_ips_capable(const 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);
 
-	/* IPS only exists on ULT machines and is tied to pipe A. */
 	if (!hsw_crtc_supports_ips(crtc))
 		return false;
 
-	if (!display->params.enable_ips)
-		return false;
-
 	if (crtc_state->pipe_bpp > 24)
 		return false;
 
-	/*
-	 * We compare against max which means we must take
-	 * the increased cdclk requirement into account when
-	 * calculating the new cdclk.
-	 *
-	 * Should measure whether using a lower cdclk w/o IPS
-	 */
-	if (display->platform.broadwell &&
-	    crtc_state->pixel_rate > display->cdclk.max_cdclk_freq * 95 / 100)
-		return false;
-
 	return true;
 }
 
+static int _hsw_ips_min_cdclk(const struct intel_crtc_state *crtc_state)
+{
+	struct intel_display *display = to_intel_display(crtc_state);
+
+	if (display->platform.broadwell)
+		return DIV_ROUND_UP(crtc_state->pixel_rate * 100, 95);
+
+	/* no IPS specific limits to worry about */
+	return 0;
+}
+
 int hsw_ips_min_cdclk(const struct intel_crtc_state *crtc_state)
 {
 	struct intel_display *display = to_intel_display(crtc_state);
-
-	if (!display->platform.broadwell)
-		return 0;
+	int min_cdclk;
 
 	if (!hsw_crtc_state_ips_capable(crtc_state))
 		return 0;
 
-	/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
-	return DIV_ROUND_UP(crtc_state->pixel_rate * 100, 95);
+	min_cdclk = _hsw_ips_min_cdclk(crtc_state);
+
+	/*
+	 * Do not ask for more than the max CDCLK frequency,
+	 * if that is not enough IPS will simply not be used.
+	 */
+	if (min_cdclk > display->cdclk.max_cdclk_freq)
+		return 0;
+
+	return min_cdclk;
 }
 
 int hsw_ips_compute_config(struct intel_atomic_state *state,
@@ -244,6 +245,12 @@ int hsw_ips_compute_config(struct intel_atomic_state *state,
 	if (!hsw_crtc_state_ips_capable(crtc_state))
 		return 0;
 
+	if (_hsw_ips_min_cdclk(crtc_state) > display->cdclk.max_cdclk_freq)
+		return 0;
+
+	if (!display->params.enable_ips)
+		return 0;
+
 	/*
 	 * When IPS gets enabled, the pipe CRC changes. Since IPS gets
 	 * enabled and disabled dynamically based on package C states,
@@ -257,18 +264,6 @@ int hsw_ips_compute_config(struct intel_atomic_state *state,
 	if (!(crtc_state->active_planes & ~BIT(PLANE_CURSOR)))
 		return 0;
 
-	if (display->platform.broadwell) {
-		const struct intel_cdclk_state *cdclk_state;
-
-		cdclk_state = intel_atomic_get_cdclk_state(state);
-		if (IS_ERR(cdclk_state))
-			return PTR_ERR(cdclk_state);
-
-		/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
-		if (crtc_state->pixel_rate > intel_cdclk_logical(cdclk_state) * 95 / 100)
-			return 0;
-	}
-
 	crtc_state->ips_enabled = true;
 
 	return 0;
-- 
2.49.1


  parent reply	other threads:[~2025-10-13 20:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13 20:12 [PATCH 0/9] drm/i915: Reorder cdclk stuff for vblank/guardband length checks Ville Syrjala
2025-10-13 20:12 ` [PATCH 1/9] drm/i915/bw: Untangle dbuf bw from the sagv/mem bw stuff Ville Syrjala
2025-10-16 10:39   ` Kahola, Mika
2025-10-13 20:12 ` [PATCH 2/9] drm/i915: s/"not not"/"not"/ Ville Syrjala
2025-10-16 10:41   ` Kahola, Mika
2025-10-13 20:12 ` [PATCH 3/9] drm/i915/bw: Relocate intel_bw_crtc_min_cdclk() Ville Syrjala
2025-10-16 10:43   ` Kahola, Mika
2025-10-13 20:12 ` Ville Syrjala [this message]
2025-10-16 10:57   ` [PATCH 4/9] drm/i915/ips: Eliminate the cdclk_state stuff from hsw_ips_compute_config() Kahola, Mika
2025-10-13 20:12 ` [PATCH 5/9] drm/i915/fbc: Decouple FBC from intel_cdclk_atomic_check() Ville Syrjala
2025-10-16 11:40   ` Kahola, Mika
2025-10-13 20:12 ` [PATCH 6/9] drm/i915: s/min_cdck[]/plane_min_cdclk[]/ Ville Syrjala
2025-10-16 11:44   ` Kahola, Mika
2025-10-13 20:12 ` [PATCH 7/9] drm/i915: Compute per-crtc min_cdclk earlier Ville Syrjala
2025-10-16 11:56   ` Kahola, Mika
2025-10-13 20:12 ` [PATCH 8/9] drm/i915: Include the per-crtc minimum cdclk in the crtc state dump Ville Syrjala
2025-10-16 11:56   ` Kahola, Mika
2025-10-13 20:12 ` [PATCH 9/9] drm/i915: Neuter cdclk_prefill_adjustment() Ville Syrjala
2025-10-16 11:59   ` Kahola, Mika
2025-10-14  0:16 ` ✗ CI.checkpatch: warning for drm/i915: Reorder cdclk stuff for vblank/guardband length checks Patchwork
2025-10-14  0:17 ` ✓ CI.KUnit: success " Patchwork
2025-10-14  0:32 ` ✗ CI.checksparse: warning " Patchwork
2025-10-14  0:58 ` ✓ Xe.CI.BAT: success " Patchwork
2025-10-14  8:53 ` ✗ Xe.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=20251013201236.30084-5-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /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