Skip to content

Commit

Permalink
drm/amdgpu: free userptrs even if GTT isn't bound
Browse files Browse the repository at this point in the history
This fixes a memory leak since binding GTT only on demand.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Christian König authored and Alex Deucher committed Sep 28, 2016
1 parent 3d5f4d4 commit 85a4b57
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,16 +757,16 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)
{
struct amdgpu_ttm_tt *gtt = (void *)ttm;

if (gtt->userptr)
amdgpu_ttm_tt_unpin_userptr(ttm);

if (!amdgpu_ttm_is_bound(ttm))
return 0;

/* unbind shouldn't be done for GDS/GWS/OA in ttm_bo_clean_mm */
if (gtt->adev->gart.ready)
amdgpu_gart_unbind(gtt->adev, gtt->offset, ttm->num_pages);

if (gtt->userptr)
amdgpu_ttm_tt_unpin_userptr(ttm);

spin_lock(&gtt->adev->gtt_list_lock);
list_del_init(&gtt->list);
spin_unlock(&gtt->adev->gtt_list_lock);
Expand Down

0 comments on commit 85a4b57

Please sign in to comment.