Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Christian König <christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Junwei Zhang <Jerry.Zhang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
a9f34c70 c50fe0c5

+35 -30
+5 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 535 535 struct amdgpu_bo *bo = mem->bo; 536 536 537 537 INIT_LIST_HEAD(&entry->head); 538 - entry->shared = true; 538 + entry->num_shared = 1; 539 539 entry->bo = &bo->tbo; 540 540 mutex_lock(&process_info->lock); 541 541 if (userptr) ··· 676 676 677 677 ctx->kfd_bo.priority = 0; 678 678 ctx->kfd_bo.tv.bo = &bo->tbo; 679 - ctx->kfd_bo.tv.shared = true; 679 + ctx->kfd_bo.tv.num_shared = 1; 680 680 ctx->kfd_bo.user_pages = NULL; 681 681 list_add(&ctx->kfd_bo.tv.head, &ctx->list); 682 682 ··· 740 740 741 741 ctx->kfd_bo.priority = 0; 742 742 ctx->kfd_bo.tv.bo = &bo->tbo; 743 - ctx->kfd_bo.tv.shared = true; 743 + ctx->kfd_bo.tv.num_shared = 1; 744 744 ctx->kfd_bo.user_pages = NULL; 745 745 list_add(&ctx->kfd_bo.tv.head, &ctx->list); 746 746 ··· 1830 1830 validate_list.head) { 1831 1831 list_add_tail(&mem->resv_list.head, &resv_list); 1832 1832 mem->resv_list.bo = mem->validate_list.bo; 1833 - mem->resv_list.shared = mem->validate_list.shared; 1833 + mem->resv_list.num_shared = mem->validate_list.num_shared; 1834 1834 } 1835 1835 1836 1836 /* Reserve all BOs and page tables for validation */ ··· 2049 2049 2050 2050 list_add_tail(&mem->resv_list.head, &ctx.list); 2051 2051 mem->resv_list.bo = mem->validate_list.bo; 2052 - mem->resv_list.shared = mem->validate_list.shared; 2052 + mem->resv_list.num_shared = mem->validate_list.num_shared; 2053 2053 } 2054 2054 2055 2055 ret = ttm_eu_reserve_buffers(&ctx.ticket, &ctx.list,
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c
··· 118 118 entry->priority = min(info[i].bo_priority, 119 119 AMDGPU_BO_LIST_MAX_PRIORITY); 120 120 entry->tv.bo = &bo->tbo; 121 - entry->tv.shared = !bo->prime_shared_count; 121 + entry->tv.num_shared = !bo->prime_shared_count; 122 122 123 123 if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_GDS) 124 124 list->gds_obj = bo;
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 50 50 bo = amdgpu_bo_ref(gem_to_amdgpu_bo(gobj)); 51 51 p->uf_entry.priority = 0; 52 52 p->uf_entry.tv.bo = &bo->tbo; 53 - p->uf_entry.tv.shared = true; 53 + p->uf_entry.tv.num_shared = 1; 54 54 p->uf_entry.user_pages = NULL; 55 55 56 56 drm_gem_object_put_unlocked(gobj);
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_csa.c
··· 74 74 INIT_LIST_HEAD(&list); 75 75 INIT_LIST_HEAD(&csa_tv.head); 76 76 csa_tv.bo = &bo->tbo; 77 - csa_tv.shared = true; 77 + csa_tv.num_shared = 1; 78 78 79 79 list_add(&csa_tv.head, &list); 80 80 amdgpu_vm_get_pd_bo(vm, &list, &pd);
+5 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
··· 169 169 INIT_LIST_HEAD(&duplicates); 170 170 171 171 tv.bo = &bo->tbo; 172 - tv.shared = true; 172 + tv.num_shared = 1; 173 173 list_add(&tv.head, &list); 174 174 175 175 amdgpu_vm_get_pd_bo(vm, &list, &vm_pd); ··· 604 604 return -ENOENT; 605 605 abo = gem_to_amdgpu_bo(gobj); 606 606 tv.bo = &abo->tbo; 607 - tv.shared = !!(abo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID); 607 + if (abo->flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) 608 + tv.num_shared = 1; 609 + else 610 + tv.num_shared = 0; 608 611 list_add(&tv.head, &list); 609 612 } else { 610 613 gobj = NULL;
+1 -1
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 617 617 { 618 618 entry->priority = 0; 619 619 entry->tv.bo = &vm->root.base.bo->tbo; 620 - entry->tv.shared = true; 620 + entry->tv.num_shared = 1; 621 621 entry->user_pages = NULL; 622 622 list_add(&entry->tv.head, validated); 623 623 }
+1 -1
drivers/gpu/drm/qxl/qxl_release.c
··· 217 217 218 218 qxl_bo_ref(bo); 219 219 entry->tv.bo = &bo->tbo; 220 - entry->tv.shared = false; 220 + entry->tv.num_shared = 0; 221 221 list_add_tail(&entry->tv.head, &release->bos); 222 222 return 0; 223 223 }
+2 -2
drivers/gpu/drm/radeon/radeon_cs.c
··· 178 178 } 179 179 180 180 p->relocs[i].tv.bo = &p->relocs[i].robj->tbo; 181 - p->relocs[i].tv.shared = !r->write_domain; 181 + p->relocs[i].tv.num_shared = !r->write_domain; 182 182 183 183 radeon_cs_buckets_add(&buckets, &p->relocs[i].tv.head, 184 184 priority); ··· 253 253 254 254 resv = reloc->robj->tbo.resv; 255 255 r = radeon_sync_resv(p->rdev, &p->ib.sync, resv, 256 - reloc->tv.shared); 256 + reloc->tv.num_shared); 257 257 if (r) 258 258 return r; 259 259 }
+1 -1
drivers/gpu/drm/radeon/radeon_gem.c
··· 552 552 INIT_LIST_HEAD(&list); 553 553 554 554 tv.bo = &bo_va->bo->tbo; 555 - tv.shared = true; 555 + tv.num_shared = 1; 556 556 list_add(&tv.head, &list); 557 557 558 558 vm_bos = radeon_vm_get_bos(rdev, bo_va->vm, &list);
+2 -2
drivers/gpu/drm/radeon/radeon_vm.c
··· 142 142 list[0].preferred_domains = RADEON_GEM_DOMAIN_VRAM; 143 143 list[0].allowed_domains = RADEON_GEM_DOMAIN_VRAM; 144 144 list[0].tv.bo = &vm->page_directory->tbo; 145 - list[0].tv.shared = true; 145 + list[0].tv.num_shared = 1; 146 146 list[0].tiling_flags = 0; 147 147 list_add(&list[0].tv.head, head); 148 148 ··· 154 154 list[idx].preferred_domains = RADEON_GEM_DOMAIN_VRAM; 155 155 list[idx].allowed_domains = RADEON_GEM_DOMAIN_VRAM; 156 156 list[idx].tv.bo = &list[idx].robj->tbo; 157 - list[idx].tv.shared = true; 157 + list[idx].tv.num_shared = 1; 158 158 list[idx].tiling_flags = 0; 159 159 list_add(&list[idx++].tv.head, head); 160 160 }
+7 -5
drivers/gpu/drm/ttm/ttm_execbuf_util.c
··· 126 126 } 127 127 128 128 if (!ret) { 129 - if (!entry->shared) 129 + if (!entry->num_shared) 130 130 continue; 131 131 132 - ret = reservation_object_reserve_shared(bo->resv, 1); 132 + ret = reservation_object_reserve_shared(bo->resv, 133 + entry->num_shared); 133 134 if (!ret) 134 135 continue; 135 136 } ··· 151 150 } 152 151 } 153 152 154 - if (!ret && entry->shared) 155 - ret = reservation_object_reserve_shared(bo->resv, 1); 153 + if (!ret && entry->num_shared) 154 + ret = reservation_object_reserve_shared(bo->resv, 155 + entry->num_shared); 156 156 157 157 if (unlikely(ret != 0)) { 158 158 if (ret == -EINTR) ··· 201 199 202 200 list_for_each_entry(entry, list, head) { 203 201 bo = entry->bo; 204 - if (entry->shared) 202 + if (entry->num_shared) 205 203 reservation_object_add_shared_fence(bo->resv, fence); 206 204 else 207 205 reservation_object_add_excl_fence(bo->resv, fence);
+5 -5
drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
··· 85 85 struct ttm_validate_buffer val_buf; 86 86 87 87 val_buf.bo = bo; 88 - val_buf.shared = false; 88 + val_buf.num_shared = 0; 89 89 res->func->unbind(res, false, &val_buf); 90 90 } 91 91 res->backup_dirty = false; ··· 462 462 463 463 INIT_LIST_HEAD(&val_list); 464 464 val_buf->bo = ttm_bo_reference(&res->backup->base); 465 - val_buf->shared = false; 465 + val_buf->num_shared = 0; 466 466 list_add_tail(&val_buf->head, &val_list); 467 467 ret = ttm_eu_reserve_buffers(ticket, &val_list, interruptible, NULL); 468 468 if (unlikely(ret != 0)) ··· 565 565 BUG_ON(!func->may_evict); 566 566 567 567 val_buf.bo = NULL; 568 - val_buf.shared = false; 568 + val_buf.num_shared = 0; 569 569 ret = vmw_resource_check_buffer(ticket, res, interruptible, &val_buf); 570 570 if (unlikely(ret != 0)) 571 571 return ret; ··· 614 614 return 0; 615 615 616 616 val_buf.bo = NULL; 617 - val_buf.shared = false; 617 + val_buf.num_shared = 0; 618 618 if (res->backup) 619 619 val_buf.bo = &res->backup->base; 620 620 do { ··· 685 685 struct vmw_resource *res, *next; 686 686 struct ttm_validate_buffer val_buf = { 687 687 .bo = &vbo->base, 688 - .shared = false 688 + .num_shared = 0 689 689 }; 690 690 691 691 lockdep_assert_held(&vbo->base.resv->lock.base);
+1 -1
drivers/gpu/drm/vmwgfx/vmwgfx_validation.c
··· 266 266 val_buf->bo = ttm_bo_get_unless_zero(&vbo->base); 267 267 if (!val_buf->bo) 268 268 return -ESRCH; 269 - val_buf->shared = false; 269 + val_buf->num_shared = 0; 270 270 list_add_tail(&val_buf->head, &ctx->bo_list); 271 271 bo_node->as_mob = as_mob; 272 272 bo_node->cpu_blit = cpu_blit;
+2 -2
include/drm/ttm/ttm_execbuf_util.h
··· 40 40 * 41 41 * @head: list head for thread-private list. 42 42 * @bo: refcounted buffer object pointer. 43 - * @shared: should the fence be added shared? 43 + * @num_shared: How many shared fences we want to add. 44 44 */ 45 45 46 46 struct ttm_validate_buffer { 47 47 struct list_head head; 48 48 struct ttm_buffer_object *bo; 49 - bool shared; 49 + unsigned int num_shared; 50 50 }; 51 51 52 52 /**