Commit 07d72b39 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amd/display: Return context from validate_context

This will allow us to carry it from check to commit
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Acked-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 8122a253
......@@ -1384,6 +1384,7 @@ int amdgpu_dm_connector_mode_valid(
/* TODO: Unhardcode stream count */
struct dc_stream *stream;
struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
struct validate_context *context;
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) ||
(mode->flags & DRM_MODE_FLAG_DBLSCAN))
......@@ -1418,8 +1419,13 @@ int amdgpu_dm_connector_mode_valid(
stream->src.height = mode->vdisplay;
stream->dst = stream->src;
if (dc_validate_resources(adev->dm.dc, &val_set, 1))
context = dc_get_validate_context(adev->dm.dc, &val_set, 1);
if (context) {
result = MODE_OK;
dc_resource_validate_ctx_destruct(context);
dm_free(context);
}
dc_stream_release(stream);
......@@ -2842,6 +2848,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
struct amdgpu_device *adev = dev->dev_private;
struct dc *dc = adev->dm.dc;
bool need_to_validate = false;
struct validate_context *context;
ret = drm_atomic_helper_check(dev, state);
......@@ -3064,15 +3071,20 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,
}
}
if (need_to_validate == false || set_count == 0 ||
dc_validate_resources(dc, set, set_count))
context = dc_get_validate_context(dc, set, set_count);
if (need_to_validate == false || set_count == 0 || context)
ret = 0;
for (i = 0; i < set_count; i++) {
for (j = 0; j < set[i].surface_count; j++) {
dc_surface_release(set[i].surfaces[j]);
}
if (context) {
dc_resource_validate_ctx_destruct(context);
dm_free(context);
}
for (i = 0; i < set_count; i++)
for (j = 0; j < set[i].surface_count; j++)
dc_surface_release(set[i].surfaces[j]);
for (i = 0; i < new_stream_count; i++)
dc_stream_release(new_streams[i]);
......
......@@ -635,7 +635,7 @@ static bool is_validation_required(
return false;
}
bool dc_validate_resources(
struct validate_context *dc_get_validate_context(
const struct dc *dc,
const struct dc_validation_set set[],
uint8_t set_count)
......@@ -644,31 +644,51 @@ bool dc_validate_resources(
enum dc_status result = DC_ERROR_UNEXPECTED;
struct validate_context *context;
if (!is_validation_required(core_dc, set, set_count))
return true;
context = dm_alloc(sizeof(struct validate_context));
if(context == NULL)
goto context_alloc_fail;
if (!is_validation_required(core_dc, set, set_count)) {
dc_resource_validate_ctx_copy_construct(core_dc->current_context, context);
return context;
}
result = core_dc->res_pool->funcs->validate_with_context(
core_dc, set, set_count, context);
dc_resource_validate_ctx_destruct(context);
dm_free(context);
context_alloc_fail:
if (result != DC_OK) {
dm_logger_write(core_dc->ctx->logger, LOG_WARNING,
"%s:resource validation failed, dc_status:%d\n",
__func__,
result);
dc_resource_validate_ctx_destruct(context);
dm_free(context);
context = NULL;
}
return (result == DC_OK);
return context;
}
bool dc_validate_resources(
const struct dc *dc,
const struct dc_validation_set set[],
uint8_t set_count)
{
struct validate_context *ctx;
ctx = dc_get_validate_context(dc, set, set_count);
if (ctx) {
dc_resource_validate_ctx_destruct(ctx);
dm_free(ctx);
return true;
}
return false;
}
bool dc_validate_guaranteed(
const struct dc *dc,
const struct dc_stream *stream)
......
......@@ -505,6 +505,11 @@ struct dc_validation_set {
* After this call:
* No hardware is programmed for call. Only validation is done.
*/
struct validate_context *dc_get_validate_context(
const struct dc *dc,
const struct dc_validation_set set[],
uint8_t set_count);
bool dc_validate_resources(
const struct dc *dc,
const struct dc_validation_set set[],
......
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