drm/i915: clear the entire gtt when using gem
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 26 Mar 2012 07:45:42 +0000 (09:45 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 27 Mar 2012 11:15:24 +0000 (13:15 +0200)
We've lost our guard page somewhere in the gtt rewrite, this patch
here will restore it.

Exercised by i-g-t/tests/gem_cs_prefetch.

v2: Substract the guard page from the range we're supposed to manage
with gem. Suggested by Chris Wilson to increase the odds of old ums +
gem userspace not blowing up. To compensate for the loss of a page,
don't substract the guard page in the modeset init code any longer.

Tested-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=44748
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_gem_gtt.c

index c2d9eaedff331e4a6be66f128c76fab4853a0570..4f690374fffe46b1ddc4d60583b61a7ee745ec02 100644 (file)
@@ -1207,8 +1207,6 @@ static int i915_load_gem_init(struct drm_device *dev)
                /* PPGTT pdes are stolen from global gtt ptes, so shrink the
                 * aperture accordingly when using aliasing ppgtt. */
                gtt_size -= I915_PPGTT_PD_ENTRIES*PAGE_SIZE;
-               /* For paranoia keep the guard page in between. */
-               gtt_size -= PAGE_SIZE;
 
                i915_gem_init_global_gtt(dev, 0, mappable_size, gtt_size);
 
@@ -1227,7 +1225,7 @@ static int i915_load_gem_init(struct drm_device *dev)
                 * aperture.
                 */
                i915_gem_init_global_gtt(dev, 0, mappable_size,
-                                        gtt_size - PAGE_SIZE);
+                                        gtt_size);
        }
 
        ret = i915_gem_init_hw(dev);
index 98ed612d8d65fdd5c08ecbf7479c09a121fde4c6..5a626f7af0c7ee8c13ee4e5e3ff447015d5b4ec4 100644 (file)
@@ -429,7 +429,8 @@ void i915_gem_init_global_gtt(struct drm_device *dev,
 {
        drm_i915_private_t *dev_priv = dev->dev_private;
 
-       drm_mm_init(&dev_priv->mm.gtt_space, start, end - start);
+       /* Substract the guard page ... */
+       drm_mm_init(&dev_priv->mm.gtt_space, start, end - start - PAGE_SIZE);
 
        dev_priv->mm.gtt_start = start;
        dev_priv->mm.gtt_mappable_end = mappable_end;
@@ -437,6 +438,6 @@ void i915_gem_init_global_gtt(struct drm_device *dev,
        dev_priv->mm.gtt_total = end - start;
        dev_priv->mm.mappable_gtt_total = min(end, mappable_end) - start;
 
-       /* Take over this portion of the GTT */
+       /* ... but ensure that we clear the entire range. */
        intel_gtt_clear_range(start / PAGE_SIZE, (end-start) / PAGE_SIZE);
 }