aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
diff options
context:
space:
mode:
authorJohn Brooks <john@fastquake.com>2017-06-30 11:31:08 -0400
committerAlex Deucher <alexander.deucher@amd.com>2017-07-14 11:06:33 -0400
commit96cf8271df546d0f4cfc9ddddbc42dce633e0190 (patch)
tree981e86f5e52091f11a03930cea2f7f5bd40ed35e /drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
parent00f06b246a3056bbaa901a90a5a93c9f81ab8e36 (diff)
drm/amdgpu: Set/clear CPU_ACCESS flag on page fault and move to VRAM
When a BO is moved to VRAM, clear AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED. This allows it to potentially later move to invisible VRAM if the CPU does not access it again. Setting the CPU_ACCESS flag in amdgpu_bo_fault_reserve_notify() also means that we can remove the loop to restrict lpfn to the end of visible VRAM, because amdgpu_ttm_placement_init() will do it for us. v3 [Michel Dänzer] * Use AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED instead of a new flag (Christian König) * Clear flag in amdgpu_bo_move instead of amdgpu_move_ram_vram (Christian) * Explicitly mention amdgpu_bo_fault_reserve_notify in amdgpu_bo_move * Also clear flag in amdgpu_bo_create_restricted Suggested-by: Michel Dänzer <michel.daenzer@amd.com> 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.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index e429829ae93d..93601fbea695 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -432,6 +432,10 @@ int amdgpu_bo_create_restricted(struct amdgpu_device *adev,
432 432
433 trace_amdgpu_bo_create(bo); 433 trace_amdgpu_bo_create(bo);
434 434
435 /* Treat CPU_ACCESS_REQUIRED only as a hint if given by UMD */
436 if (type == ttm_bo_type_device)
437 bo->flags &= ~AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
438
435 return 0; 439 return 0;
436 440
437fail_unreserve: 441fail_unreserve:
@@ -945,13 +949,17 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
945{ 949{
946 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev); 950 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
947 struct amdgpu_bo *abo; 951 struct amdgpu_bo *abo;
948 unsigned long offset, size, lpfn; 952 unsigned long offset, size;
949 int i, r; 953 int r;
950 954
951 if (!amdgpu_ttm_bo_is_amdgpu_bo(bo)) 955 if (!amdgpu_ttm_bo_is_amdgpu_bo(bo))
952 return 0; 956 return 0;
953 957
954 abo = container_of(bo, struct amdgpu_bo, tbo); 958 abo = container_of(bo, struct amdgpu_bo, tbo);
959
960 /* Remember that this BO was accessed by the CPU */
961 abo->flags |= AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED;
962
955 if (bo->mem.mem_type != TTM_PL_VRAM) 963 if (bo->mem.mem_type != TTM_PL_VRAM)
956 return 0; 964 return 0;
957 965
@@ -967,14 +975,6 @@ int amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
967 /* hurrah the memory is not visible ! */ 975 /* hurrah the memory is not visible ! */
968 atomic64_inc(&adev->num_vram_cpu_page_faults); 976 atomic64_inc(&adev->num_vram_cpu_page_faults);
969 amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM); 977 amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_VRAM);
970 lpfn = adev->mc.visible_vram_size >> PAGE_SHIFT;
971 for (i = 0; i < abo->placement.num_placement; i++) {
972 /* Force into visible VRAM */
973 if ((abo->placements[i].flags & TTM_PL_FLAG_VRAM) &&
974 (!abo->placements[i].lpfn ||
975 abo->placements[i].lpfn > lpfn))
976 abo->placements[i].lpfn = lpfn;
977 }
978 r = ttm_bo_validate(bo, &abo->placement, false, false); 978 r = ttm_bo_validate(bo, &abo->placement, false, false);
979 if (unlikely(r == -ENOMEM)) { 979 if (unlikely(r == -ENOMEM)) {
980 amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT); 980 amdgpu_ttm_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_GTT);