Commit 45209ef7 authored by Dmytro Laktyushkin's avatar Dmytro Laktyushkin Committed by Alex Deucher

drm/amd/display: remove apply_clk_constraints, used validate_bandwidth universally

Signed-off-by: default avatarDmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Acked-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Reviewed-by: default avatarDmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 64801369
...@@ -1144,12 +1144,11 @@ bool dc_pre_update_surfaces_to_stream( ...@@ -1144,12 +1144,11 @@ bool dc_pre_update_surfaces_to_stream(
} }
} }
if (core_dc->res_pool->funcs->validate_bandwidth) if (!core_dc->res_pool->funcs->validate_bandwidth(core_dc, context)) {
if (core_dc->res_pool->funcs->validate_bandwidth(core_dc, context) != DC_OK) { BREAK_TO_DEBUGGER();
BREAK_TO_DEBUGGER(); ret = false;
ret = false; goto unexpected_fail;
goto unexpected_fail; }
}
if (!IS_FPGA_MAXIMUS_DC(core_dc->ctx->dce_environment) if (!IS_FPGA_MAXIMUS_DC(core_dc->ctx->dce_environment)
&& prev_disp_clk < context->dispclk_khz) { && prev_disp_clk < context->dispclk_khz) {
...@@ -1184,28 +1183,36 @@ bool dc_pre_update_surfaces_to_stream( ...@@ -1184,28 +1183,36 @@ bool dc_pre_update_surfaces_to_stream(
bool dc_post_update_surfaces_to_stream(struct dc *dc) bool dc_post_update_surfaces_to_stream(struct dc *dc)
{ {
struct core_dc *core_dc = DC_TO_CORE(dc);
int i; int i;
struct core_dc *core_dc = DC_TO_CORE(dc);
struct validate_context *context = dm_alloc(sizeof(struct validate_context));
if (!context) {
dm_error("%s: failed to create validate ctx\n", __func__);
return false;
}
resource_validate_ctx_copy_construct(core_dc->current_context, context);
post_surface_trace(dc); post_surface_trace(dc);
for (i = 0; i < core_dc->current_context->res_ctx.pool->pipe_count; i++) for (i = 0; i < context->res_ctx.pool->pipe_count; i++)
if (core_dc->current_context->res_ctx.pipe_ctx[i].stream == NULL) { if (context->res_ctx.pipe_ctx[i].stream == NULL) {
core_dc->current_context->res_ctx.pipe_ctx[i].pipe_idx = i; context->res_ctx.pipe_ctx[i].pipe_idx = i;
core_dc->hwss.power_down_front_end( core_dc->hwss.power_down_front_end(
core_dc, &core_dc->current_context->res_ctx.pipe_ctx[i]); core_dc, &context->res_ctx.pipe_ctx[i]);
}
if (core_dc->res_pool->funcs->validate_bandwidth)
if (core_dc->res_pool->funcs->validate_bandwidth(
core_dc, core_dc->current_context) != DC_OK) {
BREAK_TO_DEBUGGER();
return false;
} }
if (!core_dc->res_pool->funcs->validate_bandwidth(core_dc, context)) {
BREAK_TO_DEBUGGER();
return false;
}
core_dc->hwss.set_bandwidth(core_dc); core_dc->hwss.set_bandwidth(core_dc);
pplib_apply_display_requirements( /*TODO: dce specific*/
core_dc, core_dc->current_context, &core_dc->current_context->pp_display_cfg); pplib_apply_display_requirements(core_dc, context, &context->pp_display_cfg);
resource_validate_ctx_destruct(core_dc->current_context);
core_dc->current_context = context;
return true; return true;
} }
...@@ -1472,6 +1479,11 @@ void dc_update_surfaces_for_stream(struct dc *dc, ...@@ -1472,6 +1479,11 @@ void dc_update_surfaces_for_stream(struct dc *dc,
*(updates[i].hdr_static_metadata); *(updates[i].hdr_static_metadata);
} }
if (update_type == UPDATE_TYPE_FULL &&
!core_dc->res_pool->funcs->validate_bandwidth(core_dc, context)) {
BREAK_TO_DEBUGGER();
return;
}
if (!surface_count) /* reset */ if (!surface_count) /* reset */
core_dc->hwss.apply_ctx_for_surface(core_dc, NULL, context); core_dc->hwss.apply_ctx_for_surface(core_dc, NULL, context);
......
...@@ -765,14 +765,14 @@ static enum dc_status validate_mapped_resource( ...@@ -765,14 +765,14 @@ static enum dc_status validate_mapped_resource(
return DC_OK; return DC_OK;
} }
enum dc_status dce100_validate_bandwidth( bool dce100_validate_bandwidth(
const struct core_dc *dc, const struct core_dc *dc,
struct validate_context *context) struct validate_context *context)
{ {
/* TODO implement when needed but for now hardcode max value*/ /* TODO implement when needed but for now hardcode max value*/
context->dispclk_khz = 681000; context->dispclk_khz = 681000;
return DC_OK; return false;
} }
static bool dce100_validate_surface_sets( static bool dce100_validate_surface_sets(
...@@ -840,7 +840,8 @@ enum dc_status dce100_validate_with_context( ...@@ -840,7 +840,8 @@ enum dc_status dce100_validate_with_context(
result = resource_build_scaling_params_for_context(dc, context); result = resource_build_scaling_params_for_context(dc, context);
if (result == DC_OK) if (result == DC_OK)
result = dce100_validate_bandwidth(dc, context); if (!dce100_validate_bandwidth(dc, context))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result; return result;
} }
...@@ -873,7 +874,8 @@ enum dc_status dce100_validate_guaranteed( ...@@ -873,7 +874,8 @@ enum dc_status dce100_validate_guaranteed(
} }
if (result == DC_OK) if (result == DC_OK)
result = dce100_validate_bandwidth(dc, context); if (!dce100_validate_bandwidth(dc, context))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result; return result;
} }
......
...@@ -912,30 +912,28 @@ static enum dc_status validate_mapped_resource( ...@@ -912,30 +912,28 @@ static enum dc_status validate_mapped_resource(
return DC_OK; return DC_OK;
} }
enum dc_status dce110_validate_bandwidth( bool dce110_validate_bandwidth(
const struct core_dc *dc, const struct core_dc *dc,
struct validate_context *context) struct validate_context *context)
{ {
enum dc_status result = DC_ERROR_UNEXPECTED; bool result = false;
dm_logger_write( dm_logger_write(
dc->ctx->logger, LOG_BANDWIDTH_CALCS, dc->ctx->logger, LOG_BANDWIDTH_CALCS,
"%s: start", "%s: start",
__func__); __func__);
if (!bw_calcs( if (bw_calcs(
dc->ctx, dc->ctx,
&dc->bw_dceip, &dc->bw_dceip,
&dc->bw_vbios, &dc->bw_vbios,
context->res_ctx.pipe_ctx, context->res_ctx.pipe_ctx,
context->res_ctx.pool->pipe_count, context->res_ctx.pool->pipe_count,
&context->bw_results)) &context->bw_results))
result = DC_FAIL_BANDWIDTH_VALIDATE; result = true;
else
result = DC_OK;
context->dispclk_khz = context->bw_results.dispclk_khz; context->dispclk_khz = context->bw_results.dispclk_khz;
if (result == DC_FAIL_BANDWIDTH_VALIDATE) if (!result)
dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_VALIDATION, dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_VALIDATION,
"%s: %dx%d@%d Bandwidth validation failed!\n", "%s: %dx%d@%d Bandwidth validation failed!\n",
__func__, __func__,
...@@ -1073,7 +1071,8 @@ enum dc_status dce110_validate_with_context( ...@@ -1073,7 +1071,8 @@ enum dc_status dce110_validate_with_context(
result = resource_build_scaling_params_for_context(dc, context); result = resource_build_scaling_params_for_context(dc, context);
if (result == DC_OK) if (result == DC_OK)
result = dce110_validate_bandwidth(dc, context); if (!dce110_validate_bandwidth(dc, context))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result; return result;
} }
...@@ -1106,7 +1105,8 @@ enum dc_status dce110_validate_guaranteed( ...@@ -1106,7 +1105,8 @@ enum dc_status dce110_validate_guaranteed(
} }
if (result == DC_OK) if (result == DC_OK)
result = dce110_validate_bandwidth(dc, context); if (!dce110_validate_bandwidth(dc, context))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result; return result;
} }
......
...@@ -836,30 +836,28 @@ static enum dc_status validate_mapped_resource( ...@@ -836,30 +836,28 @@ static enum dc_status validate_mapped_resource(
return DC_OK; return DC_OK;
} }
enum dc_status dce112_validate_bandwidth( bool dce112_validate_bandwidth(
const struct core_dc *dc, const struct core_dc *dc,
struct validate_context *context) struct validate_context *context)
{ {
enum dc_status result = DC_ERROR_UNEXPECTED; bool result = false;
dm_logger_write( dm_logger_write(
dc->ctx->logger, LOG_BANDWIDTH_CALCS, dc->ctx->logger, LOG_BANDWIDTH_CALCS,
"%s: start", "%s: start",
__func__); __func__);
if (!bw_calcs( if (bw_calcs(
dc->ctx, dc->ctx,
&dc->bw_dceip, &dc->bw_dceip,
&dc->bw_vbios, &dc->bw_vbios,
context->res_ctx.pipe_ctx, context->res_ctx.pipe_ctx,
context->res_ctx.pool->pipe_count, context->res_ctx.pool->pipe_count,
&context->bw_results)) &context->bw_results))
result = DC_FAIL_BANDWIDTH_VALIDATE; result = true;
else
result = DC_OK;
context->dispclk_khz = context->bw_results.dispclk_khz; context->dispclk_khz = context->bw_results.dispclk_khz;
if (result == DC_FAIL_BANDWIDTH_VALIDATE) if (!result)
dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_VALIDATION, dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_VALIDATION,
"%s: Bandwidth validation failed!", "%s: Bandwidth validation failed!",
__func__); __func__);
...@@ -1026,7 +1024,8 @@ enum dc_status dce112_validate_with_context( ...@@ -1026,7 +1024,8 @@ enum dc_status dce112_validate_with_context(
result = resource_build_scaling_params_for_context(dc, context); result = resource_build_scaling_params_for_context(dc, context);
if (result == DC_OK) if (result == DC_OK)
result = dce112_validate_bandwidth(dc, context); if (!dce112_validate_bandwidth(dc, context))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result; return result;
} }
...@@ -1059,7 +1058,8 @@ enum dc_status dce112_validate_guaranteed( ...@@ -1059,7 +1058,8 @@ enum dc_status dce112_validate_guaranteed(
} }
if (result == DC_OK) if (result == DC_OK)
result = dce112_validate_bandwidth(dc, context); if (!dce112_validate_bandwidth(dc, context))
result = DC_FAIL_BANDWIDTH_VALIDATE;
return result; return result;
} }
......
...@@ -46,7 +46,7 @@ enum dc_status dce112_validate_guaranteed( ...@@ -46,7 +46,7 @@ enum dc_status dce112_validate_guaranteed(
const struct dc_stream *dc_stream, const struct dc_stream *dc_stream,
struct validate_context *context); struct validate_context *context);
enum dc_status dce112_validate_bandwidth( bool dce112_validate_bandwidth(
const struct core_dc *dc, const struct core_dc *dc,
struct validate_context *context); struct validate_context *context);
......
...@@ -780,7 +780,7 @@ static enum dc_status validate_mapped_resource( ...@@ -780,7 +780,7 @@ static enum dc_status validate_mapped_resource(
return DC_OK; return DC_OK;
} }
enum dc_status dce80_validate_bandwidth( bool dce80_validate_bandwidth(
const struct core_dc *dc, const struct core_dc *dc,
struct validate_context *context) struct validate_context *context)
{ {
...@@ -788,7 +788,7 @@ enum dc_status dce80_validate_bandwidth( ...@@ -788,7 +788,7 @@ enum dc_status dce80_validate_bandwidth(
context->dispclk_khz = 681000; context->dispclk_khz = 681000;
context->bw_results.required_yclk = 250000 * MEMORY_TYPE_MULTIPLIER; context->bw_results.required_yclk = 250000 * MEMORY_TYPE_MULTIPLIER;
return DC_OK; return true;
} }
static bool dce80_validate_surface_sets( static bool dce80_validate_surface_sets(
......
...@@ -41,7 +41,6 @@ enum dc_status { ...@@ -41,7 +41,6 @@ enum dc_status {
DC_SURFACE_PIXEL_FORMAT_UNSUPPORTED = 11, DC_SURFACE_PIXEL_FORMAT_UNSUPPORTED = 11,
DC_FAIL_BANDWIDTH_VALIDATE = 12, /* BW and Watermark validation */ DC_FAIL_BANDWIDTH_VALIDATE = 12, /* BW and Watermark validation */
DC_FAIL_SCALING = 13, DC_FAIL_SCALING = 13,
DC_FAIL_CLK_CONSTRAINT = 14,
DC_ERROR_UNEXPECTED = -1 DC_ERROR_UNEXPECTED = -1
}; };
......
...@@ -207,11 +207,7 @@ struct resource_funcs { ...@@ -207,11 +207,7 @@ struct resource_funcs {
const struct dc_stream *stream, const struct dc_stream *stream,
struct validate_context *context); struct validate_context *context);
enum dc_status (*validate_bandwidth)( bool (*validate_bandwidth)(
const struct core_dc *dc,
struct validate_context *context);
struct validate_context *(*apply_clk_constraints)(
const struct core_dc *dc, const struct core_dc *dc,
struct validate_context *context); struct validate_context *context);
......
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