diff mbox series

[03/10] drm/i915: Assume exclusive access to objects inside resume

Message ID 20190819164448.22132-3-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [01/10] drm/i915: Use 0 for the unordered context | expand

Commit Message

Chris Wilson Aug. 19, 2019, 4:44 p.m. UTC
Inside gtt_restore_mappings() we currently take the obj->resv->lock, but
in the future we need to avoid taking this fs-reclaim tainted lock as we
need to extend the coverage of the vm->mutex. Take advantage of the
single-threaded nature of the early resume phase, and do a single
wbinvd() to flush all the GTT objects en masse.

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

Comments

Matthew Auld Aug. 19, 2019, 7:57 p.m. UTC | #1
On Mon, 19 Aug 2019 at 17:45, Chris Wilson <chris@chris-wilson.co.uk> wrote:
>
> Inside gtt_restore_mappings() we currently take the obj->resv->lock, but
> in the future we need to avoid taking this fs-reclaim tainted lock as we
> need to extend the coverage of the vm->mutex. Take advantage of the
> single-threaded nature of the early resume phase, and do a single
> wbinvd() to flush all the GTT objects en masse.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 5413c2ff51a2..e48df11a19fb 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -3274,6 +3274,7 @@  void i915_ggtt_disable_guc(struct i915_ggtt *ggtt)
 static void ggtt_restore_mappings(struct i915_ggtt *ggtt)
 {
 	struct i915_vma *vma, *vn;
+	bool flush = false;
 
 	intel_gt_check_and_clear_faults(ggtt->vm.gt);
 
@@ -3298,10 +3299,9 @@  static void ggtt_restore_mappings(struct i915_ggtt *ggtt)
 		WARN_ON(i915_vma_bind(vma,
 				      obj ? obj->cache_level : 0,
 				      PIN_UPDATE));
-		if (obj) {
-			i915_gem_object_lock(obj);
-			WARN_ON(i915_gem_object_set_to_gtt_domain(obj, false));
-			i915_gem_object_unlock(obj);
+		if (obj) { /* only used during resume => exclusive access */
+			flush |= fetch_and_zero(&obj->write_domain);
+			obj->read_domains |= I915_GEM_DOMAIN_GTT;
 		}
 
 lock:
@@ -3312,6 +3312,9 @@  static void ggtt_restore_mappings(struct i915_ggtt *ggtt)
 	ggtt->invalidate(ggtt);
 
 	mutex_unlock(&ggtt->vm.mutex);
+
+	if (flush)
+		wbinvd_on_all_cpus();
 }
 
 void i915_gem_restore_gtt_mappings(struct drm_i915_private *i915)