Commit 5fb1941d authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/amdgpu: port fault_reserve_notify changes from radeon

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 564ea790
...@@ -549,30 +549,45 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo, ...@@ -549,30 +549,45 @@ void amdgpu_bo_move_notify(struct ttm_buffer_object *bo,
int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo) int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
{ {
struct amdgpu_device *adev; struct amdgpu_device *adev;
struct amdgpu_bo *rbo; struct amdgpu_bo *abo;
unsigned long offset, size; unsigned long offset, size, lpfn;
int r; int i, r;
if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
return 0; return 0;
rbo = container_of(bo, struct amdgpu_bo, tbo);
adev = rbo->adev; abo = container_of(bo, struct amdgpu_bo, tbo);
if (bo->mem.mem_type == TTM_PL_VRAM) { adev = abo->adev;
size = bo->mem.num_pages << PAGE_SHIFT; if (bo->mem.mem_type != TTM_PL_VRAM)
offset = bo->mem.start << PAGE_SHIFT; return 0;
if ((offset + size) > adev->mc.visible_vram_size) {
/* hurrah the memory is not visible ! */ size = bo->mem.num_pages << PAGE_SHIFT;
amdgpu_ttm_placement_from_domain(rbo, AMDGPU_GEM_DOMAIN_VRAM); offset = bo->mem.start << PAGE_SHIFT;
rbo->placements[0].lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT; if ((offset + size) <= adev->mc.visible_vram_size)
r = ttm_bo_validate(bo, &rbo->placement, false, false); return 0;
if (unlikely(r != 0))
return r; /* hurrah the memory is not visible ! */
offset = bo->mem.start << PAGE_SHIFT; amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
/* this should not happen */ lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
if ((offset + size) > adev->mc.visible_vram_size) for (i = 0; i < abo->placement.num_placement; i++) {
return -EINVAL; /* Force into visible VRAM */
} if ((abo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
(!abo->placements[i].lpfn || abo->placements[i].lpfn > lpfn))
abo->placements[i].lpfn = lpfn;
}
r = ttm_bo_validate(bo, &abo->placement, false, false);
if (unlikely(r == -ENOMEM)) {
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;
} }
offset = bo->mem.start << PAGE_SHIFT;
/* this should never happen */
if ((offset + size) > adev->mc.visible_vram_size)
return -EINVAL;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment