From 9a6ddc1bb0a2ab51a8aae75b44d84654ccc9e153 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 21 Dec 2012 09:25:45 +0000 Subject: [PATCH] drm/i915: Hack to prevent page movement of unknown swizzled pages --- drivers/gpu/drm/i915/i915_gem.c | 6 ++++++ drivers/gpu/drm/i915/i915_gem_tiling.c | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index a3e0d0d..ef04e2a 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -1974,6 +1974,9 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) if (i915_gem_object_needs_bit17_swizzle(obj)) i915_gem_object_do_bit_17_swizzle(obj); + if (obj->tiling_mode != I915_TILING_NONE) + i915_gem_object_pin_pages(obj); + return 0; err_pages: @@ -3808,6 +3811,9 @@ i915_gem_madvise_ioctl(struct drm_device *dev, void *data, if (obj->madv != __I915_MADV_PURGED) obj->madv = args->madv; + if (i915_gem_object_is_purgeable(obj) && obj->tiling_mode != I915_TILING_NONE) + i915_gem_object_unpin_pages(obj); + /* if the object is no longer attached, discard its backing storage */ if (i915_gem_object_is_purgeable(obj) && obj->pages == NULL) i915_gem_object_truncate(obj); diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c index 65f1d4f..4b59199 100644 --- a/drivers/gpu/drm/i915/i915_gem_tiling.c +++ b/drivers/gpu/drm/i915/i915_gem_tiling.c @@ -382,6 +382,13 @@ i915_gem_set_tiling(struct drm_device *dev, void *data, } if (ret == 0) { + if (obj->madv == I915_MADV_WILLNEED) { + if (args->tiling_mode == I915_TILING_NONE) + i915_gem_object_unpin_pages(obj); + if (obj->tiling_mode == I915_TILING_NONE) + i915_gem_object_pin_pages(obj); + } + obj->fence_dirty = obj->fenced_gpu_access || obj->fence_reg != I915_FENCE_REG_NONE; -- 1.7.10.4