diff options
author | Flora Cui <Flora.Cui@amd.com> | 2016-12-02 03:51:20 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-12-06 18:08:34 -0500 |
commit | 47e50d5c0d1347b3ab66d2270a45adc200fca31a (patch) | |
tree | 6f4b7fdd778b937c7ecae4c23664316734d74793 | |
parent | 10e2ca346bf74561ff1b7fff6287716ab976cd8c (diff) |
drm/amdgpu: fix gtt available page num accounting
Signed-off-by: Flora Cui <Flora.Cui@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c index 3c634f02a3d5..00f46b0e076d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | |||
@@ -164,8 +164,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, | |||
164 | spin_unlock(&mgr->lock); | 164 | spin_unlock(&mgr->lock); |
165 | 165 | ||
166 | node = kzalloc(sizeof(*node), GFP_KERNEL); | 166 | node = kzalloc(sizeof(*node), GFP_KERNEL); |
167 | if (!node) | 167 | if (!node) { |
168 | return -ENOMEM; | 168 | r = -ENOMEM; |
169 | goto err_out; | ||
170 | } | ||
169 | 171 | ||
170 | node->start = AMDGPU_BO_INVALID_OFFSET; | 172 | node->start = AMDGPU_BO_INVALID_OFFSET; |
171 | node->size = mem->num_pages; | 173 | node->size = mem->num_pages; |
@@ -176,12 +178,20 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man, | |||
176 | if (unlikely(r)) { | 178 | if (unlikely(r)) { |
177 | kfree(node); | 179 | kfree(node); |
178 | mem->mm_node = NULL; | 180 | mem->mm_node = NULL; |
181 | r = 0; | ||
182 | goto err_out; | ||
179 | } | 183 | } |
180 | } else { | 184 | } else { |
181 | mem->start = node->start; | 185 | mem->start = node->start; |
182 | } | 186 | } |
183 | 187 | ||
184 | return 0; | 188 | return 0; |
189 | err_out: | ||
190 | spin_lock(&mgr->lock); | ||
191 | mgr->available += mem->num_pages; | ||
192 | spin_unlock(&mgr->lock); | ||
193 | |||
194 | return r; | ||
185 | } | 195 | } |
186 | 196 | ||
187 | /** | 197 | /** |