drm/i915: Add object locking to vm_fault_cpu
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Tue, 23 Mar 2021 15:50:12 +0000 (16:50 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 24 Mar 2021 16:27:20 +0000 (17:27 +0100)
Take a simple lock so we hold ww around (un)pin_pages as needed.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210323155059.628690-24-maarten.lankhorst@linux.intel.com
drivers/gpu/drm/i915/gem/i915_gem_mman.c

index c0034d811e508067f496db9724cd48e8c23efe7b..163208a6260d1cbd13a711d846357c6bb7f06aa9 100644 (file)
@@ -246,6 +246,9 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf)
                     area->vm_flags & VM_WRITE))
                return VM_FAULT_SIGBUS;
 
+       if (i915_gem_object_lock_interruptible(obj, NULL))
+               return VM_FAULT_NOPAGE;
+
        err = i915_gem_object_pin_pages(obj);
        if (err)
                goto out;
@@ -269,6 +272,7 @@ static vm_fault_t vm_fault_cpu(struct vm_fault *vmf)
        i915_gem_object_unpin_pages(obj);
 
 out:
+       i915_gem_object_unlock(obj);
        return i915_error_to_vmf_fault(err);
 }