Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915/gt: Pin the rings before marking active

On eviction, we acquire the vm->mutex and then wait on the vma->active.
Therefore when binding and pinning the vma, we must follow the same
sequence, lock/pin the vma then mark it active. Otherwise, we mark the
vma as active, then wait for the vm->mutex, and meanwhile the evictor
holding the mutex waits upon us to complete our activity.

Fixes: 8ccfc20a7d56 ("drm/i915/gt: Mark ring->vma as active while pinned")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: <stable@vger.kernel.org> # v5.6+
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200706170138.8993-1-chris@chris-wilson.co.uk

+6 -6
+6 -6
drivers/gpu/drm/i915/gt/intel_context.c
··· 204 204 { 205 205 int err; 206 206 207 - err = i915_active_acquire(&ring->vma->active); 207 + err = intel_ring_pin(ring); 208 208 if (err) 209 209 return err; 210 210 211 - err = intel_ring_pin(ring); 211 + err = i915_active_acquire(&ring->vma->active); 212 212 if (err) 213 - goto err_active; 213 + goto err_pin; 214 214 215 215 return 0; 216 216 217 - err_active: 218 - i915_active_release(&ring->vma->active); 217 + err_pin: 218 + intel_ring_unpin(ring); 219 219 return err; 220 220 } 221 221 222 222 static void __ring_retire(struct intel_ring *ring) 223 223 { 224 - intel_ring_unpin(ring); 225 224 i915_active_release(&ring->vma->active); 225 + intel_ring_unpin(ring); 226 226 } 227 227 228 228 __i915_active_call