Commit a9f34c70 authored by Christian König's avatar Christian König Committed by Alex Deucher

drm/ttm: allow reserving more than one shared slot v3

Let's support simultaneous submissions to multiple engines.

v2: rename the field to num_shared and fix up all users
v3: rebased
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Reviewed-by: default avatarJunwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c50fe0c5
...@@ -535,7 +535,7 @@ static void add_kgd_mem_to_kfd_bo_list(struct kgd_mem *mem, ...@@ -535,7 +535,7 @@ static void add_kgd_mem_to_kfd_bo_list(struct kgd_mem *mem,
struct amdgpu_bo *bo = mem->bo; struct amdgpu_bo *bo = mem->bo;
INIT_LIST_HEAD(&entry->head); INIT_LIST_HEAD(&entry->head);
entry->shared = true; entry->num_shared = 1;
entry->bo = &bo->tbo; entry->bo = &bo->tbo;
mutex_lock(&process_info->lock); mutex_lock(&process_info->lock);
if (userptr) if (userptr)
...@@ -676,7 +676,7 @@ static int reserve_bo_and_vm(struct kgd_mem *mem, ...@@ -676,7 +676,7 @@ static int reserve_bo_and_vm(struct kgd_mem *mem,
ctx->kfd_bo.priority = 0; ctx->kfd_bo.priority = 0;
ctx->kfd_bo.tv.bo = &bo->tbo; ctx->kfd_bo.tv.bo = &bo->tbo;
ctx->kfd_bo.tv.shared = true; ctx->kfd_bo.tv.num_shared = 1;
ctx->kfd_bo.user_pages = NULL; ctx->kfd_bo.user_pages = NULL;
list_add(&ctx->kfd_bo.tv.head, &ctx->list); list_add(&ctx->kfd_bo.tv.head, &ctx->list);
...@@ -740,7 +740,7 @@ static int reserve_bo_and_cond_vms(struct kgd_mem *mem, ...@@ -740,7 +740,7 @@ static int reserve_bo_and_cond_vms(struct kgd_mem *mem,
ctx->kfd_bo.priority = 0; ctx->kfd_bo.priority = 0;
ctx->kfd_bo.tv.bo = &bo->tbo; ctx->kfd_bo.tv.bo = &bo->tbo;
ctx->kfd_bo.tv.shared = true; ctx->kfd_bo.tv.num_shared = 1;
ctx->kfd_bo.user_pages = NULL; ctx->kfd_bo.user_pages = NULL;
list_add(&ctx->kfd_bo.tv.head, &ctx->list); list_add(&ctx->kfd_bo.tv.head, &ctx->list);
...@@ -1830,7 +1830,7 @@ static int validate_invalid_user_pages(struct amdkfd_process_info *process_info) ...@@ -1830,7 +1830,7 @@ static int validate_invalid_user_pages(struct amdkfd_process_info *process_info)
validate_list.head) { validate_list.head) {
list_add_tail(&mem->resv_list.head, &resv_list); list_add_tail(&mem->resv_list.head, &resv_list);
mem->resv_list.bo = mem->validate_list.bo; mem->resv_list.bo = mem->validate_list.bo;
mem->resv_list.shared = mem->validate_list.shared; mem->resv_list.num_shared = mem->validate_list.num_shared;
} }
/* Reserve all BOs and page tables for validation */ /* Reserve all BOs and page tables for validation */
...@@ -2049,7 +2049,7 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef) ...@@ -2049,7 +2049,7 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef)
list_add_tail(&mem->resv_list.head, &ctx.list); list_add_tail(&mem->resv_list.head, &ctx.list);
mem->resv_list.bo = mem->validate_list.bo; mem->resv_list.bo = mem->validate_list.bo;
mem->resv_list.shared = mem->validate_list.shared; mem->resv_list.num_shared = mem->validate_list.num_shared;
} }
ret = ttm_eu_reserve_buffers(&ctx.ticket, &ctx.list, ret = ttm_eu_reserve_buffers(&ctx.ticket, &ctx.list,
......
...@@ -118,7 +118,7 @@ int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp, ...@@ -118,7 +118,7 @@ int amdgpu_bo_list_create(struct amdgpu_device *adev, struct drm_file *filp,
entry->priority = min(info[i].bo_priority, entry->priority = min(info[i].bo_priority,
AMDGPU_BO_LIST_MAX_PRIORITY); AMDGPU_BO_LIST_MAX_PRIORITY);
entry->tv.bo = &bo->tbo; entry->tv.bo = &bo->tbo;
entry->tv.shared = !bo->prime_shared_count; entry->tv.num_shared = !bo->prime_shared_count;
if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_GDS) if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_GDS)
list->gds_obj = bo; list->gds_obj = bo;
......
...@@ -50,7 +50,7 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p, ...@@ -50,7 +50,7 @@ static int amdgpu_cs_user_fence_chunk(struct amdgpu_cs_parser *p,
bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj));
p->uf_entry.priority = 0; p->uf_entry.priority = 0;
p->uf_entry.tv.bo = &bo->tbo; p->uf_entry.tv.bo = &bo->tbo;
p->uf_entry.tv.shared = true; p->uf_entry.tv.num_shared = 1;
p->uf_entry.user_pages = NULL; p->uf_entry.user_pages = NULL;
drm_gem_object_put_unlocked(gobj); drm_gem_object_put_unlocked(gobj);
......
...@@ -74,7 +74,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm, ...@@ -74,7 +74,7 @@ int amdgpu_map_static_csa(struct amdgpu_device *adev, struct amdgpu_vm *vm,
INIT_LIST_HEAD(&list); INIT_LIST_HEAD(&list);
INIT_LIST_HEAD(&csa_tv.head); INIT_LIST_HEAD(&csa_tv.head);
csa_tv.bo = &bo->tbo; csa_tv.bo = &bo->tbo;
csa_tv.shared = true; csa_tv.num_shared = 1;
list_add(&csa_tv.head, &list); list_add(&csa_tv.head, &list);
amdgpu_vm_get_pd_bo(vm, &list, &pd); amdgpu_vm_get_pd_bo(vm, &list, &pd);
......
...@@ -169,7 +169,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj, ...@@ -169,7 +169,7 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj,
INIT_LIST_HEAD(&duplicates); INIT_LIST_HEAD(&duplicates);
tv.bo = &bo->tbo; tv.bo = &bo->tbo;
tv.shared = true; tv.num_shared = 1;
list_add(&tv.head, &list); list_add(&tv.head, &list);
amdgpu_vm_get_pd_bo(vm, &list, &vm_pd); amdgpu_vm_get_pd_bo(vm, &list, &vm_pd);
...@@ -604,7 +604,10 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, ...@@ -604,7 +604,10 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data,
return -ENOENT; return -ENOENT;
abo = gem_to_amdgpu_bo(gobj); abo = gem_to_amdgpu_bo(gobj);
tv.bo = &abo->tbo; tv.bo = &abo->tbo;
tv.shared = !!(abo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID); if (abo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID)
tv.num_shared = 1;
else
tv.num_shared = 0;
list_add(&tv.head, &list); list_add(&tv.head, &list);
} else { } else {
gobj = NULL; gobj = NULL;
......
...@@ -617,7 +617,7 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm, ...@@ -617,7 +617,7 @@ void amdgpu_vm_get_pd_bo(struct amdgpu_vm *vm,
{ {
entry->priority = 0; entry->priority = 0;
entry->tv.bo = &vm->root.base.bo->tbo; entry->tv.bo = &vm->root.base.bo->tbo;
entry->tv.shared = true; entry->tv.num_shared = 1;
entry->user_pages = NULL; entry->user_pages = NULL;
list_add(&entry->tv.head, validated); list_add(&entry->tv.head, validated);
} }
......
...@@ -217,7 +217,7 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo) ...@@ -217,7 +217,7 @@ int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)
qxl_bo_ref(bo); qxl_bo_ref(bo);
entry->tv.bo = &bo->tbo; entry->tv.bo = &bo->tbo;
entry->tv.shared = false; entry->tv.num_shared = 0;
list_add_tail(&entry->tv.head, &release->bos); list_add_tail(&entry->tv.head, &release->bos);
return 0; return 0;
} }
......
...@@ -178,7 +178,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p) ...@@ -178,7 +178,7 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
} }
p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; p->relocs[i].tv.bo = &p->relocs[i].robj->tbo;
p->relocs[i].tv.shared = !r->write_domain; p->relocs[i].tv.num_shared = !r->write_domain;
radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head, radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head,
priority); priority);
...@@ -253,7 +253,7 @@ static int radeon_cs_sync_rings(struct radeon_cs_parser *p) ...@@ -253,7 +253,7 @@ static int radeon_cs_sync_rings(struct radeon_cs_parser *p)
resv = reloc->robj->tbo.resv; resv = reloc->robj->tbo.resv;
r = radeon_sync_resv(p->rdev, &p->ib.sync, resv, r = radeon_sync_resv(p->rdev, &p->ib.sync, resv,
reloc->tv.shared); reloc->tv.num_shared);
if (r) if (r)
return r; return r;
} }
......
...@@ -552,7 +552,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev, ...@@ -552,7 +552,7 @@ static void radeon_gem_va_update_vm(struct radeon_device *rdev,
INIT_LIST_HEAD(&list); INIT_LIST_HEAD(&list);
tv.bo = &bo_va->bo->tbo; tv.bo = &bo_va->bo->tbo;
tv.shared = true; tv.num_shared = 1;
list_add(&tv.head, &list); list_add(&tv.head, &list);
vm_bos = radeon_vm_get_bos(rdev, bo_va->vm, &list); vm_bos = radeon_vm_get_bos(rdev, bo_va->vm, &list);
......
...@@ -142,7 +142,7 @@ struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev, ...@@ -142,7 +142,7 @@ struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev,
list[0].preferred_domains = RADEON_GEM_DOMAIN_VRAM; list[0].preferred_domains = RADEON_GEM_DOMAIN_VRAM;
list[0].allowed_domains = RADEON_GEM_DOMAIN_VRAM; list[0].allowed_domains = RADEON_GEM_DOMAIN_VRAM;
list[0].tv.bo = &vm->page_directory->tbo; list[0].tv.bo = &vm->page_directory->tbo;
list[0].tv.shared = true; list[0].tv.num_shared = 1;
list[0].tiling_flags = 0; list[0].tiling_flags = 0;
list_add(&list[0].tv.head, head); list_add(&list[0].tv.head, head);
...@@ -154,7 +154,7 @@ struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev, ...@@ -154,7 +154,7 @@ struct radeon_bo_list *radeon_vm_get_bos(struct radeon_device *rdev,
list[idx].preferred_domains = RADEON_GEM_DOMAIN_VRAM; list[idx].preferred_domains = RADEON_GEM_DOMAIN_VRAM;
list[idx].allowed_domains = RADEON_GEM_DOMAIN_VRAM; list[idx].allowed_domains = RADEON_GEM_DOMAIN_VRAM;
list[idx].tv.bo = &list[idx].robj->tbo; list[idx].tv.bo = &list[idx].robj->tbo;
list[idx].tv.shared = true; list[idx].tv.num_shared = 1;
list[idx].tiling_flags = 0; list[idx].tiling_flags = 0;
list_add(&list[idx++].tv.head, head); list_add(&list[idx++].tv.head, head);
} }
......
...@@ -126,10 +126,11 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ...@@ -126,10 +126,11 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
} }
if (!ret) { if (!ret) {
if (!entry->shared) if (!entry->num_shared)
continue; continue;
ret = reservation_object_reserve_shared(bo->resv, 1); ret = reservation_object_reserve_shared(bo->resv,
entry->num_shared);
if (!ret) if (!ret)
continue; continue;
} }
...@@ -150,8 +151,9 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, ...@@ -150,8 +151,9 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
} }
} }
if (!ret && entry->shared) if (!ret && entry->num_shared)
ret = reservation_object_reserve_shared(bo->resv, 1); ret = reservation_object_reserve_shared(bo->resv,
entry->num_shared);
if (unlikely(ret != 0)) { if (unlikely(ret != 0)) {
if (ret == -EINTR) if (ret == -EINTR)
...@@ -199,7 +201,7 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, ...@@ -199,7 +201,7 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket,
list_for_each_entry(entry, list, head) { list_for_each_entry(entry, list, head) {
bo = entry->bo; bo = entry->bo;
if (entry->shared) if (entry->num_shared)
reservation_object_add_shared_fence(bo->resv, fence); reservation_object_add_shared_fence(bo->resv, fence);
else else
reservation_object_add_excl_fence(bo->resv, fence); reservation_object_add_excl_fence(bo->resv, fence);
......
...@@ -85,7 +85,7 @@ static void vmw_resource_release(struct kref *kref) ...@@ -85,7 +85,7 @@ static void vmw_resource_release(struct kref *kref)
struct ttm_validate_buffer val_buf; struct ttm_validate_buffer val_buf;
val_buf.bo = bo; val_buf.bo = bo;
val_buf.shared = false; val_buf.num_shared = 0;
res->func->unbind(res, false, &val_buf); res->func->unbind(res, false, &val_buf);
} }
res->backup_dirty = false; res->backup_dirty = false;
...@@ -462,7 +462,7 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket, ...@@ -462,7 +462,7 @@ vmw_resource_check_buffer(struct ww_acquire_ctx *ticket,
INIT_LIST_HEAD(&val_list); INIT_LIST_HEAD(&val_list);
val_buf->bo = ttm_bo_reference(&res->backup->base); val_buf->bo = ttm_bo_reference(&res->backup->base);
val_buf->shared = false; val_buf->num_shared = 0;
list_add_tail(&val_buf->head, &val_list); list_add_tail(&val_buf->head, &val_list);
ret = ttm_eu_reserve_buffers(ticket, &val_list, interruptible, NULL); ret = ttm_eu_reserve_buffers(ticket, &val_list, interruptible, NULL);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
...@@ -565,7 +565,7 @@ static int vmw_resource_do_evict(struct ww_acquire_ctx *ticket, ...@@ -565,7 +565,7 @@ static int vmw_resource_do_evict(struct ww_acquire_ctx *ticket,
BUG_ON(!func->may_evict); BUG_ON(!func->may_evict);
val_buf.bo = NULL; val_buf.bo = NULL;
val_buf.shared = false; val_buf.num_shared = 0;
ret = vmw_resource_check_buffer(ticket, res, interruptible, &val_buf); ret = vmw_resource_check_buffer(ticket, res, interruptible, &val_buf);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
return ret; return ret;
...@@ -614,7 +614,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr) ...@@ -614,7 +614,7 @@ int vmw_resource_validate(struct vmw_resource *res, bool intr)
return 0; return 0;
val_buf.bo = NULL; val_buf.bo = NULL;
val_buf.shared = false; val_buf.num_shared = 0;
if (res->backup) if (res->backup)
val_buf.bo = &res->backup->base; val_buf.bo = &res->backup->base;
do { do {
...@@ -685,7 +685,7 @@ void vmw_resource_unbind_list(struct vmw_buffer_object *vbo) ...@@ -685,7 +685,7 @@ void vmw_resource_unbind_list(struct vmw_buffer_object *vbo)
struct vmw_resource *res, *next; struct vmw_resource *res, *next;
struct ttm_validate_buffer val_buf = { struct ttm_validate_buffer val_buf = {
.bo = &vbo->base, .bo = &vbo->base,
.shared = false .num_shared = 0
}; };
lockdep_assert_held(&vbo->base.resv->lock.base); lockdep_assert_held(&vbo->base.resv->lock.base);
......
...@@ -266,7 +266,7 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx, ...@@ -266,7 +266,7 @@ int vmw_validation_add_bo(struct vmw_validation_context *ctx,
val_buf->bo = ttm_bo_get_unless_zero(&vbo->base); val_buf->bo = ttm_bo_get_unless_zero(&vbo->base);
if (!val_buf->bo) if (!val_buf->bo)
return -ESRCH; return -ESRCH;
val_buf->shared = false; val_buf->num_shared = 0;
list_add_tail(&val_buf->head, &ctx->bo_list); list_add_tail(&val_buf->head, &ctx->bo_list);
bo_node->as_mob = as_mob; bo_node->as_mob = as_mob;
bo_node->cpu_blit = cpu_blit; bo_node->cpu_blit = cpu_blit;
......
...@@ -40,13 +40,13 @@ ...@@ -40,13 +40,13 @@
* *
* @head: list head for thread-private list. * @head: list head for thread-private list.
* @bo: refcounted buffer object pointer. * @bo: refcounted buffer object pointer.
* @shared: should the fence be added shared? * @num_shared: How many shared fences we want to add.
*/ */
struct ttm_validate_buffer { struct ttm_validate_buffer {
struct list_head head; struct list_head head;
struct ttm_buffer_object *bo; struct ttm_buffer_object *bo;
bool shared; unsigned int num_shared;
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment