aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorJohn Brooks <john@fastquake.com>2017-06-27 22:33:18 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-07-14 11:06:33 -0400
commit00f06b246a3056bbaa901a90a5a93c9f81ab8e36 (patch)
tree097060002ba3b1340935941ff5a12c9fb5a60cec /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parent218b5dcde4d30e071eec4201a36af665ccfa7e1c (diff)
drm/amdgpu: Throttle visible VRAM moves separately
The BO move throttling code is designed to allow VRAM to fill quickly if it is relatively empty. However, this does not take into account situations where the visible VRAM is smaller than total VRAM, and total VRAM may not be close to full but the visible VRAM segment is under pressure. In such situations, visible VRAM would experience unrestricted swapping and performance would drop. Add a separate counter specifically for moves involving visible VRAM, and check it before moving BOs there. v2: Only perform calculations for separate counter if visible VRAM is smaller than total VRAM. (Michel Dänzer) v3: [Michel Dänzer] * Use BO's location rather than the AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED flag to determine whether to account a move for visible VRAM in most cases. * Use a single if (adev->mc.visible_vram_size < adev->mc.real_vram_size) { block in amdgpu_cs_get_threshold_for_moves. Fixes: 95844d20ae02 (drm/amdgpu: throttle buffer migrations at CS using a fixed MBps limit (v2)) Signed-off-by: John Brooks <john@fastquake.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index a85e75327456..e429829ae93d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -322,7 +322,7 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
322 struct amdgpu_bo *bo; 322 struct amdgpu_bo *bo;
323 enum ttm_bo_type type; 323 enum ttm_bo_type type;
324 unsigned long page_align; 324 unsigned long page_align;
325 u64 initial_bytes_moved; 325 u64 initial_bytes_moved, bytes_moved;
326 size_t acc_size; 326 size_t acc_size;
327 int r; 327 int r;
328 328
@@ -398,8 +398,14 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
398 r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type, 398 r = ttm_bo_init_reserved(&adev->mman.bdev, &bo->tbo, size, type,
399 &bo->placement, page_align, !kernel, NULL, 399 &bo->placement, page_align, !kernel, NULL,
400 acc_size, sg, resv, &amdgpu_ttm_bo_destroy); 400 acc_size, sg, resv, &amdgpu_ttm_bo_destroy);
401 amdgpu_cs_report_moved_bytes(adev, 401 bytes_moved = atomic64_read(&adev->num_bytes_moved) -
402 atomic64_read(&adev->num_bytes_moved) - initial_bytes_moved); 402 initial_bytes_moved;
403 if (adev->mc.visible_vram_size < adev->mc.real_vram_size &&
404 bo->tbo.mem.mem_type == TTM_PL_VRAM &&
405 bo->tbo.mem.start < adev->mc.visible_vram_size >> PAGE_SHIFT)
406 amdgpu_cs_report_moved_bytes(adev, bytes_moved, bytes_moved);
407 else
408 amdgpu_cs_report_moved_bytes(adev, bytes_moved, 0);
403 409
404 if (unlikely(r != 0)) 410 if (unlikely(r != 0))
405 return r; 411 return r;