Commit deb79818 authored by Jun Lei's avatar Jun Lei Committed by Alex Deucher

drm/amd/display: add explicit comparator as default optimization check

[why]
memcmp is vulnerable to regression due to dc_clocks structures not being
organized properly (not "current" clock related structures being at the beginning
of the structure) and causes unnecessary setting of the optimize bit

[how]
add a dcn sepcific comparator, implement for dcn2
Signed-off-by: default avatarJun Lei <Jun.Lei@amd.com>
Reviewed-by: default avatarAnthony Koo <Anthony.Koo@amd.com>
Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 3c2381b9
...@@ -349,12 +349,36 @@ void dcn2_get_clock(struct clk_mgr *clk_mgr, ...@@ -349,12 +349,36 @@ void dcn2_get_clock(struct clk_mgr *clk_mgr,
} }
} }
static bool dcn2_are_clock_states_equal(struct dc_clocks *a,
struct dc_clocks *b)
{
if (a->dispclk_khz != b->dispclk_khz)
return false;
else if (a->dppclk_khz != b->dppclk_khz)
return false;
else if (a->dcfclk_khz != b->dcfclk_khz)
return false;
else if (a->socclk_khz != b->socclk_khz)
return false;
else if (a->dcfclk_deep_sleep_khz != b->dcfclk_deep_sleep_khz)
return false;
else if (a->phyclk_khz != b->phyclk_khz)
return false;
else if (a->dramclk_khz != b->dramclk_khz)
return false;
else if (a->p_state_change_support != b->p_state_change_support)
return false;
return true;
}
static struct clk_mgr_funcs dcn2_funcs = { static struct clk_mgr_funcs dcn2_funcs = {
.get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz, .get_dp_ref_clk_frequency = dce12_get_dp_ref_freq_khz,
.update_clocks = dcn2_update_clocks, .update_clocks = dcn2_update_clocks,
.init_clocks = dcn2_init_clocks, .init_clocks = dcn2_init_clocks,
.enable_pme_wa = dcn2_enable_pme_wa, .enable_pme_wa = dcn2_enable_pme_wa,
.get_clock = dcn2_get_clock, .get_clock = dcn2_get_clock,
.are_clock_states_equal = dcn2_are_clock_states_equal,
}; };
......
...@@ -1681,8 +1681,16 @@ enum surface_update_type dc_check_update_surfaces_for_stream( ...@@ -1681,8 +1681,16 @@ enum surface_update_type dc_check_update_surfaces_for_stream(
updates[i].surface->update_flags.raw = 0xFFFFFFFF; updates[i].surface->update_flags.raw = 0xFFFFFFFF;
} }
if (type == UPDATE_TYPE_FAST && memcmp(&dc->current_state->bw_ctx.bw.dcn.clk, &dc->clk_mgr->clks, offsetof(struct dc_clocks, prev_p_state_change_support)) != 0) if (type == UPDATE_TYPE_FAST) {
// If there's an available clock comparator, we use that.
if (dc->clk_mgr->funcs->are_clock_states_equal) {
if (!dc->clk_mgr->funcs->are_clock_states_equal(&dc->clk_mgr->clks, &dc->current_state->bw_ctx.bw.dcn.clk))
dc->optimized_required = true; dc->optimized_required = true;
// Else we fallback to mem compare.
} else if (memcmp(&dc->current_state->bw_ctx.bw.dcn.clk, &dc->clk_mgr->clks, offsetof(struct dc_clocks, prev_p_state_change_support)) != 0) {
dc->optimized_required = true;
}
}
return type; return type;
} }
......
...@@ -180,6 +180,9 @@ struct clk_mgr_funcs { ...@@ -180,6 +180,9 @@ struct clk_mgr_funcs {
struct dc_state *context, struct dc_state *context,
enum dc_clock_type clock_type, enum dc_clock_type clock_type,
struct dc_clock_config *clock_cfg); struct dc_clock_config *clock_cfg);
bool (*are_clock_states_equal) (struct dc_clocks *a,
struct dc_clocks *b);
}; };
struct clk_mgr { struct clk_mgr {
......
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