Commit 922044c9 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

drm/i915: Avoid div by zero when pixel clock is large

Make sure the line_time_us isn't zero in the gmch watermarks code as
that would cause a div by zero. This can be triggered by specifying
a very fast pixel clock for the mode.

At some point we should probably just switch over to using the same
math we use on PCH platforms which avoids such intermediate rounded
results.

Also we should verify the user provided mode much more rigorously.
At the moment we accept pretty much anything.

Note that "very fast mode" here means above 74.25 GHz.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
[danvet: Add Ville's clarification of what "very fast" means.]
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 77961eb9
...@@ -1134,7 +1134,7 @@ static bool g4x_compute_wm0(struct drm_device *dev, ...@@ -1134,7 +1134,7 @@ static bool g4x_compute_wm0(struct drm_device *dev,
*plane_wm = display->max_wm; *plane_wm = display->max_wm;
/* Use the large buffer method to calculate cursor watermark */ /* Use the large buffer method to calculate cursor watermark */
line_time_us = ((htotal * 1000) / clock); line_time_us = max(htotal * 1000 / clock, 1);
line_count = (cursor_latency_ns / line_time_us + 1000) / 1000; line_count = (cursor_latency_ns / line_time_us + 1000) / 1000;
entries = line_count * 64 * pixel_size; entries = line_count * 64 * pixel_size;
tlb_miss = cursor->fifo_size*cursor->cacheline_size - hdisplay * 8; tlb_miss = cursor->fifo_size*cursor->cacheline_size - hdisplay * 8;
...@@ -1210,7 +1210,7 @@ static bool g4x_compute_srwm(struct drm_device *dev, ...@@ -1210,7 +1210,7 @@ static bool g4x_compute_srwm(struct drm_device *dev,
hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; hdisplay = to_intel_crtc(crtc)->config.pipe_src_w;
pixel_size = crtc->fb->bits_per_pixel / 8; pixel_size = crtc->fb->bits_per_pixel / 8;
line_time_us = (htotal * 1000) / clock; line_time_us = max(htotal * 1000 / clock, 1);
line_count = (latency_ns / line_time_us + 1000) / 1000; line_count = (latency_ns / line_time_us + 1000) / 1000;
line_size = hdisplay * pixel_size; line_size = hdisplay * pixel_size;
...@@ -1443,7 +1443,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc) ...@@ -1443,7 +1443,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc)
unsigned long line_time_us; unsigned long line_time_us;
int entries; int entries;
line_time_us = ((htotal * 1000) / clock); line_time_us = max(htotal * 1000 / clock, 1);
/* Use ns/us then divide to preserve precision */ /* Use ns/us then divide to preserve precision */
entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
...@@ -1569,7 +1569,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc) ...@@ -1569,7 +1569,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc)
unsigned long line_time_us; unsigned long line_time_us;
int entries; int entries;
line_time_us = (htotal * 1000) / clock; line_time_us = max(htotal * 1000 / clock, 1);
/* Use ns/us then divide to preserve precision */ /* Use ns/us then divide to preserve precision */
entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment