Skip to contentSkip to conversation

drm/amdgpu: fix gtt available page num accounting

PATCH In review Flora Cui 2 participants 2 messages Dec 2, 2016 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Flora Cui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix gtt available page num accounting

Change-Id I54d38957fe52c83bcee676da05bc480fcf1bc916
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +12 -2
index 3c634f0..00f46b0 100644
@@ -164,8 +164,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
 	spin_unlock(&mgr->lock);
 
 	node = kzalloc(sizeof(*node), GFP_KERNEL);
-	if (!node)
-		return -ENOMEM;
+	if (!node) {
+		r = -ENOMEM;
+		goto err_out;
+	}
 
 	node->start = AMDGPU_BO_INVALID_OFFSET;
 	node->size = mem->num_pages;
@@ -176,12 +178,20 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
 		if (unlikely(r)) {
 			kfree(node);
 			mem->mm_node = NULL;
+			r = 0;
+			goto err_out;
 		}
 	} else {
 		mem->start = node->start;
 	}
 
 	return 0;
+err_out:
+	spin_lock(&mgr->lock);
+	mgr->available += mem->num_pages;
+	spin_unlock(&mgr->lock);
+
+	return r;
 }
 
 /**
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1480669901-23558-1-git-send-email-Flora.Cui-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 02.12.2016 um 10:11 schrieb Flora Cui:

Quoted 3 lines
Change-Id I54d38957fe52c83bcee676da05bc480fcf1bc916

Nice catch, Reviewed-by: Christian König <[email protected]>.

Quoted 32 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +6 -2
index 3c634f0..00f46b0 100644
@@ -164,8 +164,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
  	spin_unlock(&mgr->lock);
 
  	node = kzalloc(sizeof(*node), GFP_KERNEL);
-	if (!node)
-		return -ENOMEM;
+	if (!node) {
+		r = -ENOMEM;
+		goto err_out;
+	}
 
  	node->start = AMDGPU_BO_INVALID_OFFSET;
  	node->size = mem->num_pages;
@@ -176,12 +178,20 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,
  		if (unlikely(r)) {
  			kfree(node);
  			mem->mm_node = NULL;
+			r = 0;
+			goto err_out;
  		}
  	} else {
  		mem->start = node->start;
  	}
 

drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, · line 197

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +6 -0
  	return 0;
+err_out:
+	spin_lock(&mgr->lock);
+	mgr->available += mem->num_pages;
+	spin_unlock(&mgr->lock);
+
+	return r;
  }
 
  /**

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx