diff options
author | Chunming Zhou <David1.Zhou@amd.com> | 2015-11-13 01:18:38 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-11-18 11:41:20 -0500 |
commit | 49b02b180a541d6fb31031aaffe75496e9238942 (patch) | |
tree | ffb0bdf468f5579576b00287bc160b63eb871b6b /drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |
parent | ef9f0a83d68cecca241ee5d61b797d598722772e (diff) |
drm/amdgpu: reserve/unreserve objects out of map/unmap operations
Change-Id: Id6514f2fb6e002437fdbe99353d5d35f4ac736c7
Signed-off-by: Chunming Zhou <David1.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 16dca46314bd..00c5b580f56c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | |||
@@ -515,6 +515,9 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, | |||
515 | struct amdgpu_fpriv *fpriv = filp->driver_priv; | 515 | struct amdgpu_fpriv *fpriv = filp->driver_priv; |
516 | struct amdgpu_bo *rbo; | 516 | struct amdgpu_bo *rbo; |
517 | struct amdgpu_bo_va *bo_va; | 517 | struct amdgpu_bo_va *bo_va; |
518 | struct ttm_validate_buffer tv, tv_pd; | ||
519 | struct ww_acquire_ctx ticket; | ||
520 | struct list_head list, duplicates; | ||
518 | uint32_t invalid_flags, va_flags = 0; | 521 | uint32_t invalid_flags, va_flags = 0; |
519 | int r = 0; | 522 | int r = 0; |
520 | 523 | ||
@@ -552,7 +555,18 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, | |||
552 | return -ENOENT; | 555 | return -ENOENT; |
553 | mutex_lock(&fpriv->vm.mutex); | 556 | mutex_lock(&fpriv->vm.mutex); |
554 | rbo = gem_to_amdgpu_bo(gobj); | 557 | rbo = gem_to_amdgpu_bo(gobj); |
555 | r = amdgpu_bo_reserve(rbo, false); | 558 | INIT_LIST_HEAD(&list); |
559 | INIT_LIST_HEAD(&duplicates); | ||
560 | tv.bo = &rbo->tbo; | ||
561 | tv.shared = true; | ||
562 | list_add(&tv.head, &list); | ||
563 | |||
564 | if (args->operation == AMDGPU_VA_OP_MAP) { | ||
565 | tv_pd.bo = &fpriv->vm.page_directory->tbo; | ||
566 | tv_pd.shared = true; | ||
567 | list_add(&tv_pd.head, &list); | ||
568 | } | ||
569 | r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates); | ||
556 | if (r) { | 570 | if (r) { |
557 | mutex_unlock(&fpriv->vm.mutex); | 571 | mutex_unlock(&fpriv->vm.mutex); |
558 | drm_gem_object_unreference_unlocked(gobj); | 572 | drm_gem_object_unreference_unlocked(gobj); |
@@ -561,7 +575,8 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, | |||
561 | 575 | ||
562 | bo_va = amdgpu_vm_bo_find(&fpriv->vm, rbo); | 576 | bo_va = amdgpu_vm_bo_find(&fpriv->vm, rbo); |
563 | if (!bo_va) { | 577 | if (!bo_va) { |
564 | amdgpu_bo_unreserve(rbo); | 578 | ttm_eu_backoff_reservation(&ticket, &list); |
579 | drm_gem_object_unreference_unlocked(gobj); | ||
565 | mutex_unlock(&fpriv->vm.mutex); | 580 | mutex_unlock(&fpriv->vm.mutex); |
566 | return -ENOENT; | 581 | return -ENOENT; |
567 | } | 582 | } |
@@ -584,7 +599,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, | |||
584 | default: | 599 | default: |
585 | break; | 600 | break; |
586 | } | 601 | } |
587 | 602 | ttm_eu_backoff_reservation(&ticket, &list); | |
588 | if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE)) | 603 | if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE)) |
589 | amdgpu_gem_va_update_vm(adev, bo_va, args->operation); | 604 | amdgpu_gem_va_update_vm(adev, bo_va, args->operation); |
590 | mutex_unlock(&fpriv->vm.mutex); | 605 | mutex_unlock(&fpriv->vm.mutex); |