diff options
author | Christian König <christian.koenig@amd.com> | 2016-01-11 09:35:21 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-01-13 12:22:17 -0500 |
commit | eceb8a1562db6fc3e1c21cd54a4be0189aa1d0e3 (patch) | |
tree | 0e0e73dfc9bf8c20c6c81d5b765d92d94e57c76b /drivers/gpu/drm/amd/amdgpu | |
parent | ab74961810ba7935b5f9643da10daaa36690f48e (diff) |
drm/amdgpu: move VM page tables to the LRU end on CS v2
This makes it less likely to run into an ENOMEM because
VM page tables are evicted last.
v2: move the BOs in the LRU tail after validation
Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 7 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 27 |
3 files changed, 35 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 003959f99251..313b0cc8d676 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -987,6 +987,8 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, | |||
987 | struct list_head *validated, | 987 | struct list_head *validated, |
988 | struct amdgpu_bo_list_entry *entry); | 988 | struct amdgpu_bo_list_entry *entry); |
989 | void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates); | 989 | void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates); |
990 | void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev, | ||
991 | struct amdgpu_vm *vm); | ||
990 | int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, | 992 | int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, |
991 | struct amdgpu_sync *sync); | 993 | struct amdgpu_sync *sync); |
992 | void amdgpu_vm_flush(struct amdgpu_ring *ring, | 994 | void amdgpu_vm_flush(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 ce0254d4dcd7..1fffc338f69d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | |||
@@ -428,8 +428,10 @@ static int amdgpu_cs_parser_relocs(struct amdgpu_cs_parser *p) | |||
428 | r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &duplicates); | 428 | r = amdgpu_cs_list_validate(p->adev, &fpriv->vm, &duplicates); |
429 | 429 | ||
430 | error_validate: | 430 | error_validate: |
431 | if (r) | 431 | if (r) { |
432 | amdgpu_vm_move_pt_bos_in_lru(p->adev, &fpriv->vm); | ||
432 | ttm_eu_backoff_reservation(&p->ticket, &p->validated); | 433 | ttm_eu_backoff_reservation(&p->ticket, &p->validated); |
434 | } | ||
433 | 435 | ||
434 | error_reserve: | 436 | error_reserve: |
435 | if (need_mmap_lock) | 437 | if (need_mmap_lock) |
@@ -473,8 +475,11 @@ static int cmp_size_smaller_first(void *priv, struct list_head *a, | |||
473 | **/ | 475 | **/ |
474 | static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bool backoff) | 476 | static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bool backoff) |
475 | { | 477 | { |
478 | struct amdgpu_fpriv *fpriv = parser->filp->driver_priv; | ||
476 | unsigned i; | 479 | unsigned i; |
477 | 480 | ||
481 | amdgpu_vm_move_pt_bos_in_lru(parser->adev, &fpriv->vm); | ||
482 | |||
478 | if (!error) { | 483 | if (!error) { |
479 | /* Sort the buffer list from the smallest to largest buffer, | 484 | /* Sort the buffer list from the smallest to largest buffer, |
480 | * which affects the order of buffers in the LRU list. | 485 | * which affects the order of buffers in the LRU list. |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 8f7688e598a1..aefc668e6b5d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -119,6 +119,33 @@ void amdgpu_vm_get_pt_bos(struct amdgpu_vm *vm, struct list_head *duplicates) | |||
119 | 119 | ||
120 | list_add(&entry->tv.head, duplicates); | 120 | list_add(&entry->tv.head, duplicates); |
121 | } | 121 | } |
122 | |||
123 | } | ||
124 | |||
125 | /** | ||
126 | * amdgpu_vm_move_pt_bos_in_lru - move the PT BOs to the LRU tail | ||
127 | * | ||
128 | * @adev: amdgpu device instance | ||
129 | * @vm: vm providing the BOs | ||
130 | * | ||
131 | * Move the PT BOs to the tail of the LRU. | ||
132 | */ | ||
133 | void amdgpu_vm_move_pt_bos_in_lru(struct amdgpu_device *adev, | ||
134 | struct amdgpu_vm *vm) | ||
135 | { | ||
136 | struct ttm_bo_global *glob = adev->mman.bdev.glob; | ||
137 | unsigned i; | ||
138 | |||
139 | spin_lock(&glob->lru_lock); | ||
140 | for (i = 0; i <= vm->max_pde_used; ++i) { | ||
141 | struct amdgpu_bo_list_entry *entry = &vm->page_tables[i].entry; | ||
142 | |||
143 | if (!entry->robj) | ||
144 | continue; | ||
145 | |||
146 | ttm_bo_move_to_lru_tail(&entry->robj->tbo); | ||
147 | } | ||
148 | spin_unlock(&glob->lru_lock); | ||
122 | } | 149 | } |
123 | 150 | ||
124 | /** | 151 | /** |