Commit e56c67ed authored by Murton Liu's avatar Murton Liu Committed by Greg Kroah-Hartman

drm/amd/display: Fix Divide by 0 in memory calculations

[ Upstream commit 59979bf8 ]

Check if we get any values equal to 0, and set to 1 if so.
Signed-off-by: default avatarMurton Liu <murton.liu@amd.com>
Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Acked-by: default avatarSivapiriyan Kumarasamy <Sivapiriyan.Kumarasamy@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 8f9123dc
......@@ -406,15 +406,25 @@ void dpp1_dscl_calc_lb_num_partitions(
int *num_part_y,
int *num_part_c)
{
int lb_memory_size, lb_memory_size_c, lb_memory_size_a, num_partitions_a,
lb_bpc, memory_line_size_y, memory_line_size_c, memory_line_size_a;
int line_size = scl_data->viewport.width < scl_data->recout.width ?
scl_data->viewport.width : scl_data->recout.width;
int line_size_c = scl_data->viewport_c.width < scl_data->recout.width ?
scl_data->viewport_c.width : scl_data->recout.width;
int lb_bpc = dpp1_dscl_get_lb_depth_bpc(scl_data->lb_params.depth);
int memory_line_size_y = (line_size * lb_bpc + 71) / 72; /* +71 to ceil */
int memory_line_size_c = (line_size_c * lb_bpc + 71) / 72; /* +71 to ceil */
int memory_line_size_a = (line_size + 5) / 6; /* +5 to ceil */
int lb_memory_size, lb_memory_size_c, lb_memory_size_a, num_partitions_a;
if (line_size == 0)
line_size = 1;
if (line_size_c == 0)
line_size_c = 1;
lb_bpc = dpp1_dscl_get_lb_depth_bpc(scl_data->lb_params.depth);
memory_line_size_y = (line_size * lb_bpc + 71) / 72; /* +71 to ceil */
memory_line_size_c = (line_size_c * lb_bpc + 71) / 72; /* +71 to ceil */
memory_line_size_a = (line_size + 5) / 6; /* +5 to ceil */
if (lb_config == LB_MEMORY_CONFIG_1) {
lb_memory_size = 816;
......
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