aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-09-04 04:47:56 -0400
committerAlex Deucher <alexander.deucher@amd.com>2015-09-23 17:23:35 -0400
commitbf60efd353f68e5dec1a177b5cbe4da07c819569 (patch)
tree03911fc3289220f4003b9778a62a4793e26f076f /drivers/gpu/drm
parenta5b750583eb4af69da1e659c7684b6d370b2ae97 (diff)
drm/amdgpu: use only one reservation object for each VM v2
Reduces the locking and fencing overhead. v2: add comment why we need the duplicates list in the GEM op. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c6
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c33
2 files changed, 9 insertions, 30 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index b75c3b235832..2f39fea10bd1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -455,11 +455,12 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
455 struct ttm_validate_buffer tv, *entry; 455 struct ttm_validate_buffer tv, *entry;
456 struct amdgpu_bo_list_entry *vm_bos; 456 struct amdgpu_bo_list_entry *vm_bos;
457 struct ww_acquire_ctx ticket; 457 struct ww_acquire_ctx ticket;
458 struct list_head list; 458 struct list_head list, duplicates;
459 unsigned domain; 459 unsigned domain;
460 int r; 460 int r;
461 461
462 INIT_LIST_HEAD(&list); 462 INIT_LIST_HEAD(&list);
463 INIT_LIST_HEAD(&duplicates);
463 464
464 tv.bo = &bo_va->bo->tbo; 465 tv.bo = &bo_va->bo->tbo;
465 tv.shared = true; 466 tv.shared = true;
@@ -469,7 +470,8 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
469 if (!vm_bos) 470 if (!vm_bos)
470 return; 471 return;
471 472
472 r = ttm_eu_reserve_buffers(&ticket, &list, true, NULL); 473 /* Provide duplicates to avoid -EALREADY */
474 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates);
473 if (r) 475 if (r)
474 goto error_free; 476 goto error_free;
475 477
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index 8927dc6dec7c..d30fbecac26e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -686,31 +686,6 @@ static int amdgpu_vm_update_ptes(struct amdgpu_device *adev,
686} 686}
687 687
688/** 688/**
689 * amdgpu_vm_fence_pts - fence page tables after an update
690 *
691 * @vm: requested vm
692 * @start: start of GPU address range
693 * @end: end of GPU address range
694 * @fence: fence to use
695 *
696 * Fence the page tables in the range @start - @end (cayman+).
697 *
698 * Global and local mutex must be locked!
699 */
700static void amdgpu_vm_fence_pts(struct amdgpu_vm *vm,
701 uint64_t start, uint64_t end,
702 struct fence *fence)
703{
704 unsigned i;
705
706 start >>= amdgpu_vm_block_size;
707 end >>= amdgpu_vm_block_size;
708
709 for (i = start; i <= end; ++i)
710 amdgpu_bo_fence(vm->page_tables[i].bo, fence, true);
711}
712
713/**
714 * amdgpu_vm_bo_update_mapping - update a mapping in the vm page table 689 * amdgpu_vm_bo_update_mapping - update a mapping in the vm page table
715 * 690 *
716 * @adev: amdgpu_device pointer 691 * @adev: amdgpu_device pointer
@@ -813,8 +788,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
813 if (r) 788 if (r)
814 goto error_free; 789 goto error_free;
815 790
816 amdgpu_vm_fence_pts(vm, mapping->it.start, 791 amdgpu_bo_fence(vm->page_directory, f, true);
817 mapping->it.last + 1, f);
818 if (fence) { 792 if (fence) {
819 fence_put(*fence); 793 fence_put(*fence);
820 *fence = fence_get(f); 794 *fence = fence_get(f);
@@ -1089,6 +1063,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
1089 1063
1090 /* walk over the address space and allocate the page tables */ 1064 /* walk over the address space and allocate the page tables */
1091 for (pt_idx = saddr; pt_idx <= eaddr; ++pt_idx) { 1065 for (pt_idx = saddr; pt_idx <= eaddr; ++pt_idx) {
1066 struct reservation_object *resv = vm->page_directory->tbo.resv;
1092 struct amdgpu_bo *pt; 1067 struct amdgpu_bo *pt;
1093 1068
1094 if (vm->page_tables[pt_idx].bo) 1069 if (vm->page_tables[pt_idx].bo)
@@ -1097,11 +1072,13 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
1097 /* drop mutex to allocate and clear page table */ 1072 /* drop mutex to allocate and clear page table */
1098 mutex_unlock(&vm->mutex); 1073 mutex_unlock(&vm->mutex);
1099 1074
1075 ww_mutex_lock(&resv->lock, NULL);
1100 r = amdgpu_bo_create(adev, AMDGPU_VM_PTE_COUNT * 8, 1076 r = amdgpu_bo_create(adev, AMDGPU_VM_PTE_COUNT * 8,
1101 AMDGPU_GPU_PAGE_SIZE, true, 1077 AMDGPU_GPU_PAGE_SIZE, true,
1102 AMDGPU_GEM_DOMAIN_VRAM, 1078 AMDGPU_GEM_DOMAIN_VRAM,
1103 AMDGPU_GEM_CREATE_NO_CPU_ACCESS, 1079 AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
1104 NULL, NULL, &pt); 1080 NULL, resv, &pt);
1081 ww_mutex_unlock(&resv->lock);
1105 if (r) 1082 if (r)
1106 goto error_free; 1083 goto error_free;
1107 1084