Commit 74a16675 authored by Rodrigo Siqueira's avatar Rodrigo Siqueira Committed by Alex Deucher

drm/amd/display: Add helper to convert DC status

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: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 0a25e8eb
......@@ -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;
}
......
......@@ -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";
}
......@@ -53,4 +53,6 @@ enum dc_status {
DC_ERROR_UNEXPECTED = -1
};
char *dc_status_to_str(enum dc_status status);
#endif /* _CORE_STATUS_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment