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

drm/i915/dp_mst: Add intel_dp_mst_{inc, dec}_active_streams()

Add helpers to increment/decrement the active MST stream count, instead
of open-coding these.

In mst_stream_pre_enable(), the increment will happen earlier, this is
ok, since nothing depends on the counter between the two points.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://lore.kernel.org/r/20250404150310.1156696-3-imre.deak@intel.com

+27 -16
+27 -16
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 105 105 return &dig_port->dp; 106 106 } 107 107 108 + static bool intel_dp_mst_dec_active_streams(struct intel_dp *intel_dp) 109 + { 110 + struct intel_display *display = to_intel_display(intel_dp); 111 + 112 + drm_dbg_kms(display->drm, "active MST streams %d -> %d\n", 113 + intel_dp->mst.active_links, intel_dp->mst.active_links - 1); 114 + 115 + if (drm_WARN_ON(display->drm, intel_dp->mst.active_links == 0)) 116 + return true; 117 + 118 + return --intel_dp->mst.active_links == 0; 119 + } 120 + 121 + static bool intel_dp_mst_inc_active_streams(struct intel_dp *intel_dp) 122 + { 123 + struct intel_display *display = to_intel_display(intel_dp); 124 + 125 + drm_dbg_kms(display->drm, "active MST streams %d -> %d\n", 126 + intel_dp->mst.active_links, intel_dp->mst.active_links + 1); 127 + 128 + return intel_dp->mst.active_links++ == 0; 129 + } 130 + 108 131 static int intel_dp_mst_max_dpt_bpp(const struct intel_crtc_state *crtc_state, 109 132 bool dsc) 110 133 { ··· 1023 1000 to_intel_connector(old_conn_state->connector); 1024 1001 enum transcoder trans = old_crtc_state->cpu_transcoder; 1025 1002 1026 - drm_dbg_kms(display->drm, "active links %d\n", 1027 - intel_dp->mst.active_links); 1028 - 1029 1003 if (intel_dp->mst.active_links == 1) 1030 1004 intel_dp->link.active = false; 1031 1005 ··· 1057 1037 bool last_mst_stream; 1058 1038 int i; 1059 1039 1060 - intel_dp->mst.active_links--; 1061 - last_mst_stream = intel_dp->mst.active_links == 0; 1040 + last_mst_stream = intel_dp_mst_dec_active_streams(intel_dp); 1041 + 1062 1042 drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 12 && last_mst_stream && 1063 1043 !intel_dp_mst_is_master_trans(old_crtc_state)); 1064 1044 ··· 1129 1109 primary_encoder->post_disable(state, primary_encoder, 1130 1110 old_crtc_state, NULL); 1131 1111 1132 - drm_dbg_kms(display->drm, "active links %d\n", 1133 - intel_dp->mst.active_links); 1134 1112 } 1135 1113 1136 1114 static void mst_stream_post_pll_disable(struct intel_atomic_state *state, ··· 1212 1194 */ 1213 1195 connector->encoder = encoder; 1214 1196 intel_mst->connector = connector; 1215 - first_mst_stream = intel_dp->mst.active_links == 0; 1197 + 1198 + first_mst_stream = intel_dp_mst_inc_active_streams(intel_dp); 1216 1199 drm_WARN_ON(display->drm, DISPLAY_VER(display) >= 12 && first_mst_stream && 1217 1200 !intel_dp_mst_is_master_trans(pipe_config)); 1218 - 1219 - drm_dbg_kms(display->drm, "active links %d\n", 1220 - intel_dp->mst.active_links); 1221 1201 1222 1202 if (first_mst_stream) 1223 1203 intel_dp_set_power(intel_dp, DP_SET_POWER_D0); ··· 1230 1214 1231 1215 intel_mst_reprobe_topology(intel_dp, pipe_config); 1232 1216 } 1233 - 1234 - intel_dp->mst.active_links++; 1235 1217 1236 1218 ret = drm_dp_add_payload_part1(&intel_dp->mst.mgr, mst_state, 1237 1219 drm_atomic_get_mst_payload_state(mst_state, connector->mst.port)); ··· 1348 1334 1349 1335 intel_de_rmw(display, TRANS_DDI_FUNC_CTL(display, trans), 0, 1350 1336 TRANS_DDI_DP_VC_PAYLOAD_ALLOC); 1351 - 1352 - drm_dbg_kms(display->drm, "active links %d\n", 1353 - intel_dp->mst.active_links); 1354 1337 1355 1338 intel_ddi_wait_for_act_sent(encoder, pipe_config); 1356 1339 drm_dp_check_act_status(&intel_dp->mst.mgr);