[PATCH] drm/radeon: fix 32-bit compile after dpm merge

Dave Airlie airlied at gmail.com
Wed Jun 26 20:51:47 PDT 2013


From: Dave Airlie <airlied at redhat.com>

feel free to split this back up and merge it into the individual commits.

should probably also confirm its doing sane things.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 drivers/gpu/drm/radeon/ni_dpm.c    |   10 +++++-----
 drivers/gpu/drm/radeon/rv730_dpm.c |    6 +++---
 drivers/gpu/drm/radeon/rv740_dpm.c |    6 +++---
 drivers/gpu/drm/radeon/rv770_dpm.c |    6 +++---
 drivers/gpu/drm/radeon/si_dpm.c    |   11 ++++++-----
 5 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index ee82495..d547c42 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -1376,8 +1376,8 @@ static u32 ni_calculate_power_boost_limit(struct radeon_device *rdev,
 		if (ret)
 			return 0;
 
-		tmp = ((u64)near_tdp_limit * ((u64)std_vddc_med * (u64)std_vddc_med) * 90) /
-			((u64)std_vddc_high * (u64)std_vddc_high * 100);
+		tmp = ((u64)near_tdp_limit * ((u64)std_vddc_med * (u64)std_vddc_med) * 90);
+		do_div(tmp, ((u64)std_vddc_high * (u64)std_vddc_high * 100));
 		if (tmp >> 32)
 			return 0;
 		power_boost_limit = (u32)tmp;
@@ -1978,9 +1978,9 @@ static int ni_calculate_sclk_params(struct radeon_device *rdev,
 
 	reference_divider = 1 + dividers.ref_div;
 
-	tmp = (u64) engine_clock * reference_divider * dividers.post_div;
-
-	fbdiv = (u32) ((16384 * tmp) / reference_clock);
+	tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16834;
+	do_div(tmp, reference_clock);
+	fbdiv = (u32) tmp;
 
 	spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
 	spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
diff --git a/drivers/gpu/drm/radeon/rv730_dpm.c b/drivers/gpu/drm/radeon/rv730_dpm.c
index b23be71..3f5e1cf 100644
--- a/drivers/gpu/drm/radeon/rv730_dpm.c
+++ b/drivers/gpu/drm/radeon/rv730_dpm.c
@@ -67,9 +67,9 @@ int rv730_populate_sclk_value(struct radeon_device *rdev,
 	else
 		post_divider = 1;
 
-	tmp = (u64) engine_clock * reference_divider * post_divider;
-
-	fbdiv = (u32) ((16384 * tmp) / reference_clock);
+	tmp = (u64) engine_clock * reference_divider * post_divider * 16384;
+	do_div(tmp, reference_clock);
+	fbdiv = (u32) tmp;
 
 	/* set up registers */
 	if (dividers.enable_post_div)
diff --git a/drivers/gpu/drm/radeon/rv740_dpm.c b/drivers/gpu/drm/radeon/rv740_dpm.c
index 7aa1608..c4c8da5 100644
--- a/drivers/gpu/drm/radeon/rv740_dpm.c
+++ b/drivers/gpu/drm/radeon/rv740_dpm.c
@@ -141,9 +141,9 @@ int rv740_populate_sclk_value(struct radeon_device *rdev, u32 engine_clock,
 
 	reference_divider = 1 + dividers.ref_div;
 
-	tmp = (u64) engine_clock * reference_divider * dividers.post_div;
-
-	fbdiv = (u32) ((16384 * tmp) / reference_clock);
+	tmp = (u64) engine_clock * reference_divider * dividers.post_div * 16384;
+	do_div(tmp, reference_clock);
+	fbdiv = (u32) tmp;
 
 	spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
 	spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c
index 038c013..e58f8b6 100644
--- a/drivers/gpu/drm/radeon/rv770_dpm.c
+++ b/drivers/gpu/drm/radeon/rv770_dpm.c
@@ -511,9 +511,9 @@ static int rv770_populate_sclk_value(struct radeon_device *rdev,
 	else
 		post_divider = 1;
 
-	tmp = (u64) engine_clock * reference_divider * post_divider;
-
-	fbdiv = (u32) ((16384 * tmp) / reference_clock);
+	tmp = (u64) engine_clock * reference_divider * post_divider * 16384;
+	do_div(tmp, reference_clock);
+	fbdiv = (u32) tmp;
 
 	if (dividers.enable_post_div)
 		spll_func_cntl |= SPLL_DIVEN;
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c
index 4c5b258..98450d8 100644
--- a/drivers/gpu/drm/radeon/si_dpm.c
+++ b/drivers/gpu/drm/radeon/si_dpm.c
@@ -2243,8 +2243,9 @@ static u16 si_calculate_power_efficiency_ratio(struct radeon_device *rdev,
 	if ((prev_vddc == 0) || (curr_vddc == 0))
 		return 0;
 
-	pwr_efficiency_ratio = ((u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin) /
-				(u64)1000) / (prev_vddc * prev_vddc);
+	pwr_efficiency_ratio = (u64)1024 * curr_vddc * curr_vddc * ((u64)1000 + margin);
+	do_div(pwr_efficiency_ratio, 1000);
+	do_div(pwr_efficiency_ratio, (prev_vddc * prev_vddc));
 
 	if (pwr_efficiency_ratio > (u64)0xFFFF)
 		return 0;
@@ -4532,9 +4533,9 @@ static int si_calculate_sclk_params(struct radeon_device *rdev,
 
 	reference_divider = 1 + dividers.ref_div;
 
-	tmp = (uint64_t) engine_clock * reference_divider * dividers.post_div;
-
-	fbdiv = (u32) ((16384 * tmp) / reference_clock);
+	tmp = engine_clock * reference_divider * dividers.post_div * 16384;
+	do_div(tmp, reference_clock);
+	fbdiv = (u32) tmp;
 
 	spll_func_cntl &= ~(SPLL_PDIV_A_MASK | SPLL_REF_DIV_MASK);
 	spll_func_cntl |= SPLL_REF_DIV(dividers.ref_div);
-- 
1.7.1



More information about the dri-devel mailing list