aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Kleiner <mario.kleiner.de@gmail.com>2017-06-13 01:17:11 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-06-14 09:25:58 -0400
commit55f61a040e1b1ea0ba962e53ae341b4c51915bd1 (patch)
tree16528c7a73bc73fc1fc4aec5046d3c21adec60da
parentbea10413934dcf98cb9b2dfcdc56e1d28f192897 (diff)
drm/radeon: Fix overflow of watermark calcs at > 4k resolutions.
Commit e6b9a6c84b93 ("drm/radeon: Make display watermark calculations more accurate") made watermark calculations more accurate, but not for > 4k resolutions on 32-Bit architectures, as it introduced an integer overflow for those setups and resolutions. Fix this by proper u64 casting and division. Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com> Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk> Fixes: e6b9a6c84b93 ("drm/radeon: Make display watermark calculations more accurate") Cc: Ben Hutchings <ben.hutchings@codethink.co.uk> Cc: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/radeon/cik.c7
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c7
-rw-r--r--drivers/gpu/drm/radeon/si.c7
3 files changed, 15 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 008c145b7f29..ca44233ceacc 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -9267,8 +9267,11 @@ static void dce8_program_watermarks(struct radeon_device *rdev,
9267 u32 tmp, wm_mask; 9267 u32 tmp, wm_mask;
9268 9268
9269 if (radeon_crtc->base.enabled && num_heads && mode) { 9269 if (radeon_crtc->base.enabled && num_heads && mode) {
9270 active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 9270 active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000,
9271 line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 9271 (u32)mode->clock);
9272 line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000,
9273 (u32)mode->clock);
9274 line_time = min(line_time, (u32)65535);
9272 9275
9273 /* watermark for high clocks */ 9276 /* watermark for high clocks */
9274 if ((rdev->pm.pm_method == PM_METHOD_DPM) && 9277 if ((rdev->pm.pm_method == PM_METHOD_DPM) &&
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 0bf103536404..534637203e70 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -2266,8 +2266,11 @@ static void evergreen_program_watermarks(struct radeon_device *rdev,
2266 fixed20_12 a, b, c; 2266 fixed20_12 a, b, c;
2267 2267
2268 if (radeon_crtc->base.enabled && num_heads && mode) { 2268 if (radeon_crtc->base.enabled && num_heads && mode) {
2269 active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 2269 active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000,
2270 line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 2270 (u32)mode->clock);
2271 line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000,
2272 (u32)mode->clock);
2273 line_time = min(line_time, (u32)65535);
2271 priority_a_cnt = 0; 2274 priority_a_cnt = 0;
2272 priority_b_cnt = 0; 2275 priority_b_cnt = 0;
2273 dram_channels = evergreen_get_number_of_dram_channels(rdev); 2276 dram_channels = evergreen_get_number_of_dram_channels(rdev);
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 76d1888528e6..5303f25d5280 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -2284,8 +2284,11 @@ static void dce6_program_watermarks(struct radeon_device *rdev,
2284 fixed20_12 a, b, c; 2284 fixed20_12 a, b, c;
2285 2285
2286 if (radeon_crtc->base.enabled && num_heads && mode) { 2286 if (radeon_crtc->base.enabled && num_heads && mode) {
2287 active_time = 1000000UL * (u32)mode->crtc_hdisplay / (u32)mode->clock; 2287 active_time = (u32) div_u64((u64)mode->crtc_hdisplay * 1000000,
2288 line_time = min((u32) (1000000UL * (u32)mode->crtc_htotal / (u32)mode->clock), (u32)65535); 2288 (u32)mode->clock);
2289 line_time = (u32) div_u64((u64)mode->crtc_htotal * 1000000,
2290 (u32)mode->clock);
2291 line_time = min(line_time, (u32)65535);
2289 priority_a_cnt = 0; 2292 priority_a_cnt = 0;
2290 priority_b_cnt = 0; 2293 priority_b_cnt = 0;
2291 2294