drm/amd/display: Add helper to convert DC status
authorRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Tue, 26 May 2020 20:53:38 +0000 (16:53 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 1 Jul 2020 05:59:20 +0000 (01:59 -0400)
During the debugging process related to a hot-plug
problem with 4k display, we realized that we had
some issues related to the global state validation.
This problem was not explicitly highlighted in the
dmesg log, for this reason, this commit adds a function
that converts `enum dc_status` to a human-readable
string and appends the proper warning message in case
of failure.

Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/dc/core/dc_debug.c
drivers/gpu/drm/amd/display/dc/inc/core_status.h

index c64beb2d6c5f282499d59709a5bb6e0f1e138b83..461ff7e511c34aa3cb9e9a0f7db47d6a992d8e87 100644 (file)
@@ -5066,11 +5066,12 @@ create_validate_stream_for_sink(struct amdgpu_dm_connector *aconnector,
                dc_result = dc_validate_stream(adev->dm.dc, stream);
 
                if (dc_result != DC_OK) {
-                       DRM_DEBUG_KMS("Mode %dx%d (clk %d) failed DC validation with error %d\n",
+                       DRM_DEBUG_KMS("Mode %dx%d (clk %d) failed DC validation with error %d (%s)\n",
                                      drm_mode->hdisplay,
                                      drm_mode->vdisplay,
                                      drm_mode->clock,
-                                     dc_result);
+                                     dc_result,
+                                     dc_status_to_str(dc_result));
 
                        dc_stream_release(stream);
                        stream = NULL;
@@ -8504,7 +8505,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
        struct drm_plane_state *old_plane_state, *new_plane_state;
        enum surface_update_type update_type = UPDATE_TYPE_FAST;
        enum surface_update_type overall_update_type = UPDATE_TYPE_FAST;
-
+       enum dc_status status;
        int ret, i;
 
        /*
@@ -8716,8 +8717,10 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
                ret = drm_dp_mst_atomic_check(state);
                if (ret)
                        goto fail;
-
-               if (dc_validate_global_state(dc, dm_state->context, false) != DC_OK) {
+               status = dc_validate_global_state(dc, dm_state->context, false);
+               if (status != DC_OK) {
+                       DC_LOG_WARNING("DC global validation failure: %s (%d)",
+                                      dc_status_to_str(status), status);
                        ret = -EINVAL;
                        goto fail;
                }
index 502ed3c7959d2ba04d9bcae41478638c55473f84..87d89449b9af84afd7e8bdfa52353f3543d4bbb4 100644 (file)
@@ -365,3 +365,62 @@ void context_clock_trace(
                        context->bw_ctx.bw.dcn.clk.socclk_khz);
 #endif
 }
+
+/**
+ * dc_status_to_str - convert dc_status to a human readable string
+ * @status: dc_status to be converted
+ *
+ * Return:
+ * A string describing the DC status.
+ */
+char *dc_status_to_str(enum dc_status status)
+{
+       switch (status) {
+       case DC_OK:
+               return "DC OK";
+       case DC_NO_CONTROLLER_RESOURCE:
+               return "No controller resource";
+       case DC_NO_STREAM_ENC_RESOURCE:
+               return "No stream encoder";
+       case DC_NO_CLOCK_SOURCE_RESOURCE:
+               return "No clock source";
+       case DC_FAIL_CONTROLLER_VALIDATE:
+               return "Controller validation failure";
+       case DC_FAIL_ENC_VALIDATE:
+               return "Encoder validation failure";
+       case DC_FAIL_ATTACH_SURFACES:
+               return "Surfaces attachment failure";
+       case DC_FAIL_DETACH_SURFACES:
+               return "Surfaces detachment failure";
+       case DC_FAIL_SURFACE_VALIDATE:
+               return "Surface validation failure";
+       case DC_NO_DP_LINK_BANDWIDTH:
+               return "No DP link bandwidth";
+       case DC_EXCEED_DONGLE_CAP:
+               return "Exceed dongle capability";
+       case DC_SURFACE_PIXEL_FORMAT_UNSUPPORTED:
+               return "Unsupported pixel format";
+       case DC_FAIL_BANDWIDTH_VALIDATE:
+               return "Bandwidth validation failure (BW and Watermark)";
+       case DC_FAIL_SCALING:
+               return "Scaling failure";
+       case DC_FAIL_DP_LINK_TRAINING:
+               return "DP link training failure";
+       case DC_FAIL_DSC_VALIDATE:
+               return "DSC validation failure";
+       case DC_NO_DSC_RESOURCE:
+               return "No DSC resource";
+       case DC_FAIL_UNSUPPORTED_1:
+               return "Unsupported";
+       case DC_FAIL_CLK_EXCEED_MAX:
+               return "Clk exceed max failure";
+       case DC_FAIL_CLK_BELOW_MIN:
+               return "Fail clk below minimum";
+       case DC_FAIL_CLK_BELOW_CFG_REQUIRED:
+               return "Fail clk below required CFG (hard_min in PPLIB)";
+       case DC_ERROR_UNEXPECTED:
+               return "Unexpected error";
+       }
+
+       return "Unexpected status error";
+}
index 4ead89dd7c418eed866cdcce35c019e4a979a2b7..f932801235c645b9761f80e4cd1bf53da7defb1b 100644 (file)
@@ -53,4 +53,6 @@ enum dc_status {
        DC_ERROR_UNEXPECTED = -1
 };
 
+char *dc_status_to_str(enum dc_status status);
+
 #endif /* _CORE_STATUS_H_ */