Commit 41d9a6a7 authored by John Brooks's avatar John Brooks Committed by Alex Deucher
Browse files

drm/amdgpu: Don't force BOs into visible VRAM for page faults



There is no need for page faults to force BOs into visible VRAM if it's
full, and the time it takes to do so is great enough to cause noticeable
stuttering. Add GTT as a possible placement so that if visible VRAM is
full, page faults move BOs to GTT instead of evicting other BOs from VRAM.

Suggested-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Signed-off-by: default avatarJohn Brooks <john@fastquake.com>
Reviewed-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 96cf8271
Loading
Loading
Loading
Loading
+10 −7
Original line number Original line Diff line number Diff line
@@ -974,18 +974,21 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)


	/* hurrah the memory is not visible ! */
	/* hurrah the memory is not visible ! */
	atomic64_inc(&adev->num_vram_cpu_page_faults);
	atomic64_inc(&adev->num_vram_cpu_page_faults);
	amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
	amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM |
					 AMDGPU_GEM_DOMAIN_GTT);

	/* Avoid costly evictions; only set GTT as a busy placement */
	abo->placement.num_busy_placement = 1;
	abo->placement.busy_placement = &abo->placements[1];

	r = ttm_bo_validate(bo, &abo->placement, false, false);
	r = ttm_bo_validate(bo, &abo->placement, false, false);
	if (unlikely(r == -ENOMEM)) {
	if (unlikely(r != 0))
		amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);
		return ttm_bo_validate(bo, &abo->placement, false, false);
	} else if (unlikely(r != 0)) {
		return r;
		return r;
	}


	offset = bo->mem.start << PAGE_SHIFT;
	offset = bo->mem.start << PAGE_SHIFT;
	/* this should never happen */
	/* this should never happen */
	if ((offset + size) > adev->mc.visible_vram_size)
	if (bo->mem.mem_type == TTM_PL_VRAM &&
	    (offset + size) > adev->mc.visible_vram_size)
		return -EINVAL;
		return -EINVAL;


	return 0;
	return 0;