[PATCH 2/4] drm/amdgpu: Optimization of critical section

Alex Xie AlexBin.Xie at amd.com
Mon Jun 12 20:31:23 UTC 2017


Make the critical section smaller. There is no
need to protect the bo_list, because there is
no other task can access the newly created BO
list yet.

Signed-off-by: Alex Xie <AlexBin.Xie at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
index 02c138f..c994a04 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
@@ -48,8 +48,9 @@ static int amdgpu_bo_list_create(struct amdgpu_fpriv *fpriv,
 	mutex_lock(&fpriv->bo_list_lock);
 	r = idr_alloc(&fpriv->bo_list_handles, *result,
 		      1, 0, GFP_KERNEL);
+	mutex_unlock(&fpriv->bo_list_lock);
+
 	if (r < 0) {
-		mutex_unlock(&fpriv->bo_list_lock);
 		kfree(*result);
 		return r;
 	}
@@ -60,7 +61,6 @@ static int amdgpu_bo_list_create(struct amdgpu_fpriv *fpriv,
 	(*result)->array = NULL;
 
 	mutex_lock(&(*result)->lock);
-	mutex_unlock(&fpriv->bo_list_lock);
 
 	return 0;
 }
-- 
2.7.4



More information about the amd-gfx mailing list