From bcc7907398c84c139461b60925427955caf4db6a Mon Sep 17 00:00:00 2001 From: Imre Deak Date: Thu, 19 Feb 2026 20:28:21 +0200 Subject: [PATCH] drm/i915/dp_tunnel: Split update_tunnel_state() 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(). Reviewed-by: Arun R Murthy Signed-off-by: Imre Deak Link: https://patch.msgid.link/20260219182823.926702-4-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 b95fdafa3d36..b3b3c064ac2a 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; } /*