Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: <intel-gfx@lists.freedesktop.org>, <intel-xe@lists.freedesktop.org>
Subject: [PATCH 3/5] drm/i915/dp_tunnel: Split update_tunnel_state()
Date: Thu, 19 Feb 2026 20:28:21 +0200	[thread overview]
Message-ID: <20260219182823.926702-4-imre.deak@intel.com> (raw)
In-Reply-To: <20260219182823.926702-1-imre.deak@intel.com>

Split update_tunnel_state() into two helpers: one that updates the
tunnel state, and another that detects whether the tunnel bandwidth
has changed.

This prepares for a follow-up change that needs to compare the current
bandwidth against the value from before the DP tunnel was detected and
bandwidth allocation mode was enabled.

While at it, document the return value of update_tunnel_state().

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 .../gpu/drm/i915/display/intel_dp_tunnel.c    | 41 +++++++++++++++----
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_tunnel.c b/drivers/gpu/drm/i915/display/intel_dp_tunnel.c
index 9f3750035f68e..5840b92dace19 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_tunnel.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_tunnel.c
@@ -62,16 +62,12 @@ static int get_current_link_bw(struct intel_dp *intel_dp)
 	return intel_dp_max_link_data_rate(intel_dp, rate, lane_count);
 }
 
-static int update_tunnel_state(struct intel_dp *intel_dp)
+static int __update_tunnel_state(struct intel_dp *intel_dp)
 {
 	struct intel_display *display = to_intel_display(intel_dp);
 	struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
-	int old_bw;
-	int new_bw;
 	int ret;
 
-	old_bw = get_current_link_bw(intel_dp);
-
 	ret = drm_dp_tunnel_update_state(intel_dp->tunnel);
 	if (ret < 0) {
 		drm_dbg_kms(display->drm,
@@ -89,11 +85,20 @@ static int update_tunnel_state(struct intel_dp *intel_dp)
 
 	intel_dp_update_sink_caps(intel_dp);
 
+	return 0;
+}
+
+static bool has_tunnel_bw_changed(struct intel_dp *intel_dp, int old_bw)
+{
+	struct intel_display *display = to_intel_display(intel_dp);
+	struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
+	int new_bw;
+
 	new_bw = get_current_link_bw(intel_dp);
 
 	/* Suppress the notification if the mode list can't change due to bw. */
 	if (old_bw == new_bw)
-		return 0;
+		return false;
 
 	drm_dbg_kms(display->drm,
 		    "[DPTUN %s][ENCODER:%d:%s] Notify users about BW change: %d -> %d\n",
@@ -101,7 +106,29 @@ static int update_tunnel_state(struct intel_dp *intel_dp)
 		    encoder->base.base.id, encoder->base.name,
 		    kbytes_to_mbits(old_bw), kbytes_to_mbits(new_bw));
 
-	return 1;
+	return true;
+}
+
+/*
+ * Returns:
+ * - 0 in case of success - if there wasn't any change in the tunnel state
+ *   requiring a user notification
+ * - 1 in case of success - if there was a change in the tunnel state
+ *   requiring a user notification
+ * - Negative error code if updating the tunnel state failed
+ */
+static int update_tunnel_state(struct intel_dp *intel_dp)
+{
+	int old_bw;
+	int err;
+
+	old_bw = get_current_link_bw(intel_dp);
+
+	err = __update_tunnel_state(intel_dp);
+	if (err)
+		return err;
+
+	return has_tunnel_bw_changed(intel_dp, old_bw) ? 1 : 0;
 }
 
 /*
-- 
2.49.1


  parent reply	other threads:[~2026-02-19 18:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19 18:28 [PATCH 0/5] drm/i915/dp_tunnel: Preparation for UHBR DP tunnels Imre Deak
2026-02-19 18:28 ` [PATCH 1/5] drm/i915/dp_tunnel: Don't update tunnel state during system resume Imre Deak
2026-02-23 15:54   ` Murthy, Arun R
2026-02-23 16:30     ` Imre Deak
2026-02-24  2:33       ` Murthy, Arun R
2026-02-24  7:49         ` Imre Deak
2026-02-24 12:55           ` Murthy, Arun R
2026-02-19 18:28 ` [PATCH 2/5] drm/i915/dp_tunnel: Simplify detection of link BW change Imre Deak
2026-02-23 16:02   ` Murthy, Arun R
2026-02-23 16:35     ` Imre Deak
2026-02-24 12:56       ` Murthy, Arun R
2026-02-19 18:28 ` Imre Deak [this message]
2026-02-24 12:57   ` [PATCH 3/5] drm/i915/dp_tunnel: Split update_tunnel_state() Murthy, Arun R
2026-02-19 18:28 ` [PATCH 4/5] drm/i915/dp_tunnel: Sanitize documentation of intel_dp_tunnel_detect() Imre Deak
2026-02-23 16:12   ` Murthy, Arun R
2026-02-23 16:45     ` Imre Deak
2026-02-24  2:36       ` Murthy, Arun R
2026-02-24  7:55         ` Imre Deak
2026-02-24 12:55           ` Murthy, Arun R
2026-02-19 18:28 ` [PATCH 5/5] drm/i915/dp_tunnel: Send BW change notification after tunnel creation Imre Deak
2026-02-24 12:58   ` Murthy, Arun R
2026-02-19 19:28 ` ✓ CI.KUnit: success for drm/i915/dp_tunnel: Preparation for UHBR DP tunnels Patchwork
2026-02-20  8:42 ` ✓ Xe.CI.BAT: " Patchwork
2026-02-20 13:42 ` ✗ 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=20260219182823.926702-4-imre.deak@intel.com \
    --to=imre.deak@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