Commit 0881fbc4 authored by Roman Li's avatar Roman Li Committed by Alex Deucher
Browse files

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 <mario.limonciello@amd.com>
Reviewed-by: default avatarAlvin Lee <alvin.lee2@amd.com>
Signed-off-by: default avatarRoman Li <Roman.Li@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
(cherry picked from commit f6e09701)
Cc: stable@vger.kernel.org
parent 97386094
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -66,11 +66,15 @@ static inline double dml_max5(double a, double b, double c, double d, double e)

static inline double dml_ceil(double a, double granularity)
{
	if (granularity == 0)
		return 0;
	return (double) dcn_bw_ceil2(a, granularity);
}

static inline double dml_floor(double a, double granularity)
{
	if (granularity == 0)
		return 0;
	return (double) dcn_bw_floor2(a, granularity);
}

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

static inline double dml_ceil_ex(double x, double granularity)
{
	if (granularity == 0)
		return 0;
	return (double) dcn_bw_ceil2(x, granularity);
}

static inline double dml_floor_ex(double x, double granularity)
{
	if (granularity == 0)
		return 0;
	return (double) dcn_bw_floor2(x, granularity);
}