@@ -115,12 +115,9 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_pri
115115 struct amdgpu_vm * vm = & fpriv -> vm ;
116116 struct amdgpu_bo_va * bo_va ;
117117 int r ;
118- mutex_lock (& vm -> mutex );
119118 r = amdgpu_bo_reserve (rbo , false);
120- if (r ) {
121- mutex_unlock (& vm -> mutex );
119+ if (r )
122120 return r ;
123- }
124121
125122 bo_va = amdgpu_vm_bo_find (vm , rbo );
126123 if (!bo_va ) {
@@ -129,7 +126,6 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_pri
129126 ++ bo_va -> ref_count ;
130127 }
131128 amdgpu_bo_unreserve (rbo );
132- mutex_unlock (& vm -> mutex );
133129 return 0 ;
134130}
135131
@@ -142,10 +138,8 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
142138 struct amdgpu_vm * vm = & fpriv -> vm ;
143139 struct amdgpu_bo_va * bo_va ;
144140 int r ;
145- mutex_lock (& vm -> mutex );
146141 r = amdgpu_bo_reserve (rbo , true);
147142 if (r ) {
148- mutex_unlock (& vm -> mutex );
149143 dev_err (adev -> dev , "leaking bo va because "
150144 "we fail to reserve bo (%d)\n" , r );
151145 return ;
@@ -157,7 +151,6 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
157151 }
158152 }
159153 amdgpu_bo_unreserve (rbo );
160- mutex_unlock (& vm -> mutex );
161154}
162155
163156static int amdgpu_gem_handle_lockup (struct amdgpu_device * adev , int r )
@@ -553,7 +546,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
553546 gobj = drm_gem_object_lookup (dev , filp , args -> handle );
554547 if (gobj == NULL )
555548 return - ENOENT ;
556- mutex_lock (& fpriv -> vm .mutex );
557549 rbo = gem_to_amdgpu_bo (gobj );
558550 INIT_LIST_HEAD (& list );
559551 INIT_LIST_HEAD (& duplicates );
@@ -568,7 +560,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
568560 }
569561 r = ttm_eu_reserve_buffers (& ticket , & list , true, & duplicates );
570562 if (r ) {
571- mutex_unlock (& fpriv -> vm .mutex );
572563 drm_gem_object_unreference_unlocked (gobj );
573564 return r ;
574565 }
@@ -577,7 +568,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
577568 if (!bo_va ) {
578569 ttm_eu_backoff_reservation (& ticket , & list );
579570 drm_gem_object_unreference_unlocked (gobj );
580- mutex_unlock (& fpriv -> vm .mutex );
581571 return - ENOENT ;
582572 }
583573
@@ -602,7 +592,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
602592 ttm_eu_backoff_reservation (& ticket , & list );
603593 if (!r && !(args -> flags & AMDGPU_VM_DELAY_UPDATE ))
604594 amdgpu_gem_va_update_vm (adev , bo_va , args -> operation );
605- mutex_unlock ( & fpriv -> vm . mutex );
595+
606596 drm_gem_object_unreference_unlocked (gobj );
607597 return r ;
608598}
0 commit comments