[PATCH 05/17] drm/i915: Pin the pages whilst operating on them

Chris Wilson
2016-08-22T08:04:08Z

As a safety precaution, whilst we operate on the object's pages
(clflushing them, updating the LRU) make sure we hold a pin on those
pages to prevent them disappearing underneath us.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_gem.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index de895c7ef9e6..e601b74c19f9 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3251,6 +3251,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)
if (ret)
return ret;

+ i915_gem_object_pin_pages(obj);
i915_gem_object_flush_cpu_write_domain(obj);

/* Serialise direct access to this object with the barriers for
@@ -3280,6 +3281,7 @@ i915_gem_object_set_to_gtt_domain(struct drm_i915_gem_object *obj, bool write)

/* And bump the LRU for this access */
i915_gem_object_bump_inactive_ggtt(obj);
+ i915_gem_object_unpin_pages(obj);

return 0;
}
--
2.9.3