[PATCH 6/8] drm/i915: Acquire a wakeref for unbind on vma release if needed

Thomas Hellström thomas.hellstrom at linux.intel.com
Tue Dec 21 11:59:30 UTC 2021


For I915_VMA_GLOBAL_BIND vma unbinds we need to have acquired a wakeref.
That's not always the case at i915_vma_release().

Make sure that is the case by conditionally acquiring a wakeref around
__i915_vma_unbind in that function.

Fixes: 2850748ef876 ("drm/i915: Pull i915_vma_pin under the vm->mutex")
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_vma.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 1d4e448d22d9..a278bf571903 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -1593,11 +1593,18 @@ void i915_vma_release(struct kref *ref)
 	struct drm_i915_gem_object *obj = vma->obj;
 
 	if (drm_mm_node_allocated(&vma->node)) {
-		mutex_lock(&vma->vm->mutex);
+		struct i915_address_space *vm = vma->vm;
+		intel_wakeref_t wakeref = 0;
+
+		if (i915_vma_is_bound(vma, I915_VMA_GLOBAL_BIND))
+			wakeref = intel_runtime_pm_get(&vm->i915->runtime_pm);
+		mutex_lock_nested(&vm->mutex, !wakeref);
 		atomic_and(~I915_VMA_PIN_MASK, &vma->flags);
 		WARN_ON(__i915_vma_unbind(vma));
 		mutex_unlock(&vma->vm->mutex);
 		GEM_BUG_ON(drm_mm_node_allocated(&vma->node));
+		if (wakeref)
+			intel_runtime_pm_put(&vm->i915->runtime_pm, wakeref);
 	}
 	GEM_BUG_ON(i915_vma_is_active(vma));
 
-- 
2.31.1



More information about the Intel-gfx-trybot mailing list