提交 8de9b311 编写于 作者: C Chris Wilson 提交者: Eric Anholt

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: NChris Wilson <chris@chris-wilson.co.uk>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: NEric Anholt <eric@anholt.net>
上级 d7961364
...@@ -2734,7 +2734,7 @@ static unsigned long intel_calculate_wm(unsigned long clock_in_khz, ...@@ -2734,7 +2734,7 @@ static unsigned long intel_calculate_wm(unsigned long clock_in_khz,
*/ */
entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) / entries_required = ((clock_in_khz / 1000) * pixel_size * latency_ns) /
1000; 1000;
entries_required /= wm->cacheline_size; entries_required = DIV_ROUND_UP(entries_required, wm->cacheline_size);
DRM_DEBUG_KMS("FIFO entries required for mode: %d\n", entries_required); DRM_DEBUG_KMS("FIFO entries required for mode: %d\n", entries_required);
...@@ -2855,11 +2855,9 @@ static int i9xx_get_fifo_size(struct drm_device *dev, int plane) ...@@ -2855,11 +2855,9 @@ static int i9xx_get_fifo_size(struct drm_device *dev, int plane)
uint32_t dsparb = I915_READ(DSPARB); uint32_t dsparb = I915_READ(DSPARB);
int size; int size;
if (plane == 0)
size = dsparb & 0x7f; size = dsparb & 0x7f;
else if (plane)
size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) - size;
(dsparb & 0x7f);
DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb,
plane ? "B" : "A", size); plane ? "B" : "A", size);
...@@ -2873,11 +2871,9 @@ static int i85x_get_fifo_size(struct drm_device *dev, int plane) ...@@ -2873,11 +2871,9 @@ static int i85x_get_fifo_size(struct drm_device *dev, int plane)
uint32_t dsparb = I915_READ(DSPARB); uint32_t dsparb = I915_READ(DSPARB);
int size; int size;
if (plane == 0)
size = dsparb & 0x1ff; size = dsparb & 0x1ff;
else if (plane)
size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) - size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) - size;
(dsparb & 0x1ff);
size >>= 1; /* Convert to cachelines */ size >>= 1; /* Convert to cachelines */
DRM_DEBUG_KMS("FIFO size - (0x%08x) %s: %d\n", dsparb, 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,12 +3005,12 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock,
*/ */
entries_required = ((planea_clock / 1000) * pixel_size * latency_ns) / entries_required = ((planea_clock / 1000) * pixel_size * latency_ns) /
1000; 1000;
entries_required /= G4X_FIFO_LINE_SIZE; entries_required = DIV_ROUND_UP(entries_required, G4X_FIFO_LINE_SIZE);
planea_wm = entries_required + planea_params.guard_size; planea_wm = entries_required + planea_params.guard_size;
entries_required = ((planeb_clock / 1000) * pixel_size * latency_ns) / entries_required = ((planeb_clock / 1000) * pixel_size * latency_ns) /
1000; 1000;
entries_required /= G4X_FIFO_LINE_SIZE; entries_required = DIV_ROUND_UP(entries_required, G4X_FIFO_LINE_SIZE);
planeb_wm = entries_required + planeb_params.guard_size; planeb_wm = entries_required + planeb_params.guard_size;
cursora_wm = cursorb_wm = 16; cursora_wm = cursorb_wm = 16;
...@@ -3033,12 +3029,12 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock, ...@@ -3033,12 +3029,12 @@ static void g4x_update_wm(struct drm_device *dev, int planea_clock,
/* Use ns/us then divide to preserve precision */ /* Use ns/us then divide to preserve precision */
sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
pixel_size * sr_hdisplay; pixel_size * sr_hdisplay;
sr_entries = roundup(sr_entries / cacheline_size, 1); sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size);
entries_required = (((sr_latency_ns / line_time_us) + entries_required = (((sr_latency_ns / line_time_us) +
1000) / 1000) * pixel_size * 64; 1000) / 1000) * pixel_size * 64;
entries_required = roundup(entries_required / entries_required = DIV_ROUND_UP(entries_required,
g4x_cursor_wm_info.cacheline_size, 1); g4x_cursor_wm_info.cacheline_size);
cursor_sr = entries_required + g4x_cursor_wm_info.guard_size; cursor_sr = entries_required + g4x_cursor_wm_info.guard_size;
if (cursor_sr > g4x_cursor_wm_info.max_wm) 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,7 +3085,7 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock,
/* Use ns/us then divide to preserve precision */ /* Use ns/us then divide to preserve precision */
sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
pixel_size * sr_hdisplay; pixel_size * sr_hdisplay;
sr_entries = roundup(sr_entries / I915_FIFO_LINE_SIZE, 1); sr_entries = DIV_ROUND_UP(sr_entries, I915_FIFO_LINE_SIZE);
DRM_DEBUG("self-refresh entries: %d\n", sr_entries); DRM_DEBUG("self-refresh entries: %d\n", sr_entries);
srwm = I965_FIFO_SIZE - sr_entries; srwm = I965_FIFO_SIZE - sr_entries;
if (srwm < 0) if (srwm < 0)
...@@ -3098,8 +3094,8 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock, ...@@ -3098,8 +3094,8 @@ static void i965_update_wm(struct drm_device *dev, int planea_clock,
sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
pixel_size * 64; pixel_size * 64;
sr_entries = roundup(sr_entries / sr_entries = DIV_ROUND_UP(sr_entries,
i965_cursor_wm_info.cacheline_size, 1); i965_cursor_wm_info.cacheline_size);
cursor_sr = i965_cursor_wm_info.fifo_size - cursor_sr = i965_cursor_wm_info.fifo_size -
(sr_entries + i965_cursor_wm_info.guard_size); (sr_entries + i965_cursor_wm_info.guard_size);
...@@ -3181,7 +3177,7 @@ static void i9xx_update_wm(struct drm_device *dev, int planea_clock, ...@@ -3181,7 +3177,7 @@ static void i9xx_update_wm(struct drm_device *dev, int planea_clock,
/* Use ns/us then divide to preserve precision */ /* Use ns/us then divide to preserve precision */
sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) * sr_entries = (((sr_latency_ns / line_time_us) + 1000) / 1000) *
pixel_size * sr_hdisplay; pixel_size * sr_hdisplay;
sr_entries = roundup(sr_entries / cacheline_size, 1); sr_entries = DIV_ROUND_UP(sr_entries, cacheline_size);
DRM_DEBUG_KMS("self-refresh entries: %d\n", sr_entries); DRM_DEBUG_KMS("self-refresh entries: %d\n", sr_entries);
srwm = total_size - sr_entries; srwm = total_size - sr_entries;
if (srwm < 0) if (srwm < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册