drm: Protect dev->filelist with its own mutex
[cascardo/linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_gem.c
index fa6a27b..a087b96 100644 (file)
@@ -93,7 +93,7 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
        struct drm_device *ddev = adev->ddev;
        struct drm_file *file;
 
-       mutex_lock(&ddev->struct_mutex);
+       mutex_lock(&ddev->filelist_mutex);
 
        list_for_each_entry(file, &ddev->filelist, lhead) {
                struct drm_gem_object *gobj;
@@ -103,13 +103,13 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
                spin_lock(&file->table_lock);
                idr_for_each_entry(&file->object_idr, gobj, handle) {
                        WARN_ONCE(1, "And also active allocations!\n");
-                       drm_gem_object_unreference(gobj);
+                       drm_gem_object_unreference_unlocked(gobj);
                }
                idr_destroy(&file->object_idr);
                spin_unlock(&file->table_lock);
        }
 
-       mutex_unlock(&ddev->struct_mutex);
+       mutex_unlock(&ddev->filelist_mutex);
 }
 
 /*
@@ -769,7 +769,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data)
        struct drm_file *file;
        int r;
 
-       r = mutex_lock_interruptible(&dev->struct_mutex);
+       r = mutex_lock_interruptible(&dev->filelist_mutex);
        if (r)
                return r;
 
@@ -793,7 +793,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data)
                spin_unlock(&file->table_lock);
        }
 
-       mutex_unlock(&dev->struct_mutex);
+       mutex_unlock(&dev->filelist_mutex);
        return 0;
 }