diff options
author | Christian König <christian.koenig@amd.com> | 2016-06-21 10:28:15 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-07-07 14:54:49 -0400 |
commit | 5a712a8727200fc617072bed2ccd8ba8e1b50408 (patch) | |
tree | 53d58dfb5e2bcf2b2d1232ecb192f0f8d70851d6 | |
parent | dbd5ed60ac856632609491229e6d7ad70115fb09 (diff) |
drm/amdgpu: validate VM PTs only on eviction
We don't need to validate them again if the eviction counter didn't changed.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 13 |
4 files changed, 20 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index f4d269931dbe..80d9932d86fb 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -864,6 +864,7 @@ struct amdgpu_vm { | |||
864 | struct amdgpu_bo *page_directory; | 864 | struct amdgpu_bo *page_directory; |
865 | unsigned max_pde_used; | 865 | unsigned max_pde_used; |
866 | struct fence *page_directory_fence; | 866 | struct fence *page_directory_fence; |
867 | uint64_t last_eviction_counter; | ||
867 | 868 | ||
868 | /* array of page tables, one for each page directory entry */ | 869 | /* array of page tables, one for each page directory entry */ |
869 | struct amdgpu_vm_pt *page_tables; | 870 | struct amdgpu_vm_pt *page_tables; |
@@ -932,7 +933,8 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm); | |||
932 | void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, | 933 | void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, |
933 | struct list_head *validated, | 934 | struct list_head *validated, |
934 | struct amdgpu_bo_list_entry *entry); | 935 | struct amdgpu_bo_list_entry *entry); |
935 | void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates); | 936 | void amdgpu_vm_get_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, |
937 | struct list_head *duplicates); | ||
936 | void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev, | 938 | void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev, |
937 | struct amdgpu_vm *vm); | 939 | struct amdgpu_vm *vm); |
938 | int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, | 940 | int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c index de171ccf2b9c..cf97a87f76a6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -459,7 +459,7 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
459 | list_splice(&need_pages, &p->validated); | 459 | list_splice(&need_pages, &p->validated); |
460 | } | 460 | } |
461 | 461 | ||
462 | amdgpu_vm_get_pt_bos(&fpriv->vm, &duplicates); | 462 | amdgpu_vm_get_pt_bos(p->adev, &fpriv->vm, &duplicates); |
463 | 463 | ||
464 | p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); | 464 | p->bytes_moved_threshold = amdgpu_cs_get_threshold_for_moves(p->adev); |
465 | p->bytes_moved = 0; | 465 | p->bytes_moved = 0; |
@@ -472,6 +472,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p, | |||
472 | if (r) | 472 | if (r) |
473 | goto error_validate; | 473 | goto error_validate; |
474 | 474 | ||
475 | fpriv->vm.last_eviction_counter = | ||
476 | atomic64_read(&p->adev->num_evictions); | ||
477 | |||
475 | if (p->bo_list) { | 478 | if (p->bo_list) { |
476 | struct amdgpu_bo *gds = p->bo_list->gds_obj; | 479 | struct amdgpu_bo *gds = p->bo_list->gds_obj; |
477 | struct amdgpu_bo *gws = p->bo_list->gws_obj; | 480 | struct amdgpu_bo *gws = p->bo_list->gws_obj; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 8fab6486064f..88fbed2389c0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -503,7 +503,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, | |||
503 | if (r) | 503 | if (r) |
504 | goto error_print; | 504 | goto error_print; |
505 | 505 | ||
506 | amdgpu_vm_get_pt_bos(bo_va->vm, &duplicates); | 506 | amdgpu_vm_get_pt_bos(adev, bo_va->vm, &duplicates); |
507 | list_for_each_entry(entry, &list, head) { | 507 | list_for_each_entry(entry, &list, head) { |
508 | domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); | 508 | domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); |
509 | /* if anything is swapped out don't swap it in here, | 509 | /* if anything is swapped out don't swap it in here, |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 8f04857fbe1b..ea10b7af33df 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -115,16 +115,26 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, | |||
115 | /** | 115 | /** |
116 | * amdgpu_vm_get_bos - add the vm BOs to a duplicates list | 116 | * amdgpu_vm_get_bos - add the vm BOs to a duplicates list |
117 | * | 117 | * |
118 | * @adev: amdgpu device pointer | ||
118 | * @vm: vm providing the BOs | 119 | * @vm: vm providing the BOs |
119 | * @duplicates: head of duplicates list | 120 | * @duplicates: head of duplicates list |
120 | * | 121 | * |
121 | * Add the page directory to the BO duplicates list | 122 | * Add the page directory to the BO duplicates list |
122 | * for command submission. | 123 | * for command submission. |
123 | */ | 124 | */ |
124 | void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates) | 125 | void amdgpu_vm_get_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm, |
126 | struct list_head *duplicates) | ||
125 | { | 127 | { |
128 | uint64_t num_evictions; | ||
126 | unsigned i; | 129 | unsigned i; |
127 | 130 | ||
131 | /* We only need to validate the page tables | ||
132 | * if they aren't already valid. | ||
133 | */ | ||
134 | num_evictions = atomic64_read(&adev->num_evictions); | ||
135 | if (num_evictions == vm->last_eviction_counter) | ||
136 | return; | ||
137 | |||
128 | /* add the vm page table to the list */ | 138 | /* add the vm page table to the list */ |
129 | for (i = 0; i <= vm->max_pde_used; ++i) { | 139 | for (i = 0; i <= vm->max_pde_used; ++i) { |
130 | struct amdgpu_bo_list_entry *entry = &vm->page_tables[i].entry; | 140 | struct amdgpu_bo_list_entry *entry = &vm->page_tables[i].entry; |
@@ -1534,6 +1544,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) | |||
1534 | amdgpu_bo_unreserve(vm->page_directory); | 1544 | amdgpu_bo_unreserve(vm->page_directory); |
1535 | if (r) | 1545 | if (r) |
1536 | goto error_free_page_directory; | 1546 | goto error_free_page_directory; |
1547 | vm->last_eviction_counter = atomic64_read(&adev->num_evictions); | ||
1537 | 1548 | ||
1538 | return 0; | 1549 | return 0; |
1539 | 1550 | ||