aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2016-04-26 13:29:41 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-04-27 04:16:17 -0400
commit1d2ac403ae3bfde7c50328ee0d39d3fb3d8d9823 (patch)
treeebdb7a84d3399feeb2e06b855f5ee04550101ea4 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
parentf47dbdd75bf3388ce8107c2e7e5a1eebd3700dd5 (diff)
drm: Protect dev->filelist with its own mutex
amdgpu gained dev->struct_mutex usage, and that's because it's walking the dev->filelist list. Protect that list with it's own lock to take one more step towards getting rid of struct_mutex usage in drivers once and for all. While doing the conversion I noticed that 2 debugfs files in i915 completely lacked appropriate locking. Fix that up too. v2: don't forget to switch to drm_gem_object_unreference_unlocked. Cc: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1461691808-12414-9-git-send-email-daniel.vetter@ffwll.ch
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index fa6a27bff298..a087b9638cde 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -93,7 +93,7 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
93 struct drm_device *ddev = adev->ddev; 93 struct drm_device *ddev = adev->ddev;
94 struct drm_file *file; 94 struct drm_file *file;
95 95
96 mutex_lock(&ddev->struct_mutex); 96 mutex_lock(&ddev->filelist_mutex);
97 97
98 list_for_each_entry(file, &ddev->filelist, lhead) { 98 list_for_each_entry(file, &ddev->filelist, lhead) {
99 struct drm_gem_object *gobj; 99 struct drm_gem_object *gobj;
@@ -103,13 +103,13 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
103 spin_lock(&file->table_lock); 103 spin_lock(&file->table_lock);
104 idr_for_each_entry(&file->object_idr, gobj, handle) { 104 idr_for_each_entry(&file->object_idr, gobj, handle) {
105 WARN_ONCE(1, "And also active allocations!\n"); 105 WARN_ONCE(1, "And also active allocations!\n");
106 drm_gem_object_unreference(gobj); 106 drm_gem_object_unreference_unlocked(gobj);
107 } 107 }
108 idr_destroy(&file->object_idr); 108 idr_destroy(&file->object_idr);
109 spin_unlock(&file->table_lock); 109 spin_unlock(&file->table_lock);
110 } 110 }
111 111
112 mutex_unlock(&ddev->struct_mutex); 112 mutex_unlock(&ddev->filelist_mutex);
113} 113}
114 114
115/* 115/*
@@ -769,7 +769,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data)
769 struct drm_file *file; 769 struct drm_file *file;
770 int r; 770 int r;
771 771
772 r = mutex_lock_interruptible(&dev->struct_mutex); 772 r = mutex_lock_interruptible(&dev->filelist_mutex);
773 if (r) 773 if (r)
774 return r; 774 return r;
775 775
@@ -793,7 +793,7 @@ static int amdgpu_debugfs_gem_info(struct seq_file *m, void *data)
793 spin_unlock(&file->table_lock); 793 spin_unlock(&file->table_lock);
794 } 794 }
795 795
796 mutex_unlock(&dev->struct_mutex); 796 mutex_unlock(&dev->filelist_mutex);
797 return 0; 797 return 0;
798} 798}
799 799