Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/dp_mst: Add the MST topology state for modesetted CRTCs

Add the MST topology for a CRTC to the atomic state if the driver
needs to force a modeset on the CRTC after the encoder compute config
functions are called.

Later the MST encoder's disable hook also adds the state, but that isn't
guaranteed to work (since in that hook getting the state may fail, which
can't be handled there). This should fix that, while a later patch fixes
the use of the MST state in the disable hook.

v2: Add missing forward struct declartions, caught by hdrtest.
v3: Factor out intel_dp_mst_add_topology_state_for_connector() used
later in the patchset.

Cc: Lyude Paul <lyude@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: stable@vger.kernel.org # 6.1
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> # v2
Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Lyude Paul <lyude@redhat.com>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Acked-by: Wayne Lin <wayne.lin@amd.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230206114856.2665066-1-imre.deak@intel.com

+69
+4
drivers/gpu/drm/i915/display/intel_display.c
··· 5934 5934 if (ret) 5935 5935 return ret; 5936 5936 5937 + ret = intel_dp_mst_add_topology_state_for_crtc(state, crtc); 5938 + if (ret) 5939 + return ret; 5940 + 5937 5941 ret = intel_atomic_add_affected_planes(state, crtc); 5938 5942 if (ret) 5939 5943 return ret;
+61
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 1223 1223 return crtc_state->mst_master_transcoder != INVALID_TRANSCODER && 1224 1224 crtc_state->mst_master_transcoder != crtc_state->cpu_transcoder; 1225 1225 } 1226 + 1227 + /** 1228 + * intel_dp_mst_add_topology_state_for_connector - add MST topology state for a connector 1229 + * @state: atomic state 1230 + * @connector: connector to add the state for 1231 + * @crtc: the CRTC @connector is attached to 1232 + * 1233 + * Add the MST topology state for @connector to @state. 1234 + * 1235 + * Returns 0 on success, negative error code on failure. 1236 + */ 1237 + static int 1238 + intel_dp_mst_add_topology_state_for_connector(struct intel_atomic_state *state, 1239 + struct intel_connector *connector, 1240 + struct intel_crtc *crtc) 1241 + { 1242 + struct drm_dp_mst_topology_state *mst_state; 1243 + 1244 + if (!connector->mst_port) 1245 + return 0; 1246 + 1247 + mst_state = drm_atomic_get_mst_topology_state(&state->base, 1248 + &connector->mst_port->mst_mgr); 1249 + if (IS_ERR(mst_state)) 1250 + return PTR_ERR(mst_state); 1251 + 1252 + mst_state->pending_crtc_mask |= drm_crtc_mask(&crtc->base); 1253 + 1254 + return 0; 1255 + } 1256 + 1257 + /** 1258 + * intel_dp_mst_add_topology_state_for_crtc - add MST topology state for a CRTC 1259 + * @state: atomic state 1260 + * @crtc: CRTC to add the state for 1261 + * 1262 + * Add the MST topology state for @crtc to @state. 1263 + * 1264 + * Returns 0 on success, negative error code on failure. 1265 + */ 1266 + int intel_dp_mst_add_topology_state_for_crtc(struct intel_atomic_state *state, 1267 + struct intel_crtc *crtc) 1268 + { 1269 + struct drm_connector *_connector; 1270 + struct drm_connector_state *conn_state; 1271 + int i; 1272 + 1273 + for_each_new_connector_in_state(&state->base, _connector, conn_state, i) { 1274 + struct intel_connector *connector = to_intel_connector(_connector); 1275 + int ret; 1276 + 1277 + if (conn_state->crtc != &crtc->base) 1278 + continue; 1279 + 1280 + ret = intel_dp_mst_add_topology_state_for_connector(state, connector, crtc); 1281 + if (ret) 1282 + return ret; 1283 + } 1284 + 1285 + return 0; 1286 + }
+4
drivers/gpu/drm/i915/display/intel_dp_mst.h
··· 8 8 9 9 #include <linux/types.h> 10 10 11 + struct intel_atomic_state; 12 + struct intel_crtc; 11 13 struct intel_crtc_state; 12 14 struct intel_digital_port; 13 15 struct intel_dp; ··· 20 18 bool intel_dp_mst_is_master_trans(const struct intel_crtc_state *crtc_state); 21 19 bool intel_dp_mst_is_slave_trans(const struct intel_crtc_state *crtc_state); 22 20 bool intel_dp_mst_source_support(struct intel_dp *intel_dp); 21 + int intel_dp_mst_add_topology_state_for_crtc(struct intel_atomic_state *state, 22 + struct intel_crtc *crtc); 23 23 24 24 #endif /* __INTEL_DP_MST_H__ */