summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-05-31 23:55:47 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-05-31 23:55:47 +0000
commitec0e1b112d6b4761da55127bb122c68e9fbc5ce1 (patch)
tree10d859bc8f2e3b9fe5b247722805dcc2286fd0f6 /sys
parent4fdda96a3af81d279b3578392e2489b1f984c4ab (diff)
drm/amd/display: Fix Divide by 0 in memory calculations
From Murton Liu fc5293ab6c48710eed5df3b40e808e3a3c560e2d in linux 4.19.y/4.19.47 59979bf8be1784ebfc44215031c6c88ca22ae65d in mainline linux
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c b/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c
index 4a863a5dab4..321af9af95e 100644
--- a/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c
+++ b/sys/dev/pci/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c
@@ -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;