drm/i915: Use RCU for unlocked vm_idr lookup
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 30 Aug 2019 18:03:25 +0000 (19:03 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 30 Aug 2019 20:17:48 +0000 (21:17 +0100)
Since i915_address_space is now RCU protected, we can do the vm_idr lookup
without taking the vm_idr_mutex, just with the rcu_read_lock() instead.

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/20190830180325.7755-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gem/i915_gem_context.c

index 1f735ca9b1736dcc3d2096924acf4d10e3ca5581..b8969605f4e897fa717a78ca8dbbeccbdc7764f2 100644 (file)
@@ -1057,14 +1057,11 @@ static int set_ppgtt(struct drm_i915_file_private *file_priv,
        if (upper_32_bits(args->value))
                return -ENOENT;
 
-       err = mutex_lock_interruptible(&file_priv->vm_idr_lock);
-       if (err)
-               return err;
-
+       rcu_read_lock();
        vm = idr_find(&file_priv->vm_idr, args->value);
-       if (vm)
-               i915_vm_get(vm);
-       mutex_unlock(&file_priv->vm_idr_lock);
+       if (vm && !kref_get_unless_zero(&vm->ref))
+               vm = NULL;
+       rcu_read_unlock();
        if (!vm)
                return -ENOENT;