aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-07-19 14:59:52 -0400
committerEric Anholt <eric@anholt.net>2010-08-01 22:47:37 -0400
commit8de9b311bcd117a97998574705829bd48bfa2971 (patch)
tree9dffc65bd2c4e4aed4ef98dbf8615b618bcd9a28 /drivers
parentd79613643b4512962b2be5262a09b6694dd96101 (diff)
drm/i915: Round up the watermark entries (v3)
Even though "we have enough padding that it should be ok", round up the watermark entries to the next unit to be on the safe side... v2: Use the DIV_ROUND_UP macro v3: Spotted a few more missing round-ups. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index ce96c3aea162..baaaeaac7f21 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2734,7 +2734,7 @@ static unsigned long intel_calculate_wm(unsigned long clock_in_khz,
2734 */ 2734 */
2735 entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) / 2735 entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) /
2736 1000; 2736 1000;
2737 entries_required /= wm->cacheline_size; 2737 entries_required = DIV_ROUND_UP(entries_required, wm->cacheline_size);
2738 2738
2739 DRM_DEBUG_KMS("FIFO entries required for mode: %d\n", entries_required); 2739 DRM_DEBUG_KMS("FIFO entries required for mode: %d\n", entries_required);
2740 2740
@@ -2855,11 +2855,9 @@ static int i9xx_get_fifo_size(struct drm_device *dev, int plane)
2855 uint32_t dsparb = I915_READ(DSPARB); 2855 uint32_t dsparb = I915_READ(DSPARB);
2856 int size; 2856 int size;
2857 2857
2858 if (plane == 0) 2858 size = dsparb & 0x7f;
2859 size = dsparb & 0x7f; 2859 if (plane)
2860 else 2860 size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size;
2861 size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) -
2862 (dsparb & 0x7f);
2863 2861
2864 DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, 2862 DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb,
2865 plane ? "B" : "A", size); 2863 plane ? "B" : "A", size);
@@ -2873,11 +2871,9 @@ static int i85x_get_fifo_size(struct drm_device *dev, int plane)
2873 uint32_t dsparb = I915_READ(DSPARB); 2871 uint32_t dsparb = I915_READ(DSPARB);
2874 int size; 2872 int size;
2875 2873
2876 if (plane == 0) 2874 size = dsparb & 0x1ff;
2877 size = dsparb & 0x1ff; 2875 if (plane)
2878 else 2876 size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) - size;
2879 size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) -
2880 (dsparb & 0x1ff);
2881 size >>= 1; /* Convert to cachelines */ 2877 size >>= 1; /* Convert to cachelines */
2882 2878
2883 DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, 2879 DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb,
@@ -3009,12 +3005,12 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock,
3009 */ 3005 */
3010 entries_required = ((planea_clock / 1000) * pixel_size * latency_ns) / 3006 entries_required = ((planea_clock / 1000) * pixel_size * latency_ns) /
3011 1000; 3007 1000;
3012 entries_required /= G4X_FIFO_LINE_SIZE; 3008 entries_required = DIV_ROUND_UP(entries_required, G4X_FIFO_LINE_SIZE);
3013 planea_wm = entries_required + planea_params.guard_size; 3009 planea_wm = entries_required + planea_params.guard_size;
3014 3010
3015 entries_required = ((planeb_clock / 1000) * pixel_size * latency_ns) / 3011 entries_required = ((planeb_clock / 1000) * pixel_size * latency_ns) /
3016 1000; 3012 1000;
3017 entries_required /= G4X_FIFO_LINE_SIZE; 3013 entries_required = DIV_ROUND_UP(entries_required, G4X_FIFO_LINE_SIZE);
3018 planeb_wm = entries_required + planeb_params.guard_size; 3014 planeb_wm = entries_required + planeb_params.guard_size;
3019 3015
3020 cursora_wm = cursorb_wm = 16; 3016 cursora_wm = cursorb_wm = 16;
@@ -3033,12 +3029,12 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock,
3033 /* Use ns/us then divide to preserve precision */ 3029 /* Use ns/us then divide to preserve precision */
3034 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 3030 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
3035 pixel_size * sr_hdisplay; 3031 pixel_size * sr_hdisplay;
3036 sr_entries = roundup(sr_entries / cacheline_size, 1); 3032 sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size);
3037 3033
3038 entries_required = (((sr_latency_ns / line_time_us) + 3034 entries_required = (((sr_latency_ns / line_time_us) +
3039 1000) / 1000) * pixel_size * 64; 3035 1000) / 1000) * pixel_size * 64;
3040 entries_required = roundup(entries_required / 3036 entries_required = DIV_ROUND_UP(entries_required,
3041 g4x_cursor_wm_info.cacheline_size, 1); 3037 g4x_cursor_wm_info.cacheline_size);
3042 cursor_sr = entries_required + g4x_cursor_wm_info.guard_size; 3038 cursor_sr = entries_required + g4x_cursor_wm_info.guard_size;
3043 3039
3044 if (cursor_sr > g4x_cursor_wm_info.max_wm) 3040 if (cursor_sr > g4x_cursor_wm_info.max_wm)
@@ -3089,7 +3085,7 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock,
3089 /* Use ns/us then divide to preserve precision */ 3085 /* Use ns/us then divide to preserve precision */
3090 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 3086 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
3091 pixel_size * sr_hdisplay; 3087 pixel_size * sr_hdisplay;
3092 sr_entries = roundup(sr_entries / I915_FIFO_LINE_SIZE, 1); 3088 sr_entries = DIV_ROUND_UP(sr_entries, I915_FIFO_LINE_SIZE);
3093 DRM_DEBUG("self-refresh entries: %d\n", sr_entries); 3089 DRM_DEBUG("self-refresh entries: %d\n", sr_entries);
3094 srwm = I965_FIFO_SIZE - sr_entries; 3090 srwm = I965_FIFO_SIZE - sr_entries;
3095 if (srwm < 0) 3091 if (srwm < 0)
@@ -3098,8 +3094,8 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock,
3098 3094
3099 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 3095 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
3100 pixel_size * 64; 3096 pixel_size * 64;
3101 sr_entries = roundup(sr_entries / 3097 sr_entries = DIV_ROUND_UP(sr_entries,
3102 i965_cursor_wm_info.cacheline_size, 1); 3098 i965_cursor_wm_info.cacheline_size);
3103 cursor_sr = i965_cursor_wm_info.fifo_size - 3099 cursor_sr = i965_cursor_wm_info.fifo_size -
3104 (sr_entries + i965_cursor_wm_info.guard_size); 3100 (sr_entries + i965_cursor_wm_info.guard_size);
3105 3101
@@ -3181,7 +3177,7 @@ static void i9xx_update_wm(struct drm_device *dev, int planea_clock,
3181 /* Use ns/us then divide to preserve precision */ 3177 /* Use ns/us then divide to preserve precision */
3182 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * 3178 sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
3183 pixel_size * sr_hdisplay; 3179 pixel_size * sr_hdisplay;
3184 sr_entries = roundup(sr_entries / cacheline_size, 1); 3180 sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size);
3185 DRM_DEBUG_KMS("self-refresh entries: %d\n", sr_entries); 3181 DRM_DEBUG_KMS("self-refresh entries: %d\n", sr_entries);
3186 srwm = total_size - sr_entries; 3182 srwm = total_size - sr_entries;
3187 if (srwm < 0) 3183 if (srwm < 0)
@@ -3270,7 +3266,7 @@ static void ironlake_update_wm(struct drm_device *dev, int planea_clock,
3270 entries_required = ((planea_clock / 1000) * pixel_size * 3266 entries_required = ((planea_clock / 1000) * pixel_size *
3271 ILK_LP0_PLANE_LATENCY) / 1000; 3267 ILK_LP0_PLANE_LATENCY) / 1000;
3272 entries_required = DIV_ROUND_UP(entries_required, 3268 entries_required = DIV_ROUND_UP(entries_required,
3273 ironlake_display_wm_info.cacheline_size); 3269 ironlake_display_wm_info.cacheline_size);
3274 planea_wm = entries_required + 3270 planea_wm = entries_required +
3275 ironlake_display_wm_info.guard_size; 3271 ironlake_display_wm_info.guard_size;
3276 3272
@@ -3304,7 +3300,7 @@ static void ironlake_update_wm(struct drm_device *dev, int planea_clock,
3304 entries_required = ((planeb_clock / 1000) * pixel_size * 3300 entries_required = ((planeb_clock / 1000) * pixel_size *
3305 ILK_LP0_PLANE_LATENCY) / 1000; 3301 ILK_LP0_PLANE_LATENCY) / 1000;
3306 entries_required = DIV_ROUND_UP(entries_required, 3302 entries_required = DIV_ROUND_UP(entries_required,
3307 ironlake_display_wm_info.cacheline_size); 3303 ironlake_display_wm_info.cacheline_size);
3308 planeb_wm = entries_required + 3304 planeb_wm = entries_required +
3309 ironlake_display_wm_info.guard_size; 3305 ironlake_display_wm_info.guard_size;
3310 3306
@@ -3353,14 +3349,14 @@ static void ironlake_update_wm(struct drm_device *dev, int planea_clock,
3353 /* calculate the self-refresh watermark for display plane */ 3349 /* calculate the self-refresh watermark for display plane */
3354 entries_required = line_count * sr_hdisplay * pixel_size; 3350 entries_required = line_count * sr_hdisplay * pixel_size;
3355 entries_required = DIV_ROUND_UP(entries_required, 3351 entries_required = DIV_ROUND_UP(entries_required,
3356 ironlake_display_srwm_info.cacheline_size); 3352 ironlake_display_srwm_info.cacheline_size);
3357 sr_wm = entries_required + 3353 sr_wm = entries_required +
3358 ironlake_display_srwm_info.guard_size; 3354 ironlake_display_srwm_info.guard_size;
3359 3355
3360 /* calculate the self-refresh watermark for display cursor */ 3356 /* calculate the self-refresh watermark for display cursor */
3361 entries_required = line_count * pixel_size * 64; 3357 entries_required = line_count * pixel_size * 64;
3362 entries_required = DIV_ROUND_UP(entries_required, 3358 entries_required = DIV_ROUND_UP(entries_required,
3363 ironlake_cursor_srwm_info.cacheline_size); 3359 ironlake_cursor_srwm_info.cacheline_size);
3364 cursor_wm = entries_required + 3360 cursor_wm = entries_required +
3365 ironlake_cursor_srwm_info.guard_size; 3361 ironlake_cursor_srwm_info.guard_size;
3366 3362