]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Add usb4_bw_alloc_support flag
authorPeichen Huang <peichen.huang@amd.com>
Tue, 9 Jan 2024 06:13:16 +0000 (14:13 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 22 Jan 2024 22:13:27 +0000 (17:13 -0500)
[Why]
dc should have a flag for DM to enable usb4_bw_alloc in dptx

[How]
- Add usb4_bw_alloc_support flag in dc_config

Reviewed-by: Wayne Lin <wayne.lin@amd.com>
Reviewed-by: Meenakshikumar Somasundaram <meenakshikumar.somasundaram@amd.com>
Acked-by: Roman Li <roman.li@amd.com>
Signed-off-by: Peichen Huang <peichen.huang@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dc.h
drivers/gpu/drm/amd/display/dc/link/link_detection.c
drivers/gpu/drm/amd/display/dc/link/link_dpms.c

index 432ae08462e4dac0269e28628f5272e1dcf0f6af..e338576f95a9a2b48719b087da3952a0b333fe95 100644 (file)
@@ -435,6 +435,7 @@ struct dc_config {
        bool enable_auto_dpm_test_logs;
        unsigned int disable_ips;
        unsigned int disable_ips_in_vpb;
+       bool usb4_bw_alloc_support;
 };
 
 enum visual_confirm {
index 24153b0df503dd77a672526ac911947ac272e789..b8c4a04dd175789e92a4076ba5eb82a6aae573c4 100644 (file)
@@ -41,6 +41,7 @@
 #include "protocols/link_dp_dpia.h"
 #include "protocols/link_dp_phy.h"
 #include "protocols/link_dp_training.h"
+#include "protocols/link_dp_dpia_bw.h"
 #include "accessories/link_dp_trace.h"
 
 #include "link_enc_cfg.h"
@@ -991,6 +992,23 @@ static bool detect_link_and_local_sink(struct dc_link *link,
                        if (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA &&
                                        link->reported_link_cap.link_rate > LINK_RATE_HIGH3)
                                link->reported_link_cap.link_rate = LINK_RATE_HIGH3;
+
+                       /*
+                        * If this is DP over USB4 link then we need to:
+                        * - Enable BW ALLOC support on DPtx if applicable
+                        */
+                       if (dc->config.usb4_bw_alloc_support) {
+                               if (link_dp_dpia_set_dptx_usb4_bw_alloc_support(link)) {
+                                       /* update with non reduced link cap if bw allocation mode is supported */
+                                       if (link->dpia_bw_alloc_config.nrd_max_link_rate &&
+                                               link->dpia_bw_alloc_config.nrd_max_lane_count) {
+                                               link->reported_link_cap.link_rate =
+                                                       link->dpia_bw_alloc_config.nrd_max_link_rate;
+                                               link->reported_link_cap.lane_count =
+                                                       link->dpia_bw_alloc_config.nrd_max_lane_count;
+                                       }
+                               }
+                       }
                        break;
                }
 
index 3cbfbf8d107e9b62c639ef1618041b8fc09dd9b5..a72de44a5747a446e655536747c40135df2a686a 100644 (file)
@@ -2197,6 +2197,64 @@ static enum dc_status enable_link(
 
 static bool allocate_usb4_bandwidth_for_stream(struct dc_stream_state *stream, int bw)
 {
+       struct dc_link *link = stream->sink->link;
+       int req_bw = bw;
+
+       DC_LOGGER_INIT(link->ctx->logger);
+
+       if (!link->dpia_bw_alloc_config.bw_alloc_enabled)
+               return false;
+
+       if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
+               int sink_index = 0;
+               int i = 0;
+
+               for (i = 0; i < link->sink_count; i++) {
+                       if (link->remote_sinks[i] == NULL)
+                               continue;
+
+                       if (stream->sink->sink_id != link->remote_sinks[i]->sink_id)
+                               req_bw += link->dpia_bw_alloc_config.remote_sink_req_bw[i];
+                       else
+                               sink_index = i;
+               }
+
+               link->dpia_bw_alloc_config.remote_sink_req_bw[sink_index] = bw;
+       }
+
+       /* get dp overhead for dp tunneling */
+       link->dpia_bw_alloc_config.dp_overhead = link_dp_dpia_get_dp_overhead_in_dp_tunneling(link);
+       req_bw += link->dpia_bw_alloc_config.dp_overhead;
+
+       if (link_dp_dpia_allocate_usb4_bandwidth_for_stream(link, req_bw)) {
+               if (req_bw <= link->dpia_bw_alloc_config.allocated_bw) {
+                       DC_LOG_DEBUG("%s, Success in allocate bw for link(%d), allocated_bw(%d), dp_overhead(%d)\n",
+                                       __func__, link->link_index, link->dpia_bw_alloc_config.allocated_bw,
+                                       link->dpia_bw_alloc_config.dp_overhead);
+               } else {
+                       // Cannot get the required bandwidth.
+                       DC_LOG_ERROR("%s, Failed to allocate bw for link(%d), allocated_bw(%d), dp_overhead(%d)\n",
+                                       __func__, link->link_index, link->dpia_bw_alloc_config.allocated_bw,
+                                       link->dpia_bw_alloc_config.dp_overhead);
+                       return false;
+               }
+       } else {
+               DC_LOG_DEBUG("%s, usb4 request bw timeout\n", __func__);
+               return false;
+       }
+
+       if (stream->signal == SIGNAL_TYPE_DISPLAY_PORT_MST) {
+               int i = 0;
+
+               for (i = 0; i < link->sink_count; i++) {
+                       if (link->remote_sinks[i] == NULL)
+                               continue;
+                       DC_LOG_DEBUG("%s, remote_sink=%s, request_bw=%d\n", __func__,
+                                       (const char *)(&link->remote_sinks[i]->edid_caps.display_name[0]),
+                                       link->dpia_bw_alloc_config.remote_sink_req_bw[i]);
+               }
+       }
+
        return true;
 }