drm/amdgpu: free userptrs even if GTT isn't bound
authorChristian König <christian.koenig@amd.com>
Thu, 22 Sep 2016 12:19:50 +0000 (14:19 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 28 Sep 2016 20:16:25 +0000 (16:16 -0400)
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>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 61a885b5a6a12f46011e53d3a501dd511755861d..c80bdc7194e5102f8c54e030a883aaaecba161e1 100644 (file)
@@ -757,6 +757,9 @@ 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;
 
@@ -764,9 +767,6 @@ static int amdgpu_ttm_backend_unbind(struct ttm_tt *ttm)
        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);