[PATCH 062/108] drm/i915/dp_link_caps: Adjust max_limits when setting or resetting it

Imre Deak
2026-04-28T12:54:48Z

Adjust max_limits when setting or resetting it, accounting for all other
constraints that limit the allowed configurations, similar to how it is
adjusted during a link configuration update. On detecting
inconsistencies, all restrictions are removed, ensuring at least one
allowed link configuration.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
.../gpu/drm/i915/display/intel_dp_link_caps.c | 20 +++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
index 112d343c6d9d6..7c6259c95d388 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -444,7 +444,9 @@ static bool max_link_limits_valid(struct intel_dp_link_caps *link_caps,
* @max_link_limits: new maximum link limits
*
* Set the current maximum rate and lane count limits to @max_link_limits,
- * constraining the set of allowed configurations.
+ * after adjusting @max_link_limits to the currently allowed configuration
+ * set. Since the old @max_link_limits also constrains this allowed set, the
+ * new adjusted value of @max_link_limits will be at or below the old one.
*
* The new limits must leave at least one configuration allowed: the limits
* must not be below the currently active forced parameters or below all the
@@ -456,8 +458,10 @@ static bool max_link_limits_valid(struct intel_dp_link_caps *link_caps,
*
* Return:
* - %true if the @link_caps cached max limits value got updated with
- * @max_link_limits.
- * - %false if @max_link_limits is invalid.
+ * @max_link_limits along with all the max link information.
+ * - %false if @max_link_limits is invalid, or if max link info update
+ * fails due to an internal consistency issue. In the latter
+ * case return after resetting all limits and restrictions.
*/
bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,
const struct intel_dp_link_config *max_link_limits)
@@ -467,7 +471,7 @@ bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,

set_max_link_limits_no_update(link_caps, max_link_limits);

- return true;
+ return update_max_link_info(link_caps);
}

/**
@@ -475,11 +479,14 @@ bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,
* @link_caps: link capabilities state
*
* Reset the current maximum link limits to the maximum supported common link
- * rate and lane count.
+ * rate and lane count, then update the derived maximum-link information
+ * accordingly.
*/
void intel_dp_link_caps_reset_max_limits(struct intel_dp_link_caps *link_caps)
{
reset_max_link_limits_no_update(link_caps);
+ /* On failure the following removes all restrictions. */
+ update_max_link_info(link_caps);
}

static int intel_dp_link_config_bw(struct intel_dp_link_caps *link_caps,
@@ -675,8 +682,9 @@ int intel_dp_link_config_index(struct intel_dp_link_caps *link_caps,
*/
void intel_dp_link_caps_reset(struct intel_dp_link_caps *link_caps)
{
- /* TODO: Update the limits to account for forced params. */
reset_max_link_limits_no_update(link_caps);
+ /* On failure the following removes all restrictions. */
+ update_max_link_info(link_caps);
}

static int i915_dp_force_link_rate_show(struct seq_file *m, void *data)
--
2.49.1