Skip to content

Commit

Permalink
drm/amd/display: Prevent overflow on DTO calculation
Browse files Browse the repository at this point in the history
[Why]
uint32_t is implicitly converted to uint64_t while multiplication
still happens on uint32_t side.  This creates digit overflow
for large pixel clock which is meant to be retained in uint64_t.

[How]
Calculate multiplication of units in uint64_t domain instead of
uint32_t in DTO parameter clock caculation.

Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
Acked-by: Zaeem Mohamed <zaeem.mohamed@amd.com>
Signed-off-by: Chris Park <chris.park@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Chris Park authored and Alex Deucher committed Jun 14, 2024
1 parent ed79ab5 commit 8362061
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,11 +1088,15 @@ static bool dcn401_program_pix_clk(
dto_params.clk_src = DPREFCLK;

if (e) {
dto_params.pixclk_hz = e->target_pixel_rate_khz * e->mult_factor;
dto_params.refclk_hz = dtbclk_p_src_clk_khz * e->div_factor;
dto_params.pixclk_hz = e->target_pixel_rate_khz;
dto_params.pixclk_hz *= e->mult_factor;
dto_params.refclk_hz = dtbclk_p_src_clk_khz;
dto_params.refclk_hz *= e->div_factor;
} else {
dto_params.pixclk_hz = pix_clk_params->requested_pix_clk_100hz * 100;
dto_params.refclk_hz = dtbclk_p_src_clk_khz * 1000;
dto_params.pixclk_hz = pix_clk_params->requested_pix_clk_100hz;
dto_params.pixclk_hz *= 100;
dto_params.refclk_hz = dtbclk_p_src_clk_khz;
dto_params.refclk_hz *= 1000;
}

/* enable DP DTO */
Expand Down

0 comments on commit 8362061

Please sign in to comment.