mirror of
https://github.com/torvalds/linux
synced 2024-09-06 09:51:23 +00:00
drm/i915: Avoid live-lock with i915_vma_parked()
Abuse^W Take advantage that we know we are inside the GT wakeref and
that prevents any client execbuf from reopening the i915_vma in order to
claim all the vma to close without having to drop the spinlock to free
each one individually. By keeping the spinlock, we do not have to
restart if we run concurrently with i915_gem_free_objects -- which
causes them both to restart continually and make very very slow
progress.
Closes: https://gitlab.freedesktop.org/drm/intel/issues/1361
Fixes: 77853186e5
("drm/i915: Claim vma while under closed_lock in i915_vma_parked()")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200323092841.22240-2-chris@chris-wilson.co.uk
This commit is contained in:
parent
8e87e0139a
commit
3447c4c55d
|
@ -1097,6 +1097,7 @@ void i915_vma_release(struct kref *ref)
|
||||||
void i915_vma_parked(struct intel_gt *gt)
|
void i915_vma_parked(struct intel_gt *gt)
|
||||||
{
|
{
|
||||||
struct i915_vma *vma, *next;
|
struct i915_vma *vma, *next;
|
||||||
|
LIST_HEAD(closed);
|
||||||
|
|
||||||
spin_lock_irq(>->closed_lock);
|
spin_lock_irq(>->closed_lock);
|
||||||
list_for_each_entry_safe(vma, next, >->closed_vma, closed_link) {
|
list_for_each_entry_safe(vma, next, >->closed_vma, closed_link) {
|
||||||
|
@ -1108,28 +1109,26 @@ void i915_vma_parked(struct intel_gt *gt)
|
||||||
if (!kref_get_unless_zero(&obj->base.refcount))
|
if (!kref_get_unless_zero(&obj->base.refcount))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i915_vm_tryopen(vm)) {
|
if (!i915_vm_tryopen(vm)) {
|
||||||
list_del_init(&vma->closed_link);
|
|
||||||
} else {
|
|
||||||
i915_gem_object_put(obj);
|
i915_gem_object_put(obj);
|
||||||
obj = NULL;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irq(>->closed_lock);
|
list_move(&vma->closed_link, &closed);
|
||||||
|
|
||||||
if (obj) {
|
|
||||||
__i915_vma_put(vma);
|
|
||||||
i915_gem_object_put(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
i915_vm_close(vm);
|
|
||||||
|
|
||||||
/* Restart after dropping lock */
|
|
||||||
spin_lock_irq(>->closed_lock);
|
|
||||||
next = list_first_entry(>->closed_vma,
|
|
||||||
typeof(*next), closed_link);
|
|
||||||
}
|
}
|
||||||
spin_unlock_irq(>->closed_lock);
|
spin_unlock_irq(>->closed_lock);
|
||||||
|
|
||||||
|
/* As the GT is held idle, no vma can be reopened as we destroy them */
|
||||||
|
list_for_each_entry_safe(vma, next, &closed, closed_link) {
|
||||||
|
struct drm_i915_gem_object *obj = vma->obj;
|
||||||
|
struct i915_address_space *vm = vma->vm;
|
||||||
|
|
||||||
|
INIT_LIST_HEAD(&vma->closed_link);
|
||||||
|
__i915_vma_put(vma);
|
||||||
|
|
||||||
|
i915_gem_object_put(obj);
|
||||||
|
i915_vm_close(vm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __i915_vma_iounmap(struct i915_vma *vma)
|
static void __i915_vma_iounmap(struct i915_vma *vma)
|
||||||
|
|
Loading…
Reference in a new issue