Skip to content

Commit 0881fbc

Browse files
Roman Lialexdeucher
authored andcommitted
drm/amd/display: Add check for granularity in dml ceil/floor helpers
[Why] Wrapper functions for dcn_bw_ceil2() and dcn_bw_floor2() should check for granularity is non zero to avoid assert and divide-by-zero error in dcn_bw_ functions. [How] Add check for granularity 0. Cc: Mario Limonciello <[email protected]> Reviewed-by: Alvin Lee <[email protected]> Signed-off-by: Roman Li <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]> (cherry picked from commit f6e0970) Cc: [email protected]
1 parent 9738609 commit 0881fbc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ static inline double dml_max5(double a, double b, double c, double d, double e)
6666

6767
static inline double dml_ceil(double a, double granularity)
6868
{
69+
if (granularity == 0)
70+
return 0;
6971
return (double) dcn_bw_ceil2(a, granularity);
7072
}
7173

7274
static inline double dml_floor(double a, double granularity)
7375
{
76+
if (granularity == 0)
77+
return 0;
7478
return (double) dcn_bw_floor2(a, granularity);
7579
}
7680

@@ -114,11 +118,15 @@ static inline double dml_ceil_2(double f)
114118

115119
static inline double dml_ceil_ex(double x, double granularity)
116120
{
121+
if (granularity == 0)
122+
return 0;
117123
return (double) dcn_bw_ceil2(x, granularity);
118124
}
119125

120126
static inline double dml_floor_ex(double x, double granularity)
121127
{
128+
if (granularity == 0)
129+
return 0;
122130
return (double) dcn_bw_floor2(x, granularity);
123131
}
124132

0 commit comments

Comments
 (0)