Merge tag 'drm-intel-next-2023-11-23' of git://anongit.freedesktop.org/drm/drm-intel...
[linux-2.6-block.git] / drivers / gpu / drm / amd / display / amdgpu_dm / amdgpu_dm_mst_types.c
index d80f19e442bfb098269461a212dbd1037162f1af..3608d520b22774e6fcecbfc14510bbc90fa5efb9 100644 (file)
@@ -174,8 +174,9 @@ amdgpu_dm_mst_connector_early_unregister(struct drm_connector *connector)
                if (dc_link->sink_count)
                        dc_link_remove_remote_sink(dc_link, dc_sink);
 
-               DC_LOG_MST("DM_MST: remove remote sink 0x%p, %d remaining\n",
-                       dc_sink, dc_link->sink_count);
+               drm_dbg_dp(connector->dev,
+                          "DM_MST: remove remote sink 0x%p, %d remaining\n",
+                          dc_sink, dc_link->sink_count);
 
                dc_sink_release(dc_sink);
                aconnector->dc_sink = NULL;
@@ -326,8 +327,10 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
                                        return 0;
                                }
 
-                               DC_LOG_MST("DM_MST: add remote sink 0x%p, %d remaining\n",
-                                       dc_sink, aconnector->dc_link->sink_count);
+                               drm_dbg_dp(connector->dev,
+                                          "DM_MST: add remote sink 0x%p, %d remaining\n",
+                                          dc_sink,
+                                          aconnector->dc_link->sink_count);
 
                                dc_sink->priv = aconnector;
                                aconnector->dc_sink = dc_sink;
@@ -362,8 +365,9 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
                        return 0;
                }
 
-               DC_LOG_MST("DM_MST: add remote sink 0x%p, %d remaining\n",
-                       dc_sink, aconnector->dc_link->sink_count);
+               drm_dbg_dp(connector->dev,
+                          "DM_MST: add remote sink 0x%p, %d remaining\n",
+                          dc_sink, aconnector->dc_link->sink_count);
 
                dc_sink->priv = aconnector;
                /* dc_link_add_remote_sink returns a new reference */
@@ -482,8 +486,10 @@ dm_dp_mst_detect(struct drm_connector *connector,
                if (aconnector->dc_link->sink_count)
                        dc_link_remove_remote_sink(aconnector->dc_link, aconnector->dc_sink);
 
-               DC_LOG_MST("DM_MST: remove remote sink 0x%p, %d remaining\n",
-                       aconnector->dc_link, aconnector->dc_link->sink_count);
+               drm_dbg_dp(connector->dev,
+                          "DM_MST: remove remote sink 0x%p, %d remaining\n",
+                          aconnector->dc_link,
+                          aconnector->dc_link->sink_count);
 
                dc_sink_release(aconnector->dc_sink);
                aconnector->dc_sink = NULL;
@@ -1599,31 +1605,31 @@ enum dc_status dm_dp_mst_is_port_support_mode(
        unsigned int upper_link_bw_in_kbps = 0, down_link_bw_in_kbps = 0;
        unsigned int max_compressed_bw_in_kbps = 0;
        struct dc_dsc_bw_range bw_range = {0};
-       struct drm_dp_mst_topology_mgr *mst_mgr;
+       uint16_t full_pbn = aconnector->mst_output_port->full_pbn;
 
        /*
-        * check if the mode could be supported if DSC pass-through is supported
-        * AND check if there enough bandwidth available to support the mode
-        * with DSC enabled.
+        * Consider the case with the depth of the mst topology tree is equal or less than 2
+        * A. When dsc bitstream can be transmitted along the entire path
+        *    1. dsc is possible between source and branch/leaf device (common dsc params is possible), AND
+        *    2. dsc passthrough supported at MST branch, or
+        *    3. dsc decoding supported at leaf MST device
+        *    Use maximum dsc compression as bw constraint
+        * B. When dsc bitstream cannot be transmitted along the entire path
+        *    Use native bw as bw constraint
         */
        if (is_dsc_common_config_possible(stream, &bw_range) &&
-           aconnector->mst_output_port->passthrough_aux) {
-               mst_mgr = aconnector->mst_output_port->mgr;
-               mutex_lock(&mst_mgr->lock);
-
+          (aconnector->mst_output_port->passthrough_aux ||
+           aconnector->dsc_aux == &aconnector->mst_output_port->aux)) {
                cur_link_settings = stream->link->verified_link_cap;
 
                upper_link_bw_in_kbps = dc_link_bandwidth_kbps(aconnector->dc_link,
-                                                              &cur_link_settings
-                                                              );
-               down_link_bw_in_kbps = kbps_from_pbn(aconnector->mst_output_port->full_pbn);
+                                                              &cur_link_settings);
+               down_link_bw_in_kbps = kbps_from_pbn(full_pbn);
 
                /* pick the bottleneck */
                end_to_end_bw_in_kbps = min(upper_link_bw_in_kbps,
                                            down_link_bw_in_kbps);
 
-               mutex_unlock(&mst_mgr->lock);
-
                /*
                 * use the maximum dsc compression bandwidth as the required
                 * bandwidth for the mode
@@ -1638,8 +1644,7 @@ enum dc_status dm_dp_mst_is_port_support_mode(
                /* check if mode could be supported within full_pbn */
                bpp = convert_dc_color_depth_into_bpc(stream->timing.display_color_depth) * 3;
                pbn = drm_dp_calc_pbn_mode(stream->timing.pix_clk_100hz / 10, bpp << 4);
-
-               if (pbn > aconnector->mst_output_port->full_pbn)
+               if (pbn > full_pbn)
                        return DC_FAIL_BANDWIDTH_VALIDATE;
        }