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

drm/amdgpu: fix using shared fence for exported BOs v2

It is perfectly possible that the BO list is created before the BO is
exported. While at it clean up setting shared to one instead of true.

v2: add comment and simplify logic

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

authored by

Christian König and committed by
Alex Deucher
049aca43 a9f34c70

+11 -3
-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.num_shared = !bo->prime_shared_count; 122 121 123 122 if (bo->preferred_domains == AMDGPU_GEM_DOMAIN_GDS) 124 123 list->gds_obj = bo;
+11 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 598 598 return r; 599 599 } 600 600 601 + amdgpu_bo_list_for_each_entry(e, p->bo_list) 602 + e->tv.num_shared = 1; 603 + 601 604 amdgpu_bo_list_get_list(p->bo_list, &p->validated); 602 605 if (p->bo_list->first_userptr != p->bo_list->num_entries) 603 606 p->mn = amdgpu_mn_get(p->adev, AMDGPU_MN_TYPE_GFX); ··· 720 717 gws = p->bo_list->gws_obj; 721 718 oa = p->bo_list->oa_obj; 722 719 723 - amdgpu_bo_list_for_each_entry(e, p->bo_list) 724 - e->bo_va = amdgpu_vm_bo_find(vm, ttm_to_amdgpu_bo(e->tv.bo)); 720 + amdgpu_bo_list_for_each_entry(e, p->bo_list) { 721 + struct amdgpu_bo *bo = ttm_to_amdgpu_bo(e->tv.bo); 722 + 723 + /* Make sure we use the exclusive slot for shared BOs */ 724 + if (bo->prime_shared_count) 725 + e->tv.num_shared = 0; 726 + e->bo_va = amdgpu_vm_bo_find(vm, bo); 727 + } 725 728 726 729 if (gds) { 727 730 p->job->gds_base = amdgpu_bo_gpu_offset(gds) >> PAGE_SHIFT;