diff options
author | Nikola Cornij <nikola.cornij@amd.com> | 2019-04-15 14:32:28 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-06-22 09:34:11 -0500 |
commit | b01473e919fa4dd32df696ebfc899c8ba6e817a8 (patch) | |
tree | 69ce44458e401dcfb24a9ecfc4df457c4809da0a /drivers | |
parent | 7fad39ca4a1cd721864a3b7da19b2489e73dbf42 (diff) | |
download | linux-b01473e919fa4dd32df696ebfc899c8ba6e817a8.tar.bz2 |
drm/amd/display: Make sure line size is not zero in DCN2 line buffer size calculations
[why]
'Divide by zero' error happens when line size happens to be zero.
[how]
The code that makes sure line size minimum value can be 1 was already
present in DCN1 part of the driver, this is mearly a port to DCN2.
Signed-off-by: Nikola Cornij <nikola.cornij@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c index b706190e16c1..9bc5dd23d297 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c @@ -251,14 +251,23 @@ void dscl2_calc_lb_num_partitions( int *num_part_y, int *num_part_c) { + int memory_line_size_y, memory_line_size_c, memory_line_size_a, + lb_memory_size, lb_memory_size_c, lb_memory_size_a, num_partitions_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 memory_line_size_y = (line_size + 5) / 6; /* +5 to ceil */ - int memory_line_size_c = (line_size_c + 5) / 6; /* +5 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; + + memory_line_size_y = (line_size + 5) / 6; /* +5 to ceil */ + memory_line_size_c = (line_size_c + 5) / 6; /* +5 to ceil */ + memory_line_size_a = (line_size + 5) / 6; /* +5 to ceil */ if (lb_config == LB_MEMORY_CONFIG_1) { lb_memory_size = 970; |