drm/i915/dp_mst: Reprobe the MST topology after a link parameter change
authorImre Deak <imre.deak@intel.com>
Mon, 22 Jul 2024 16:55:01 +0000 (19:55 +0300)
committerImre Deak <imre.deak@intel.com>
Wed, 31 Jul 2024 15:45:59 +0000 (18:45 +0300)
The MST link BW reported by branch devices via the ENUM_PATH_RESOURCES
message depends on the channel coding and link rate/lane count
parameters programmed to DPCD. This is the case at least for some branch
devices, while for others the reported BW is independent of the link
parameters. In any case the DP standard requires the branch device to
adjust the returned value to both account for the different way the BW
for FEC is accounted for (included in the returned value for non-UHBR
and not included for UHBR rates) and to limit the returned value to the
(trained) link BW between the source and first downstream branch
device, see DP v2.0/v2.1 Figure 2-94, DP v2.1 5.9.7. Presumedly this is
also the reason why the standard requires the DPCD link rate/lane count
values being up-to-date before sending the ENUM_PATH_RESOURCES message,
see DP v2.1 2.14.9.4.

Based on the above reprobe the MST topology after the link is retrained
with new link parameters to make sure that the MST link BW tracked in
the MST topology state (via each topology port's full_pbn value) is
up-to-date.

The next patch will make sure that the MST link BW is also kept
up-to-date if the link is disabled.

Reviewed-by: Suraj Kandpal <suraj.kandpal@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240722165503.2084999-13-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_display_types.h
drivers/gpu/drm/i915/display/intel_dp.c
drivers/gpu/drm/i915/display/intel_dp_mst.c

index ac98bb57456e018931d4aeede56d58ee0ec0b8d6..327a4133030f3b6ae3d4b8f7fa0d79bc2438a581 100644 (file)
@@ -1794,6 +1794,14 @@ struct intel_dp {
                int max_lane_count;
                /* Max rate for the current link */
                int max_rate;
+               /*
+                * Link parameters for which the MST topology was probed.
+                * Tracking these ensures that the MST path resources are
+                * re-enumerated whenever the link is retrained with new link
+                * parameters, as required by the DP standard.
+                */
+               int mst_probed_lane_count;
+               int mst_probed_rate;
                int force_lane_count;
                int force_rate;
                bool retrain_disabled;
index d707ad666993b6514a3bf81666bc118d5c0cf281..5523469404f93d699a72fe400ca5f60f653b4ec3 100644 (file)
@@ -3126,6 +3126,8 @@ void intel_dp_reset_link_params(struct intel_dp *intel_dp)
 {
        intel_dp->link.max_lane_count = intel_dp_max_common_lane_count(intel_dp);
        intel_dp->link.max_rate = intel_dp_max_common_rate(intel_dp);
+       intel_dp->link.mst_probed_lane_count = 0;
+       intel_dp->link.mst_probed_rate = 0;
        intel_dp->link.retrain_disabled = false;
        intel_dp->link.seq_train_failures = 0;
 }
index 57f29906fa28f3e62673300ac3745fdaa60e0206..19c8b6878b030a9742c28dd4170c9366401c2550 100644 (file)
@@ -1113,6 +1113,33 @@ static void intel_mst_pre_pll_enable_dp(struct intel_atomic_state *state,
                                             to_intel_crtc(pipe_config->uapi.crtc));
 }
 
+static bool intel_mst_probed_link_params_valid(struct intel_dp *intel_dp,
+                                              int link_rate, int lane_count)
+{
+       return intel_dp->link.mst_probed_rate == link_rate &&
+               intel_dp->link.mst_probed_lane_count == lane_count;
+}
+
+static void intel_mst_set_probed_link_params(struct intel_dp *intel_dp,
+                                            int link_rate, int lane_count)
+{
+       intel_dp->link.mst_probed_rate = link_rate;
+       intel_dp->link.mst_probed_lane_count = lane_count;
+}
+
+static void intel_mst_reprobe_topology(struct intel_dp *intel_dp,
+                                      const struct intel_crtc_state *crtc_state)
+{
+       if (intel_mst_probed_link_params_valid(intel_dp,
+                                              crtc_state->port_clock, crtc_state->lane_count))
+               return;
+
+       drm_dp_mst_topology_queue_probe(&intel_dp->mst_mgr);
+
+       intel_mst_set_probed_link_params(intel_dp,
+                                        crtc_state->port_clock, crtc_state->lane_count);
+}
+
 static void intel_mst_pre_enable_dp(struct intel_atomic_state *state,
                                    struct intel_encoder *encoder,
                                    const struct intel_crtc_state *pipe_config,
@@ -1149,10 +1176,13 @@ static void intel_mst_pre_enable_dp(struct intel_atomic_state *state,
 
        intel_dp_sink_enable_decompression(state, connector, pipe_config);
 
-       if (first_mst_stream)
+       if (first_mst_stream) {
                dig_port->base.pre_enable(state, &dig_port->base,
                                                pipe_config, NULL);
 
+               intel_mst_reprobe_topology(intel_dp, pipe_config);
+       }
+
        intel_dp->active_mst_links++;
 
        ret = drm_dp_add_payload_part1(&intel_dp->mst_mgr, mst_state,