Skip to content

Commit

Permalink
drm/i915: Trylock the object when shrinking
Browse files Browse the repository at this point in the history
We're working on requiring the obj->resv lock during unbind, fix
the shrinker to take the object lock.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211216142749.1966107-10-maarten.lankhorst@linux.intel.com
  • Loading branch information
Maarten Lankhorst committed Dec 21, 2021
1 parent fb3965f commit 2c3849b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,18 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
list_for_each_entry_safe(vma, next,
&i915->ggtt.vm.bound_list, vm_link) {
unsigned long count = vma->node.size >> PAGE_SHIFT;
struct drm_i915_gem_object *obj = vma->obj;

if (!vma->iomap || i915_vma_is_active(vma))
continue;

if (!i915_gem_object_trylock(obj))
continue;

if (__i915_vma_unbind(vma) == 0)
freed_pages += count;

i915_gem_object_unlock(obj);
}
mutex_unlock(&i915->ggtt.vm.mutex);

Expand Down

0 comments on commit 2c3849b

Please sign in to comment.