Skip to contentSkip to conversation

drm/amdgpu: clean up the amdgpu_cs_parser_bos

PATCH Superseded Sunil Khatri 2 participants 2 messages Feb 4

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/amdgpu: clean up the amdgpu_cs_parser_bos

In low memory conditions when kmalloc can fail and hence we need to clean up the bo list and unlock the mutex for clean exit.

Fixes 737da5363cc0 ("drm/amdgpu: update the functions to use amdgpu version of hmm")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -2
index d591dce0f3b3..b166bccecee3 100644
@@ -892,8 +892,10 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 		struct amdgpu_bo *bo = e->bo;
 
 		e->range = amdgpu_hmm_range_alloc(NULL);
-		if (unlikely(!e->range))
-			return -ENOMEM;
+		if (unlikely(!e->range)) {
+			r = -ENOMEM;
+			goto out_free_user_pages;
+		}
 
 		r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
 		if (r)
@@ -998,6 +1000,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 		amdgpu_hmm_range_free(e->range);
 		e->range = NULL;
 	}
+
+	amdgpu_bo_list_put(p->bo_list);
 	mutex_unlock(&p->bo_list->bo_list_mutex);
 	return r;
 }
Signature · 1 line
2.34.1
#1 lore raw

Ignore this patch version as v4 is pushed.

Regards
Sunil Khatri

Quoted 39 lines · Sunil Khatri

In low memory conditions when kmalloc can fail and hence we need to clean up the bo list and unlock the mutex for clean exit.

Fixes 737da5363cc0 ("drm/amdgpu: update the functions to use amdgpu version of hmm")
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 8 ++++++--
  1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -2
index d591dce0f3b3..b166bccecee3 100644
@@ -892,8 +892,10 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
  		struct amdgpu_bo *bo = e->bo;
 
  		e->range = amdgpu_hmm_range_alloc(NULL);
-		if (unlikely(!e->range))
-			return -ENOMEM;
+		if (unlikely(!e->range)) {
+			r = -ENOMEM;
+			goto out_free_user_pages;
+		}
 
  		r = amdgpu_ttm_tt_get_user_pages(bo, e->range);
  		if (r)
@@ -998,6 +1000,8 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
  		amdgpu_hmm_range_free(e->range);
  		e->range = NULL;
  	}
+
+	amdgpu_bo_list_put(p->bo_list);
  	mutex_unlock(&p->bo_list->bo_list_mutex);
  	return r;
  }