[Intel-gfx] [PATCH 09/33] drm/i915/gt: Mark ring->vma as active while pinned

Chris Wilson chris at chris-wilson.co.uk
Thu Dec 12 14:04:35 UTC 2019


As we use the active state to keep the vma alive while we are reading
its contents during GPU error capture, we need to mark the
ring->vma as active during execution if we want to include the rinbuffer
in the error state.

Reported-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Fixes: b1e3177bd1d8 ("drm/i915: Coordinate i915_active with its own mutex")
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Cc: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
---
 drivers/gpu/drm/i915/gt/intel_ring.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_ring.c b/drivers/gpu/drm/i915/gt/intel_ring.c
index 374b28f13ca0..7a27264150b9 100644
--- a/drivers/gpu/drm/i915/gt/intel_ring.c
+++ b/drivers/gpu/drm/i915/gt/intel_ring.c
@@ -45,6 +45,10 @@ int intel_ring_pin(struct intel_ring *ring)
 	if (unlikely(ret))
 		goto err_unpin;
 
+	ret = i915_active_acquire(&vma->active);
+	if (ret)
+		goto err_ring;
+
 	if (i915_vma_is_map_and_fenceable(vma))
 		addr = (void __force *)i915_vma_pin_iomap(vma);
 	else
@@ -52,7 +56,7 @@ int intel_ring_pin(struct intel_ring *ring)
 					       i915_coherent_map_type(vma->vm->i915));
 	if (IS_ERR(addr)) {
 		ret = PTR_ERR(addr);
-		goto err_ring;
+		goto err_active;
 	}
 
 	i915_vma_make_unshrinkable(vma);
@@ -63,6 +67,8 @@ int intel_ring_pin(struct intel_ring *ring)
 	ring->vaddr = addr;
 	return 0;
 
+err_active:
+	i915_active_release(&vma->active);
 err_ring:
 	i915_vma_unpin(vma);
 err_unpin:
@@ -93,6 +99,8 @@ void intel_ring_unpin(struct intel_ring *ring)
 		i915_gem_object_unpin_map(vma->obj);
 
 	i915_vma_make_purgeable(vma);
+
+	i915_active_release(&vma->active);
 	i915_vma_unpin(vma);
 }
 
-- 
2.24.0



More information about the Intel-gfx mailing list