]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/i915: Only track bound elements of the GTT
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 4 Oct 2019 13:39:56 +0000 (14:39 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 4 Oct 2019 14:39:01 +0000 (15:39 +0100)
The premise here is to simply avoiding having to acquire the vm->mutex
inside vma create/destroy to update the vm->unbound_lists, to avoid some
nasty lock recursions later.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191004134015.13204-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gem/i915_gem_stolen.c
drivers/gpu/drm/i915/i915_gem_gtt.c
drivers/gpu/drm/i915/i915_gem_gtt.h
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c

index bfbc3e3daf924519134467746b7628442c90c128..e45eb87218506ff4960fd37575247c25a1f6cac4 100644 (file)
@@ -692,7 +692,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
        __i915_vma_set_map_and_fenceable(vma);
 
        mutex_lock(&ggtt->vm.mutex);
-       list_move_tail(&vma->vm_link, &ggtt->vm.bound_list);
+       list_add_tail(&vma->vm_link, &ggtt->vm.bound_list);
        mutex_unlock(&ggtt->vm.mutex);
 
        GEM_BUG_ON(i915_gem_object_is_shrinkable(obj));
index e62e9d1a130752cffbf081add88e0a0da20ccf3c..ad9eb2d68f3f3c079b01b8356bfcdafec2644886 100644 (file)
@@ -505,19 +505,12 @@ static void i915_address_space_fini(struct i915_address_space *vm)
 
 static void ppgtt_destroy_vma(struct i915_address_space *vm)
 {
-       struct list_head *phases[] = {
-               &vm->bound_list,
-               &vm->unbound_list,
-               NULL,
-       }, **phase;
+       struct i915_vma *vma, *vn;
 
        mutex_lock(&vm->i915->drm.struct_mutex);
-       for (phase = phases; *phase; phase++) {
-               struct i915_vma *vma, *vn;
-
-               list_for_each_entry_safe(vma, vn, *phase, vm_link)
-                       i915_vma_destroy(vma);
-       }
+       list_for_each_entry_safe(vma, vn, &vm->bound_list, vm_link)
+               i915_vma_destroy(vma);
+       GEM_BUG_ON(!list_empty(&vm->bound_list));
        mutex_unlock(&vm->i915->drm.struct_mutex);
 }
 
@@ -528,9 +521,6 @@ static void __i915_vm_release(struct work_struct *work)
 
        ppgtt_destroy_vma(vm);
 
-       GEM_BUG_ON(!list_empty(&vm->bound_list));
-       GEM_BUG_ON(!list_empty(&vm->unbound_list));
-
        vm->cleanup(vm);
        i915_address_space_fini(vm);
 
@@ -569,7 +559,6 @@ static void i915_address_space_init(struct i915_address_space *vm, int subclass)
 
        stash_init(&vm->free_pages);
 
-       INIT_LIST_HEAD(&vm->unbound_list);
        INIT_LIST_HEAD(&vm->bound_list);
 }
 
@@ -1887,10 +1876,6 @@ static struct i915_vma *pd_vma_create(struct gen6_ppgtt *ppgtt, int size)
        INIT_LIST_HEAD(&vma->obj_link);
        INIT_LIST_HEAD(&vma->closed_link);
 
-       mutex_lock(&vma->vm->mutex);
-       list_add(&vma->vm_link, &vma->vm->unbound_list);
-       mutex_unlock(&vma->vm->mutex);
-
        return vma;
 }
 
index 8fd2234ba0bf47a5f6c8389fa25a517018cea245..bbdc735466c146331e066983f2db8100bbd4bad0 100644 (file)
@@ -320,11 +320,6 @@ struct i915_address_space {
         */
        struct list_head bound_list;
 
-       /**
-        * List of vma that are not unbound.
-        */
-       struct list_head unbound_list;
-
        struct pagestash free_pages;
 
        /* Global GTT */
index 68c34b1a20e4847ea0a12564daab3ba4cce566b1..d097f77890ba8477ff1028d5e9a4e6bde74d20a2 100644 (file)
@@ -218,10 +218,6 @@ vma_create(struct drm_i915_gem_object *obj,
 
        spin_unlock(&obj->vma.lock);
 
-       mutex_lock(&vm->mutex);
-       list_add(&vma->vm_link, &vm->unbound_list);
-       mutex_unlock(&vm->mutex);
-
        return vma;
 
 err_vma:
@@ -657,7 +653,7 @@ i915_vma_insert(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
        GEM_BUG_ON(!i915_gem_valid_gtt_space(vma, color));
 
        mutex_lock(&vma->vm->mutex);
-       list_move_tail(&vma->vm_link, &vma->vm->bound_list);
+       list_add_tail(&vma->vm_link, &vma->vm->bound_list);
        mutex_unlock(&vma->vm->mutex);
 
        if (vma->obj) {
@@ -685,7 +681,7 @@ i915_vma_remove(struct i915_vma *vma)
 
        mutex_lock(&vma->vm->mutex);
        drm_mm_remove_node(&vma->node);
-       list_move_tail(&vma->vm_link, &vma->vm->unbound_list);
+       list_del(&vma->vm_link);
        mutex_unlock(&vma->vm->mutex);
 
        /*
@@ -798,10 +794,6 @@ static void __i915_vma_destroy(struct i915_vma *vma)
        GEM_BUG_ON(drm_mm_node_allocated(&vma->node));
        GEM_BUG_ON(vma->fence);
 
-       mutex_lock(&vma->vm->mutex);
-       list_del(&vma->vm_link);
-       mutex_unlock(&vma->vm->mutex);
-
        if (vma->obj) {
                struct drm_i915_gem_object *obj = vma->obj;
 
index f901bbb9586e02610cd074bcd8826986f1c8a7ba..0945d6e978a2e88e9c1e17a395c7d5c78f8659ce 100644 (file)
@@ -1242,7 +1242,7 @@ static void track_vma_bind(struct i915_vma *vma)
        vma->pages = obj->mm.pages;
 
        mutex_lock(&vma->vm->mutex);
-       list_move_tail(&vma->vm_link, &vma->vm->bound_list);
+       list_add_tail(&vma->vm_link, &vma->vm->bound_list);
        mutex_unlock(&vma->vm->mutex);
 }