diff options
author | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2021-12-16 15:27:41 +0100 |
---|---|---|
committer | Maarten Lankhorst <maarten.lankhorst@linux.intel.com> | 2021-12-21 13:26:33 +0100 |
commit | 2c3849baf2908d646b7466be52989835341551c4 (patch) | |
tree | e26e0ca362deb053a90ac722c61eeec32f20017f | |
parent | fb3965f9ae28b83290e5b5431a77aace66071ca1 (diff) |
drm/i915: Trylock the object when shrinking
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
-rw-r--r-- | drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c index 6003db8424dc..f893f0bb8d8e 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c @@ -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); |