aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2018-06-15 05:06:56 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-06-19 14:50:56 -0400
commit34d6d59986abb1d2cb5415a49b6c50f51ba1d2e4 (patch)
tree32399d31437585eadb471bc358b0688000f65ec4 /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parent5c53d19b76dccbaf340b11acb837d40c0789049d (diff)
drm/amdgpu: Update pin_size values before unpinning BO
At least in theory, ttm_bo_validate may move the BO, in which case the pin_size accounting would be inconsistent with when the BO was pinned. Cc: stable@vger.kernel.org Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_object.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_object.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 5e4e1bd90383..026140f08ee9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -790,15 +790,6 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
790 bo->pin_count--; 790 bo->pin_count--;
791 if (bo->pin_count) 791 if (bo->pin_count)
792 return 0; 792 return 0;
793 for (i = 0; i < bo->placement.num_placement; i++) {
794 bo->placements[i].lpfn = 0;
795 bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
796 }
797 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
798 if (unlikely(r)) {
799 dev_err(adev->dev, "%p validate failed for unpin\n", bo);
800 goto error;
801 }
802 793
803 if (bo->tbo.mem.mem_type == TTM_PL_VRAM) { 794 if (bo->tbo.mem.mem_type == TTM_PL_VRAM) {
804 adev->vram_pin_size -= amdgpu_bo_size(bo); 795 adev->vram_pin_size -= amdgpu_bo_size(bo);
@@ -808,7 +799,14 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo)
808 adev->gart_pin_size -= amdgpu_bo_size(bo); 799 adev->gart_pin_size -= amdgpu_bo_size(bo);
809 } 800 }
810 801
811error: 802 for (i = 0; i < bo->placement.num_placement; i++) {
803 bo->placements[i].lpfn = 0;
804 bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
805 }
806 r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
807 if (unlikely(r))
808 dev_err(adev->dev, "%p validate failed for unpin\n", bo);
809
812 return r; 810 return r;
813} 811}
814 812