aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index 3ad0bf6ce3e4..cd62f6ffde2a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -116,10 +116,11 @@ void amdgpu_gem_force_release(struct amdgpu_device *adev)
116 * Call from drm_gem_handle_create which appear in both new and open ioctl 116 * Call from drm_gem_handle_create which appear in both new and open ioctl
117 * case. 117 * case.
118 */ 118 */
119int amdgpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_priv) 119int amdgpu_gem_object_open(struct drm_gem_object *obj,
120 struct drm_file *file_priv)
120{ 121{
121 struct amdgpu_bo *abo = gem_to_amdgpu_bo(obj); 122 struct amdgpu_bo *abo = gem_to_amdgpu_bo(obj);
122 struct amdgpu_device *adev = abo->adev; 123 struct amdgpu_device *adev = amdgpu_ttm_adev(abo->tbo.bdev);
123 struct amdgpu_fpriv *fpriv = file_priv->driver_priv; 124 struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
124 struct amdgpu_vm *vm = &fpriv->vm; 125 struct amdgpu_vm *vm = &fpriv->vm;
125 struct amdgpu_bo_va *bo_va; 126 struct amdgpu_bo_va *bo_va;
@@ -142,7 +143,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
142 struct drm_file *file_priv) 143 struct drm_file *file_priv)
143{ 144{
144 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); 145 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
145 struct amdgpu_device *adev = bo->adev; 146 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
146 struct amdgpu_fpriv *fpriv = file_priv->driver_priv; 147 struct amdgpu_fpriv *fpriv = file_priv->driver_priv;
147 struct amdgpu_vm *vm = &fpriv->vm; 148 struct amdgpu_vm *vm = &fpriv->vm;
148 149
@@ -468,6 +469,16 @@ out:
468 return r; 469 return r;
469} 470}
470 471
472static int amdgpu_gem_va_check(void *param, struct amdgpu_bo *bo)
473{
474 unsigned domain = amdgpu_mem_type_to_domain(bo->tbo.mem.mem_type);
475
476 /* if anything is swapped out don't swap it in here,
477 just abort and wait for the next CS */
478
479 return domain == AMDGPU_GEM_DOMAIN_CPU ? -ERESTARTSYS : 0;
480}
481
471/** 482/**
472 * amdgpu_gem_va_update_vm -update the bo_va in its VM 483 * amdgpu_gem_va_update_vm -update the bo_va in its VM
473 * 484 *
@@ -478,7 +489,8 @@ out:
478 * vital here, so they are not reported back to userspace. 489 * vital here, so they are not reported back to userspace.
479 */ 490 */
480static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, 491static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
481 struct amdgpu_bo_va *bo_va, uint32_t operation) 492 struct amdgpu_bo_va *bo_va,
493 uint32_t operation)
482{ 494{
483 struct ttm_validate_buffer tv, *entry; 495 struct ttm_validate_buffer tv, *entry;
484 struct amdgpu_bo_list_entry vm_pd; 496 struct amdgpu_bo_list_entry vm_pd;
@@ -501,7 +513,6 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
501 if (r) 513 if (r)
502 goto error_print; 514 goto error_print;
503 515
504 amdgpu_vm_get_pt_bos(adev, bo_va->vm, &duplicates);
505 list_for_each_entry(entry, &list, head) { 516 list_for_each_entry(entry, &list, head) {
506 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); 517 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type);
507 /* if anything is swapped out don't swap it in here, 518 /* if anything is swapped out don't swap it in here,
@@ -509,13 +520,10 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,
509 if (domain == AMDGPU_GEM_DOMAIN_CPU) 520 if (domain == AMDGPU_GEM_DOMAIN_CPU)
510 goto error_unreserve; 521 goto error_unreserve;
511 } 522 }
512 list_for_each_entry(entry, &duplicates, head) { 523 r = amdgpu_vm_validate_pt_bos(adev, bo_va->vm, amdgpu_gem_va_check,
513 domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type); 524 NULL);
514 /* if anything is swapped out don't swap it in here, 525 if (r)
515 just abort and wait for the next CS */ 526 goto error_unreserve;
516 if (domain == AMDGPU_GEM_DOMAIN_CPU)
517 goto error_unreserve;
518 }
519 527
520 r = amdgpu_vm_update_page_directory(adev, bo_va->vm); 528 r = amdgpu_vm_update_page_directory(adev, bo_va->vm);
521 if (r) 529 if (r)
@@ -536,8 +544,6 @@ error_print:
536 DRM_ERROR("Couldn't update BO_VA (%d)\n", r); 544 DRM_ERROR("Couldn't update BO_VA (%d)\n", r);
537} 545}
538 546
539
540
541int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, 547int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
542 struct drm_file *filp) 548 struct drm_file *filp)
543{ 549{
@@ -547,7 +553,8 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
547 struct amdgpu_fpriv *fpriv = filp->driver_priv; 553 struct amdgpu_fpriv *fpriv = filp->driver_priv;
548 struct amdgpu_bo *abo; 554 struct amdgpu_bo *abo;
549 struct amdgpu_bo_va *bo_va; 555 struct amdgpu_bo_va *bo_va;
550 struct ttm_validate_buffer tv, tv_pd; 556 struct amdgpu_bo_list_entry vm_pd;
557 struct ttm_validate_buffer tv;
551 struct ww_acquire_ctx ticket; 558 struct ww_acquire_ctx ticket;
552 struct list_head list, duplicates; 559 struct list_head list, duplicates;
553 uint32_t invalid_flags, va_flags = 0; 560 uint32_t invalid_flags, va_flags = 0;
@@ -592,9 +599,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
592 tv.shared = true; 599 tv.shared = true;
593 list_add(&tv.head, &list); 600 list_add(&tv.head, &list);
594 601
595 tv_pd.bo = &fpriv->vm.page_directory->tbo; 602 amdgpu_vm_get_pd_bo(&fpriv->vm, &list, &vm_pd);
596 tv_pd.shared = true;
597 list_add(&tv_pd.head, &list);
598 603
599 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates); 604 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates);
600 if (r) { 605 if (r) {