aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-05-12 14:48:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-12 14:48:26 -0400
commita34ab101a9d27a2995142b47f9857fb46fcb072a (patch)
treea9d5237a5706d5993c78d4f53232ddff86cdf9d1 /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
parentbd1286f964041a2fe5eec8801a51bd79d905bd02 (diff)
parent7b8cd3363e8a0e6b90a7067f75aaeaae61a7d612 (diff)
Merge tag 'drm-fixes-for-v4.12-rc1' of git://people.freedesktop.org/~airlied/linux
Pull drm fixes from Dave Airlie: "AMD, nouveau, one i915, and one EDID fix for v4.12-rc1 Some fixes that it would be good to have in rc1. It contains the i915 quiet fix that you reported. It also has an amdgpu fixes pull, with lots of ongoing work on Vega10 which is new in this kernel and is preliminary support so may have a fair bit of movement. Otherwise a few non-Vega10 AMD fixes, one EDID fix and some nouveau regression fixers" * tag 'drm-fixes-for-v4.12-rc1' of git://people.freedesktop.org/~airlied/linux: (144 commits) drm/i915: Make vblank evade warnings optional drm/nouveau/therm: remove ineffective workarounds for alarm bugs drm/nouveau/tmr: avoid processing completed alarms when adding a new one drm/nouveau/tmr: fix corruption of the pending list when rescheduling an alarm drm/nouveau/tmr: handle races with hw when updating the next alarm time drm/nouveau/tmr: ack interrupt before processing alarms drm/nouveau/core: fix static checker warning drm/nouveau/fb/ram/gf100-: remove 0x10f200 read drm/nouveau/kms/nv50: skip core channel cursor update on position-only changes drm/nouveau/kms/nv50: fix source-rect-only plane updates drm/nouveau/kms/nv50: remove pointless argument to window atomic_check_acquire() drm/amd/powerplay: refine pwm1_enable callback functions for CI. drm/amd/powerplay: refine pwm1_enable callback functions for vi. drm/amd/powerplay: refine pwm1_enable callback functions for Vega10. drm/amdgpu: refine amdgpu pwm1_enable sysfs interface. drm/amdgpu: add amd fan ctrl mode enums. drm/amd/powerplay: add more smu message on Vega10. drm/amdgpu: fix dependency issue drm/amd: fix init order of sched job drm/amdgpu: add some additional vega10 pci ids ...
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c68
1 files changed, 37 insertions, 31 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 03a9c5cad222..94cb91cf93eb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -139,6 +139,35 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj,
139 return 0; 139 return 0;
140} 140}
141 141
142static int amdgpu_gem_vm_check(void *param, struct amdgpu_bo *bo)
143{
144 /* if anything is swapped out don't swap it in here,
145 just abort and wait for the next CS */
146 if (!amdgpu_bo_gpu_accessible(bo))
147 return -ERESTARTSYS;
148
149 if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow))
150 return -ERESTARTSYS;
151
152 return 0;
153}
154
155static bool amdgpu_gem_vm_ready(struct amdgpu_device *adev,
156 struct amdgpu_vm *vm,
157 struct list_head *list)
158{
159 struct ttm_validate_buffer *entry;
160
161 list_for_each_entry(entry, list, head) {
162 struct amdgpu_bo *bo =
163 container_of(entry->bo, struct amdgpu_bo, tbo);
164 if (amdgpu_gem_vm_check(NULL, bo))
165 return false;
166 }
167
168 return !amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_gem_vm_check, NULL);
169}
170
142void amdgpu_gem_object_close(struct drm_gem_object *obj, 171void amdgpu_gem_object_close(struct drm_gem_object *obj,
143 struct drm_file *file_priv) 172 struct drm_file *file_priv)
144{ 173{
@@ -148,15 +177,13 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
148 struct amdgpu_vm *vm = &fpriv->vm; 177 struct amdgpu_vm *vm = &fpriv->vm;
149 178
150 struct amdgpu_bo_list_entry vm_pd; 179 struct amdgpu_bo_list_entry vm_pd;
151 struct list_head list, duplicates; 180 struct list_head list;
152 struct ttm_validate_buffer tv; 181 struct ttm_validate_buffer tv;
153 struct ww_acquire_ctx ticket; 182 struct ww_acquire_ctx ticket;
154 struct amdgpu_bo_va *bo_va; 183 struct amdgpu_bo_va *bo_va;
155 struct dma_fence *fence = NULL;
156 int r; 184 int r;
157 185
158 INIT_LIST_HEAD(&list); 186 INIT_LIST_HEAD(&list);
159 INIT_LIST_HEAD(&duplicates);
160 187
161 tv.bo = &bo->tbo; 188 tv.bo = &bo->tbo;
162 tv.shared = true; 189 tv.shared = true;
@@ -164,16 +191,18 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
164 191
165 amdgpu_vm_get_pd_bo(vm, &list, &vm_pd); 192 amdgpu_vm_get_pd_bo(vm, &list, &vm_pd);
166 193
167 r = ttm_eu_reserve_buffers(&ticket, &list, false, &duplicates); 194 r = ttm_eu_reserve_buffers(&ticket, &list, false, NULL);
168 if (r) { 195 if (r) {
169 dev_err(adev->dev, "leaking bo va because " 196 dev_err(adev->dev, "leaking bo va because "
170 "we fail to reserve bo (%d)\n", r); 197 "we fail to reserve bo (%d)\n", r);
171 return; 198 return;
172 } 199 }
173 bo_va = amdgpu_vm_bo_find(vm, bo); 200 bo_va = amdgpu_vm_bo_find(vm, bo);
174 if (bo_va) { 201 if (bo_va && --bo_va->ref_count == 0) {
175 if (--bo_va->ref_count == 0) { 202 amdgpu_vm_bo_rmv(adev, bo_va);
176 amdgpu_vm_bo_rmv(adev, bo_va); 203
204 if (amdgpu_gem_vm_ready(adev, vm, &list)) {
205 struct dma_fence *fence = NULL;
177 206
178 r = amdgpu_vm_clear_freed(adev, vm, &fence); 207 r = amdgpu_vm_clear_freed(adev, vm, &fence);
179 if (unlikely(r)) { 208 if (unlikely(r)) {
@@ -502,19 +531,6 @@ out:
502 return r; 531 return r;
503} 532}
504 533
505static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)
506{
507 /* if anything is swapped out don't swap it in here,
508 just abort and wait for the next CS */
509 if (!amdgpu_bo_gpu_accessible(bo))
510 return -ERESTARTSYS;
511
512 if (bo->shadow && !amdgpu_bo_gpu_accessible(bo->shadow))
513 return -ERESTARTSYS;
514
515 return 0;
516}
517
518/** 534/**
519 * amdgpu_gem_va_update_vm -update the bo_va in its VM 535 * amdgpu_gem_va_update_vm -update the bo_va in its VM
520 * 536 *
@@ -533,19 +549,9 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
533 struct list_head *list, 549 struct list_head *list,
534 uint32_t operation) 550 uint32_t operation)
535{ 551{
536 struct ttm_validate_buffer *entry;
537 int r = -ERESTARTSYS; 552 int r = -ERESTARTSYS;
538 553
539 list_for_each_entry(entry, list, head) { 554 if (!amdgpu_gem_vm_ready(adev, vm, list))
540 struct amdgpu_bo *bo =
541 container_of(entry->bo, struct amdgpu_bo, tbo);
542 if (amdgpu_gem_va_check(NULL, bo))
543 goto error;
544 }
545
546 r = amdgpu_vm_validate_pt_bos(adev, vm, amdgpu_gem_va_check,
547 NULL);
548 if (r)
549 goto error; 555 goto error;
550 556
551 r = amdgpu_vm_update_directories(adev, vm); 557 r = amdgpu_vm_update_directories(adev, vm);