drm/amd/display: Add return value for detect dp.
authorYongqiang Sun <yongqiang.sun@amd.com>
Tue, 23 Jan 2018 16:39:09 +0000 (11:39 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 19 Feb 2018 19:19:32 +0000 (14:19 -0500)
System soft hang when hotplug specific 4K DP panel
due to link caps read error and incorrect link setting
parmas to enable dp.
Add status check for DPCD read and add return value
for detect dp, in case of false, return from caller,
avoid further false operation.

Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h

index a678fc012977a31b4f454b0d8611da37cdd44310..629aa042f9ddee250d90640ecf38c3ae1c555796 100644 (file)
@@ -465,7 +465,7 @@ static void link_disconnect_sink(struct dc_link *link)
        link->dpcd_sink_count = 0;
 }
 
-static void detect_dp(
+static bool detect_dp(
        struct dc_link *link,
        struct display_sink_capability *sink_caps,
        bool *converter_disable_audio,
@@ -479,7 +479,8 @@ static void detect_dp(
 
        if (sink_caps->transaction_type == DDC_TRANSACTION_TYPE_I2C_OVER_AUX) {
                sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT;
-               detect_dp_sink_caps(link);
+               if (!detect_dp_sink_caps(link))
+                       return false;
 
                if (is_mst_supported(link)) {
                        sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT_MST;
@@ -530,7 +531,7 @@ static void detect_dp(
                                 * active dongle unplug processing for short irq
                                 */
                                link_disconnect_sink(link);
-                               return;
+                               return true;
                        }
 
                        if (link->dpcd_caps.dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER)
@@ -542,6 +543,8 @@ static void detect_dp(
                                sink_caps,
                                audio_support);
        }
+
+       return true;
 }
 
 bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
@@ -605,11 +608,12 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
                }
 
                case SIGNAL_TYPE_DISPLAY_PORT: {
-                       detect_dp(
+                       if (!detect_dp(
                                link,
                                &sink_caps,
                                &converter_disable_audio,
-                               aud_support, reason);
+                               aud_support, reason))
+                               return false;
 
                        /* Active dongle downstream unplug */
                        if (link->type == dc_connection_active_dongle
index 33d91e4474ea174f9bd7c48f35a5fe94d6b593b4..4ee4c03a6724fde4b4994c7aaa1c54c9c0536fe0 100644 (file)
@@ -2235,13 +2235,14 @@ static void dp_wa_power_up_0010FA(struct dc_link *link, uint8_t *dpcd_data,
                link->wa_flags.dp_keep_receiver_powered = false;
 }
 
-static void retrieve_link_cap(struct dc_link *link)
+static bool retrieve_link_cap(struct dc_link *link)
 {
        uint8_t dpcd_data[DP_TRAINING_AUX_RD_INTERVAL - DP_DPCD_REV + 1];
 
        union down_stream_port_count down_strm_port_count;
        union edp_configuration_cap edp_config_cap;
        union dp_downstream_port_present ds_port = { 0 };
+       enum dc_status status = DC_ERROR_UNEXPECTED;
 
        memset(dpcd_data, '\0', sizeof(dpcd_data));
        memset(&down_strm_port_count,
@@ -2249,11 +2250,16 @@ static void retrieve_link_cap(struct dc_link *link)
        memset(&edp_config_cap, '\0',
                sizeof(union edp_configuration_cap));
 
-       core_link_read_dpcd(
-               link,
-               DP_DPCD_REV,
-               dpcd_data,
-               sizeof(dpcd_data));
+       status = core_link_read_dpcd(
+                       link,
+                       DP_DPCD_REV,
+                       dpcd_data,
+                       sizeof(dpcd_data));
+
+       if (status != DC_OK) {
+               dm_error("%s: Read dpcd data failed.\n", __func__);
+               return false;
+       }
 
        {
                union training_aux_rd_interval aux_rd_interval;
@@ -2315,11 +2321,13 @@ static void retrieve_link_cap(struct dc_link *link)
 
        /* Connectivity log: detection */
        CONN_DATA_DETECT(link, dpcd_data, sizeof(dpcd_data), "Rx Caps: ");
+
+       return true;
 }
 
-void detect_dp_sink_caps(struct dc_link *link)
+bool detect_dp_sink_caps(struct dc_link *link)
 {
-       retrieve_link_cap(link);
+       return retrieve_link_cap(link);
 
        /* dc init_hw has power encoder using default
         * signal for connector. For native DP, no
index 616c73e2b0bd8a17a87b10044b00cdc02b80436d..2f783c6500842452b63f290d9c8688ff4c5f7e17 100644 (file)
@@ -53,7 +53,7 @@ bool perform_link_training_with_retries(
 
 bool is_mst_supported(struct dc_link *link);
 
-void detect_dp_sink_caps(struct dc_link *link);
+bool detect_dp_sink_caps(struct dc_link *link);
 
 void detect_edp_sink_caps(struct dc_link *link);