aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-12-11 09:16:32 -0500
committerAlex Deucher <alexander.deucher@amd.com>2015-12-18 17:29:45 -0500
commit56467ebfb254836dc30eb45d4ac8a46a400bfad6 (patch)
tree19629224afdc3328ede08e60ea46f0666c2d5ffe /drivers/gpu/drm/amd/amdgpu
parent3c0eea6c35d932c4d25070868067dc9cd9ceab91 (diff)
drm/amdgpu: split VM PD and PT handling during CS
This way we avoid the extra allocation for the page directory entry. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Chunming Zhou <david1.zhou@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu.h10
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c9
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c16
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c45
4 files changed, 51 insertions, 29 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index dc3dab539e4c..40850afa763f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -980,10 +980,11 @@ struct amdgpu_vm_manager {
980void amdgpu_vm_manager_fini(struct amdgpu_device *adev); 980void amdgpu_vm_manager_fini(struct amdgpu_device *adev);
981int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm); 981int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm);
982void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm); 982void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm);
983struct amdgpu_bo_list_entry *amdgpu_vm_get_bos(struct amdgpu_device *adev, 983void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
984 struct amdgpu_vm *vm, 984 struct list_head *validated,
985 struct list_head *validated, 985 struct amdgpu_bo_list_entry *entry);
986 struct list_head *duplicates); 986struct amdgpu_bo_list_entry *amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm,
987 struct list_head *duplicates);
987int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, 988int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
988 struct amdgpu_sync *sync); 989 struct amdgpu_sync *sync);
989void amdgpu_vm_flush(struct amdgpu_ring *ring, 990void amdgpu_vm_flush(struct amdgpu_ring *ring,
@@ -1253,6 +1254,7 @@ struct amdgpu_cs_parser {
1253 unsigned nchunks; 1254 unsigned nchunks;
1254 struct amdgpu_cs_chunk *chunks; 1255 struct amdgpu_cs_chunk *chunks;
1255 /* relocations */ 1256 /* relocations */
1257 struct amdgpu_bo_list_entry vm_pd;
1256 struct amdgpu_bo_list_entry *vm_bos; 1258 struct amdgpu_bo_list_entry *vm_bos;
1257 struct list_head validated; 1259 struct list_head validated;
1258 struct fence *fence; 1260 struct fence *fence;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index 9591c13781bd..3fb21ecd29e0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -387,8 +387,7 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p)
387 } 387 }
388 388
389 INIT_LIST_HEAD(&duplicates); 389 INIT_LIST_HEAD(&duplicates);
390 p->vm_bos = amdgpu_vm_get_bos(p->adev, &fpriv->vm, 390 amdgpu_vm_get_pd_bo(&fpriv->vm, &p->validated, &p->vm_pd);
391 &p->validated, &duplicates);
392 391
393 if (need_mmap_lock) 392 if (need_mmap_lock)
394 down_read(&current->mm->mmap_sem); 393 down_read(&current->mm->mmap_sem);
@@ -397,6 +396,12 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p)
397 if (unlikely(r != 0)) 396 if (unlikely(r != 0))
398 goto error_reserve; 397 goto error_reserve;
399 398
399 p->vm_bos = amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates);
400 if (!p->vm_bos) {
401 r = -ENOMEM;
402 goto error_validate;
403 }
404
400 r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &p->validated); 405 r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &p->validated);
401 if (r) 406 if (r)
402 goto error_validate; 407 goto error_validate;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 7fe7f8afa5ff..ea0fe94e4b54 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -448,6 +448,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
448{ 448{
449 struct ttm_validate_buffer tv, *entry; 449 struct ttm_validate_buffer tv, *entry;
450 struct amdgpu_bo_list_entry *vm_bos; 450 struct amdgpu_bo_list_entry *vm_bos;
451 struct amdgpu_bo_list_entry vm_pd;
451 struct ww_acquire_ctx ticket; 452 struct ww_acquire_ctx ticket;
452 struct list_head list, duplicates; 453 struct list_head list, duplicates;
453 unsigned domain; 454 unsigned domain;
@@ -460,14 +461,18 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
460 tv.shared = true; 461 tv.shared = true;
461 list_add(&tv.head, &list); 462 list_add(&tv.head, &list);
462 463
463 vm_bos = amdgpu_vm_get_bos(adev, bo_va->vm, &list, &duplicates); 464 amdgpu_vm_get_pd_bo(bo_va->vm, &list, &vm_pd);
464 if (!vm_bos)
465 return;
466 465
467 /* Provide duplicates to avoid -EALREADY */ 466 /* Provide duplicates to avoid -EALREADY */
468 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates); 467 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates);
469 if (r) 468 if (r)
470 goto error_free; 469 goto error_print;
470
471 vm_bos = amdgpu_vm_get_pt_bos(bo_va->vm, &duplicates);
472 if (!vm_bos) {
473 r = -ENOMEM;
474 goto error_unreserve;
475 }
471 476
472 list_for_each_entry(entry, &list, head) { 477 list_for_each_entry(entry, &list, head) {
473 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); 478 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type);
@@ -489,10 +494,9 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
489 494
490error_unreserve: 495error_unreserve:
491 ttm_eu_backoff_reservation(&ticket, &list); 496 ttm_eu_backoff_reservation(&ticket, &list);
492
493error_free:
494 drm_free_large(vm_bos); 497 drm_free_large(vm_bos);
495 498
499error_print:
496 if (r && r != -ERESTARTSYS) 500 if (r && r != -ERESTARTSYS)
497 DRM_ERROR("Couldn't update BO_VA (%d)\n", r); 501 DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
498} 502}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index f6c1d6f0bf37..592be6438a6c 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -75,39 +75,50 @@ static unsigned amdgpu_vm_directory_size(struct amdgpu_device *adev)
75} 75}
76 76
77/** 77/**
78 * amdgpu_vm_get_bos - add the vm BOs to a validation list 78 * amdgpu_vm_get_pd_bo - add the VM PD to a validation list
79 * 79 *
80 * @vm: vm providing the BOs 80 * @vm: vm providing the BOs
81 * @validated: head of validation list 81 * @validated: head of validation list
82 * @entry: entry to add
83 *
84 * Add the page directory to the list of BOs to
85 * validate for command submission.
86 */
87void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
88 struct list_head *validated,
89 struct amdgpu_bo_list_entry *entry)
90{
91 entry->robj = vm->page_directory;
92 entry->prefered_domains = AMDGPU_GEM_DOMAIN_VRAM;
93 entry->allowed_domains = AMDGPU_GEM_DOMAIN_VRAM;
94 entry->priority = 0;
95 entry->tv.bo = &vm->page_directory->tbo;
96 entry->tv.shared = true;
97 list_add(&entry->tv.head, validated);
98}
99
100/**
101 * amdgpu_vm_get_bos - add the vm BOs to a validation list
102 *
103 * @vm: vm providing the BOs
82 * @duplicates: head of duplicates list 104 * @duplicates: head of duplicates list
83 * 105 *
84 * Add the page directory to the list of BOs to 106 * Add the page directory to the list of BOs to
85 * validate for command submission (cayman+). 107 * validate for command submission (cayman+).
86 */ 108 */
87struct amdgpu_bo_list_entry *amdgpu_vm_get_bos(struct amdgpu_device *adev, 109struct amdgpu_bo_list_entry *amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm,
88 struct amdgpu_vm *vm, 110 struct list_head *duplicates)
89 struct list_head *validated,
90 struct list_head *duplicates)
91{ 111{
92 struct amdgpu_bo_list_entry *list; 112 struct amdgpu_bo_list_entry *list;
93 unsigned i, idx; 113 unsigned i, idx;
94 114
95 list = drm_malloc_ab(vm->max_pde_used + 2, 115 list = drm_malloc_ab(vm->max_pde_used + 1,
96 sizeof(struct amdgpu_bo_list_entry)); 116 sizeof(struct amdgpu_bo_list_entry));
97 if (!list) { 117 if (!list)
98 return NULL; 118 return NULL;
99 }
100 119
101 /* add the vm page table to the list */ 120 /* add the vm page table to the list */
102 list[0].robj = vm->page_directory; 121 for (i = 0, idx = 0; i <= vm->max_pde_used; i++) {
103 list[0].prefered_domains = AMDGPU_GEM_DOMAIN_VRAM;
104 list[0].allowed_domains = AMDGPU_GEM_DOMAIN_VRAM;
105 list[0].priority = 0;
106 list[0].tv.bo = &vm->page_directory->tbo;
107 list[0].tv.shared = true;
108 list_add(&list[0].tv.head, validated);
109
110 for (i = 0, idx = 1; i <= vm->max_pde_used; i++) {
111 if (!vm->page_tables[i].bo) 122 if (!vm->page_tables[i].bo)
112 continue; 123 continue;
113 124