Implement multi-GPU DMA mappings for KFD
Subsystems (5)
Felix Kuehling
maintainercover Implement multi-GPU DMA mappings for KFD
This patch series fixes DMA-mappings of system memory (GTT and userptr) for KFD running on multi-GPU systems with IOMMU enabled. One SG-BO per GPU is needed to maintain the DMA mappings of each BO.
I ran into some reservation issues when unmapping or freeing DMA-buf imports. There are a few FIXME comments in this patch series where I'm hoping for some expert advice. Patches 8 and 9 are some related fixes in TTM and amdgpu_ttm. I'm pretty sure patch 9 is not the right way to do this.
Felix Kuehling (9):
drm/amdgpu: Rename kfd_bo_va_list to kfd_mem_attachment drm/amdgpu: Keep a bo-reference per-attachment drm/amdgpu: Simplify AQL queue mapping drm/amdgpu: Add multi-GPU DMA mapping helpers drm/amdgpu: DMA map/unmap when updating GPU mappings drm/amdgpu: Move kfd_mem_attach outside reservation drm/amdgpu: Add DMA mapping of GTT BOs
drm/ttm: Don't count pages in SG BOs against pages_limit drm/amdgpu: Lock the attached dmabuf in unpopulate
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 18 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 535 ++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 + drivers/gpu/drm/ttm/ttm_tt.c | 27 +- 4 files changed, 420 insertions(+), 173 deletions(-)
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 1/9 drm/amdgpu: Rename kfd_bo_va_list to kfd_mem_attachment
This name is more fitting, especially for the changes coming next to support multi-GPU systems with proper DMA mappings. Cleaned up the code and renamed some related functions and variables to improve readability.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 8 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 209 +++++++++--------- 2 files changed, 104 insertions(+), 113 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +4 -4
@@ -38,10 +38,10 @@ extern uint64_t amdgpu_amdkfd_total_mem_size;struct amdgpu_device ; -struct kfd_bo_va_list { -struct list_head bo_list; +struct kfd_mem_attachment { +struct list_head list;struct amdgpu_bo_va *bo_va; -void *kgd_dev; +struct amdgpu_device *adev;bool is_mapped;uint64_t va;uint64_t pte_flags;
@@ -50,7 +50,7 @@ struct kfd_bo_va_list {struct kgd_mem {struct mutex lock;struct amdgpu_bo *bo; -struct list_head bo_va_list; +struct list_head attachments;/* protected by amdkfd_process_info.lock */ struct ttm_validate_buffer validate_list;struct ttm_validate_buffer resv_list;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +100 -109
412 lines not on this page · raw message
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 2/9 drm/amdgpu: Keep a bo-reference per-attachment
In reply to Felix KuehlingFor now they all reference the same BO. For correct DMA mappings they will refer to different BOs per-GPU.
--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +17 -5
@@ -487,11 +487,11 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem, struct amdgpu_vm *vm, bool is_aql, struct kfd_mem_attachment **p_attachment) { - int ret; -struct kfd_mem_attachment *attachment; -struct amdgpu_bo *bo = mem->bo; + unsigned long bo_size = mem->bo->tbo.base.size;uint64_t va = mem->va; -unsigned long bo_size = bo->tbo.base.size; +struct kfd_mem_attachment *attachment; +struct amdgpu_bo *bo; +int ret;if (!va) {pr_err ("Invalid VA when adding BO to VM\n" );
@@ -508,6 +508,14 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,pr_debug ("\t add VA 0x%llx - 0x%llx to vm %p\n" , va, va + bo_size, vm); +/* FIXME: For now all attachments use the same BO. This is incorrect +* because one BO can only have one DMA mapping for one GPU. We need +* one BO per GPU, e.g. a DMABuf import with dynamic attachment. This +* will be addressed one BO-type at a time in subsequent patches. +*/ + bo = mem->bo; +drm_gem_object_get (&bo->tbo.base); +/* Add BO to VM internal data structures*/ attachment->bo_va =amdgpu_vm_bo_add (adev, vm, bo);if (!attachment->bo_va) {
@@ -527,7 +535,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,/* Allocate validate page tables if needed */ ret =vm_validate_pt_pd_bos (vm); -if (ret) { +if (unlikely (ret)) {pr_err ("validate_pt_pd_bos() failed\n" ); goto err_alloc_pts; }
@@ -538,15 +546,19 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,amdgpu_vm_bo_rmv (adev, attachment->bo_va);list_del (&attachment->list); err_vmadd: +drm_gem_object_put (&bo->tbo.base);kfree (attachment);return ret; }static void kfd_mem_detach (struct kfd_mem_attachment *attachment) { +struct amdgpu_bo *bo = attachment->bo_va->base.bo; +pr_debug ("\t remove VA 0x%llx in entry %p\n" , attachment->va, attachment);amdgpu_vm_bo_rmv (attachment->adev, attachment->bo_va); +drm_gem_object_put (&bo->tbo.base);list_del (&attachment->list);kfree (attachment); }
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 3/9 drm/amdgpu: Simplify AQL queue mapping
In reply to Felix KuehlingDo AQL queue double-mapping with a single attach call. That will make it easier to create per-GPU BOs later, to be shared between the two BO VA mappings on the same GPU.
Freeing the attachments is not necessary if map_to_gpu fails. These will be cleaned up when the kdg_mem object is destroyed in amdgpu_amdkfd_gpuvm_free_memory_of_gpu.
--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 103 ++++++++---------- 1 file changed, 48 insertions(+), 55 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +48 -55
@@ -484,70 +484,76 @@ static uint64_t get_pte_flags(struct amdgpu_device *adev, struct kgd_mem *mem)* 4a. Validate new page tables and directories */ static int kfd_mem_attach (struct amdgpu_device *adev,struct kgd_mem *mem, -struct amdgpu_vm *vm,bool is_aql, -struct kfd_mem_attachment **p_attachment) +struct amdgpu_vm *vm,bool is_aql) {unsigned long bo_size = mem->bo->tbo.base.size;uint64_t va = mem->va; -struct kfd_mem_attachment *attachment; -struct amdgpu_bo *bo; -int ret; +struct kfd_mem_attachment *attachment[2 ] = {NULL ,NULL }; +struct amdgpu_bo *bo[2 ] = {NULL ,NULL }; +int i, ret;if (!va) {pr_err ("Invalid VA when adding BO to VM\n" );return -EINVAL ; } -if (is_aql) - va += bo_size; - - attachment =kzalloc (sizeof (*attachment),GFP_KERNEL ); -if (!attachment) -return -ENOMEM ; +for (i =0 ; i <= is_aql; i++) { + attachment[i] =kzalloc (sizeof (*attachment[i]),GFP_KERNEL ); +if (unlikely (!attachment[i])) { + ret = -ENOMEM ; + goto unwind; + } -pr_debug ("\t add VA 0x%llx - 0x%llx to vm %p\n" , va, - va + bo_size, vm); +pr_debug ("\t add VA 0x%llx - 0x%llx to vm %p\n" , va, + va + bo_size, vm); -/* FIXME: For now all attachments use the same BO. This is incorrect -* because one BO can only have one DMA mapping for one GPU. We need -* one BO per GPU, e.g. a DMABuf import with dynamic attachment. This -* will be addressed one BO-type at a time in subsequent patches. -*/ - bo = mem->bo; -drm_gem_object_get (&bo->tbo.base); +/* FIXME: For now all attachments use the same BO. This is +* incorrect because one BO can only have one DMA mapping +* for one GPU. We need one BO per GPU, e.g. a DMABuf +* import with dynamic attachment. This will be addressed +* one BO-type at a time in subsequent patches. +*/ + bo[i] = mem->bo; +drm_gem_object_get (&bo[i]->tbo.base); -/* Add BO to VM internal data structures*/ - attachment->bo_va =amdgpu_vm_bo_add (adev, vm, bo); -if (!attachment->bo_va) { - ret = -EINVAL ; -pr_err ("Failed to add BO object to VM. ret == %d\n" , - ret); - goto err_vmadd; - } +/* Add BO to VM internal data structures */ + attachment[i]->bo_va =amdgpu_vm_bo_add (adev, vm, bo[i]); +if (unlikely (!attachment[i]->bo_va)) { + ret = -ENOMEM ; +pr_err ("Failed to add BO object to VM. ret == %d\n" , + ret); + goto unwind; + } - attachment->va = va; - attachment->pte_flags =get_pte_flags (adev, mem); - attachment->adev = adev; -list_add (&attachment->list, &mem->attachments); + attachment[i]->va = va; + attachment[i]->pte_flags =get_pte_flags (adev, mem); + attachment[i]->adev = adev; +list_add (&attachment[i]->list, &mem->attachments); -if (p_attachment) - *p_attachment = attachment; + va += bo_size; + }/* Allocate validate page tables if needed */ ret =vm_validate_pt_pd_bos (vm);if (unlikely (ret)) {pr_err ("validate_pt_pd_bos() failed\n" ); - goto err_alloc_pts; + goto unwind; }return 0 ; -err_alloc_pts: -amdgpu_vm_bo_rmv (adev, attachment->bo_va); -list_del (&attachment->list); -err_vmadd: -drm_gem_object_put (&bo->tbo.base); -kfree (attachment); +unwind: +for (; i >=0 ; i--) { +if (!attachment[i]) +continue ; +if (attachment[i]->bo_va) { +amdgpu_vm_bo_rmv (adev, attachment[i]->bo_va); +list_del (&attachment[i]->list); + } +if (bo[i]) +drm_gem_object_put (&bo[i]->tbo.base); +kfree (attachment[i]); + }return ret; }
@@ -1414,8 +1420,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(uint32_t domain;struct kfd_mem_attachment *entry;struct bo_vm_reservation_context ctx; -struct kfd_mem_attachment *attachment =NULL ; -struct kfd_mem_attachment *attachment_aql =NULL ;unsigned long bo_size;bool is_invalid_userptr = false;
@@ -1465,15 +1469,9 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( is_invalid_userptr = true;if (!kfd_mem_is_attached (avm, mem)) { - ret =kfd_mem_attach (adev, mem, avm, false, &attachment); + ret =kfd_mem_attach (adev, mem, avm, mem->aql_queue);if (ret) goto attach_failed; -if (mem->aql_queue) { - ret =kfd_mem_attach (adev, mem, avm, true, - &attachment_aql); -if (ret) - goto attach_failed_aql; - } }else { ret =vm_validate_pt_pd_bos (avm);if (unlikely (ret))
@@ -1528,11 +1526,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( goto out; map_bo_to_gpuvm_failed: -if (attachment_aql) -kfd_mem_detach (attachment_aql); -attach_failed_aql: -if (attachment) -kfd_mem_detach (attachment); attach_failed:unreserve_bo_and_vms (&ctx, false, false); out:
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 4/9 drm/amdgpu: Add multi-GPU DMA mapping helpers
In reply to Felix KuehlingAdd BO-type specific helpers functions to DMA-map and unmap kfd_mem_attachments. Implement this functionality for userptrs by creating one SG BO per GPU and filling it with a DMA mapping of the pages from the original mem->bo.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 8 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 155 ++++++++++++++++-- 2 files changed, 152 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +7 -1
@@ -38,11 +38,17 @@ extern uint64_t amdgpu_amdkfd_total_mem_size;struct amdgpu_device ; +enum kfd_mem_attachment_type { +KFD_MEM_ATT_SHARED ,/* Share kgd_mem->bo or another attachment's */ +KFD_MEM_ATT_USERPTR ,/* SG bo to DMA map pages from a userptr bo */ +}; +struct kfd_mem_attachment {struct list_head list; +enum kfd_mem_attachment_type type; +bool is_mapped;struct amdgpu_bo_va *bo_va;struct amdgpu_device *adev; -bool is_mapped;uint64_t va;uint64_t pte_flags; };
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +145 -10
201 lines not on this page · raw message
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 5/9 drm/amdgpu: DMA map/unmap when updating GPU mappings
In reply to Felix KuehlingDMA map kfd_mem_attachments in update_gpuvm_pte. This function is called with the BO and page tables reserved, so we can safely update the DMA mapping.
DMA unmap when a BO is unmapped from a GPU and before updating mappings in restore workers.
--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +29 -27
@@ -964,11 +964,12 @@ static int unreserve_bo_and_vms(struct bo_vm_reservation_context *ctx,return ret; } -static int unmap_bo_from_gpuvm (struct amdgpu_device *adev, +static void unmap_bo_from_gpuvm (struct kgd_mem *mem,struct kfd_mem_attachment *entry,struct amdgpu_sync *sync) {struct amdgpu_bo_va *bo_va = entry->bo_va; +struct amdgpu_device *adev = entry->adev;struct amdgpu_vm *vm = bo_va->base.vm;amdgpu_vm_bo_unmap (adev, bo_va, entry->va);
@@ -977,15 +978,20 @@ static int unmap_bo_from_gpuvm(struct amdgpu_device *adev,amdgpu_sync_fence (sync, bo_va->last_pt_update); -return 0 ; +kfd_mem_dmaunmap_attachment (mem, entry); } -static int update_gpuvm_pte (struct amdgpu_device *adev, -struct kfd_mem_attachment *entry, -struct amdgpu_sync *sync) +static int update_gpuvm_pte (struct kgd_mem *mem, +struct kfd_mem_attachment *entry, +struct amdgpu_sync *sync) { -int ret;struct amdgpu_bo_va *bo_va = entry->bo_va; +struct amdgpu_device *adev = entry->adev; +int ret; + + ret =kfd_mem_dmamap_attachment (mem, entry); +if (ret) +return ret;/* Update the page tables */ ret =amdgpu_vm_bo_update (adev, bo_va, false);
@@ -997,14 +1003,15 @@ static int update_gpuvm_pte(struct amdgpu_device *adev,return amdgpu_sync_fence (sync, bo_va->last_pt_update); } -static int map_bo_to_gpuvm (struct amdgpu_device *adev, -struct kfd_mem_attachment *entry,struct amdgpu_sync *sync, -bool no_update_pte) +static int map_bo_to_gpuvm (struct kgd_mem *mem, +struct kfd_mem_attachment *entry, +struct amdgpu_sync *sync, +bool no_update_pte) {int ret;/* Set virtual address for the allocation */ - ret =amdgpu_vm_bo_map (adev, entry->bo_va, entry->va,0 , + ret =amdgpu_vm_bo_map (entry->adev, entry->bo_va, entry->va,0 ,amdgpu_bo_size (entry->bo_va->base.bo), entry->pte_flags);if (ret) {
@@ -1016,7 +1023,7 @@ static int map_bo_to_gpuvm(struct amdgpu_device *adev,if (no_update_pte)return 0 ; - ret =update_gpuvm_pte (adev, entry, sync); + ret =update_gpuvm_pte (mem, entry, sync);if (ret) {pr_err ("update_gpuvm_pte() failed\n" ); goto update_gpuvm_pte_failed;
@@ -1025,7 +1032,7 @@ static int map_bo_to_gpuvm(struct amdgpu_device *adev,return 0 ; update_gpuvm_pte_failed: -unmap_bo_from_gpuvm (adev, entry, sync); +unmap_bo_from_gpuvm (mem, entry, sync);return ret; }
@@ -1633,7 +1640,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(pr_debug ("\t map VA 0x%llx - 0x%llx in entry %p\n" , entry->va, entry->va + bo_size, entry); - ret =map_bo_to_gpuvm (adev, entry, ctx.sync, + ret =map_bo_to_gpuvm (mem, entry, ctx.sync, is_invalid_userptr);if (ret) {pr_err ("Failed to map bo to gpuvm\n" );
@@ -1672,7 +1679,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu (struct kgd_dev *kgd,struct kgd_mem *mem,void *vm) { -struct amdgpu_device *adev =get_amdgpu_device (kgd);struct amdkfd_process_info *process_info = ((struct amdgpu_vm *)vm)->process_info;unsigned long bo_size = mem->bo->tbo.base.size;
@@ -1707,13 +1713,8 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(pr_debug ("\t unmap VA 0x%llx - 0x%llx from entry %p\n" , entry->va, entry->va + bo_size, entry); - ret =unmap_bo_from_gpuvm (adev, entry, ctx.sync); -if (ret ==0 ) { - entry->is_mapped = false; - }else { -pr_err ("failed to unmap VA 0x%llx\n" , mem->va); - goto unreserve_out; - } +unmap_bo_from_gpuvm (mem, entry, ctx.sync); + entry->is_mapped = false; mem->mapped_to_gpu_memory--; pr_debug("\t DEC mapping count %d\n",
@@ -2083,9 +2084,8 @@ static int validate_invalid_user_pages(struct amdkfd_process_info *process_info)if (!attachment->is_mapped)continue ; - ret =update_gpuvm_pte ((struct amdgpu_device *) - attachment->adev, - attachment, &sync); +kfd_mem_dmaunmap_attachment (mem, attachment); + ret =update_gpuvm_pte (mem, attachment, &sync);if (ret) {pr_err ("%s: update PTE failed\n" , __func__);/* make sure this gets validated again */
@@ -2287,9 +2287,11 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info, struct dma_fence **ef) goto validate_map_fail; }list_for_each_entry (attachment, &mem->attachments, list) { - ret =update_gpuvm_pte ((struct amdgpu_device *) - attachment->adev, attachment, - &sync_obj); +if (!attachment->is_mapped) +continue ; + +kfd_mem_dmaunmap_attachment (mem, attachment); + ret =update_gpuvm_pte (mem, attachment, &sync_obj);if (ret) {pr_debug ("Memory eviction: update PTE failed. Try again\n" ); goto validate_map_fail;
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 6/9 drm/amdgpu: Move kfd_mem_attach outside reservation
In reply to Felix KuehlingThis is needed to avoid deadlocks with DMA buf import in the next patch. Also move PT/PD validation out of kfd_mem_attach, that way the caller can bo this unconditionally.
--- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 72 +++++++++++-------- 1 file changed, 42 insertions(+), 30 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +42 -30
@@ -575,6 +575,32 @@ kfd_mem_dmaunmap_attachment(struct kgd_mem *mem, } } +static int +kfd_mem_attach_userptr (struct amdgpu_device *adev,struct kgd_mem *mem, +struct amdgpu_bo **bo) +{ +unsigned long bo_size = mem->bo->tbo.base.size; +struct drm_gem_object *gobj; +int ret; + + ret =amdgpu_bo_reserve (mem->bo, false); +if (ret) +return ret; + + ret =amdgpu_gem_object_create (adev, bo_size,1 , +AMDGPU_GEM_DOMAIN_CPU , +0 , ttm_bo_type_sg, + mem->bo->tbo.base.resv, + &gobj); +if (ret) +return ret; + +amdgpu_bo_unreserve (mem->bo); + + *bo =gem_to_amdgpu_bo (gobj); +return 0 ; +} +/* kfd_mem_attach - Add a BO to a VM * * Everything that needs to bo done only once when a BO is first added
@@ -596,7 +622,6 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,uint64_t va = mem->va;struct kfd_mem_attachment *attachment[2 ] = {NULL ,NULL };struct amdgpu_bo *bo[2 ] = {NULL ,NULL }; -struct drm_gem_object *gobj;int i, ret;if (!va) {
@@ -630,14 +655,9 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem, }else if (amdgpu_ttm_tt_get_usermm (mem->bo->tbo.ttm)) {/* Create an SG BO to DMA-map userptrs on other GPUs */ attachment[i]->type =KFD_MEM_ATT_USERPTR ; - ret =amdgpu_gem_object_create (adev, bo_size,1 , -AMDGPU_GEM_DOMAIN_CPU , -0 , ttm_bo_type_sg, - mem->bo->tbo.base.resv, - &gobj); + ret =kfd_mem_attach_userptr (adev, mem, &bo[i]);if (ret) goto unwind; - bo[i] =gem_to_amdgpu_bo (gobj); }else {/* FIXME: Need to DMA-map other BO types */ attachment[i]->type =KFD_MEM_ATT_SHARED ;
@@ -662,13 +682,6 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem, va += bo_size; } -/* Allocate validate page tables if needed */ - ret =vm_validate_pt_pd_bos (vm); -if (unlikely (ret)) { -pr_err ("validate_pt_pd_bos() failed\n" ); - goto unwind; - } -return 0 ; unwind:
@@ -1516,12 +1529,12 @@ int amdgpu_amdkfd_gpuvm_free_memory_of_gpu(pr_debug ("Release VA 0x%llx - 0x%llx\n" , mem->va, mem->va + bo_size * (1 + mem->aql_queue)); + ret =unreserve_bo_and_vms (&ctx, false, false); +/* Remove from VM internal data structures */ list_for_each_entry_safe (entry, tmp, &mem->attachments, list)kfd_mem_detach (mem, entry); - ret =unreserve_bo_and_vms (&ctx, false, false); -/* Free the sync object */ amdgpu_sync_free (&mem->sync);
@@ -1597,6 +1610,12 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( mem->va + bo_size * (1 + mem->aql_queue), vm, domain_string(domain)); +if (!kfd_mem_is_attached (avm, mem)) { + ret =kfd_mem_attach (adev, mem, avm, mem->aql_queue); +if (ret) + goto out; + } + ret =reserve_bo_and_vm (mem, vm, &ctx);if (unlikely (ret)) goto out;
@@ -1610,15 +1629,9 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( bo->tbo.mem.mem_type == TTM_PL_SYSTEM) is_invalid_userptr = true; -if (!kfd_mem_is_attached (avm, mem)) { - ret =kfd_mem_attach (adev, mem, avm, mem->aql_queue); -if (ret) - goto attach_failed; - }else { - ret =vm_validate_pt_pd_bos (avm); -if (unlikely (ret)) - goto attach_failed; - } + ret =vm_validate_pt_pd_bos (avm); +if (unlikely (ret)) + goto out_unreserve;if (mem->mapped_to_gpu_memory ==0 && !amdgpu_ttm_tt_get_usermm (bo->tbo.ttm)) {
@@ -1629,7 +1642,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( ret =amdgpu_amdkfd_bo_validate (bo, domain, true);if (ret) {pr_debug ("Validate failed\n" ); - goto map_bo_to_gpuvm_failed; + goto out_unreserve; } }
@@ -1644,13 +1657,13 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( is_invalid_userptr);if (ret) {pr_err ("Failed to map bo to gpuvm\n" ); - goto map_bo_to_gpuvm_failed; + goto out_unreserve; } ret =vm_update_pds (vm, ctx.sync);if (ret) {pr_err ("Failed to update page directories\n" ); - goto map_bo_to_gpuvm_failed; + goto out_unreserve; } entry->is_mapped = true;
@@ -1667,8 +1680,7 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu( goto out; -map_bo_to_gpuvm_failed: -attach_failed: +out_unreserve:unreserve_bo_and_vms (&ctx, false, false); out:mutex_unlock (&mem->process_info->lock);
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 7/9 drm/amdgpu: Add DMA mapping of GTT BOs
In reply to Felix KuehlingUse DMABufs with dynamic attachment to DMA-map GTT BOs on other GPUs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 2 + .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 74 ++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h +2 -0
@@ -41,6 +41,7 @@ struct amdgpu_device;enum kfd_mem_attachment_type {KFD_MEM_ATT_SHARED ,/* Share kgd_mem->bo or another attachment's */ KFD_MEM_ATT_USERPTR ,/* SG bo to DMA map pages from a userptr bo */ +KFD_MEM_ATT_DMABUF ,/* DMAbuf to DMA map TTM BOs */ };struct kfd_mem_attachment {
@@ -56,6 +57,7 @@ struct kfd_mem_attachment {struct kgd_mem {struct mutex lock;struct amdgpu_bo *bo; +struct dma_buf *dmabuf;struct list_head attachments;/* protected by amdkfd_process_info.lock */ struct ttm_validate_buffer validate_list;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +73 -1
117 lines not on this page · raw message
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 8/9 drm/ttm: Don't count pages in SG BOs against pages_limit
In reply to Felix KuehlingPages in SG BOs were not allocated by TTM. So don't count them against TTM's pages limit.
--- drivers/gpu/drm/ttm/ttm_tt.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +18 -9
@@ -317,9 +317,12 @@ int ttm_tt_populate(struct ttm_device *bdev,if (ttm_tt_is_populated (ttm))return 0 ; -atomic_long_add (ttm->num_pages, &ttm_pages_allocated); -if (bdev->pool.use_dma32) -atomic_long_add (ttm->num_pages, &ttm_dma32_pages_allocated); +if (!(ttm->page_flags &TTM_PAGE_FLAG_SG )) { +atomic_long_add (ttm->num_pages, &ttm_pages_allocated); +if (bdev->pool.use_dma32) +atomic_long_add (ttm->num_pages, + &ttm_dma32_pages_allocated); + }while (atomic_long_read (&ttm_pages_allocated) > ttm_pages_limit || atomic_long_read(&ttm_dma32_pages_allocated) >
@@ -350,9 +353,12 @@ int ttm_tt_populate(struct ttm_device *bdev,return 0 ; error: -atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); -if (bdev->pool.use_dma32) -atomic_long_sub (ttm->num_pages, &ttm_dma32_pages_allocated); +if (!(ttm->page_flags &TTM_PAGE_FLAG_SG )) { +atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); +if (bdev->pool.use_dma32) +atomic_long_sub (ttm->num_pages, + &ttm_dma32_pages_allocated); + }return ret; }EXPORT_SYMBOL (ttm_tt_populate);
@@ -382,9 +388,12 @@ void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)else ttm_pool_free (&bdev->pool, ttm); -atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); -if (bdev->pool.use_dma32) -atomic_long_sub (ttm->num_pages, &ttm_dma32_pages_allocated); +if (!(ttm->page_flags &TTM_PAGE_FLAG_SG )) { +atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); +if (bdev->pool.use_dma32) +atomic_long_sub (ttm->num_pages, + &ttm_dma32_pages_allocated); + } ttm->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED ; }
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 8/9] drm/ttm: Don't count pages in SG BOs against pages_limit
Quoted 4 lines · Felix Kuehling
Pages in SG BOs were not allocated by TTM. So don't count them against TTM's pages limit.
Signed-off-by Felix Kuehling <[email protected]>
This sounds like papering over the lack of shrinker in ttm. Do we guarantee that someone else has already accounted these buffers against the ttm memory hard-limit anywhere? If not I think this needs to wait for the shrinker work to get solid, since fixing the double-accounting for this is probably not worth it.
-Daniel
Quoted 63 lines
--- drivers/gpu/drm/ttm/ttm_tt.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/gpu/drm/ttm/ttm_tt.c +18
-9@@ -317,9 +317,12 @@ int ttm_tt_populate(struct ttm_device *bdev,if (ttm_tt_is_populated (ttm))return 0 ; -atomic_long_add (ttm->num_pages, &ttm_pages_allocated); -if (bdev->pool.use_dma32) -atomic_long_add (ttm->num_pages, &ttm_dma32_pages_allocated); +if (!(ttm->page_flags &TTM_PAGE_FLAG_SG )) { +atomic_long_add (ttm->num_pages, &ttm_pages_allocated); +if (bdev->pool.use_dma32) +atomic_long_add (ttm->num_pages, + &ttm_dma32_pages_allocated); + }while (atomic_long_read (&ttm_pages_allocated) > ttm_pages_limit || atomic_long_read(&ttm_dma32_pages_allocated) >@@ -350,9 +353,12 @@ int ttm_tt_populate(struct ttm_device *bdev,return 0 ; error: -atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); -if (bdev->pool.use_dma32) -atomic_long_sub (ttm->num_pages, &ttm_dma32_pages_allocated); +if (!(ttm->page_flags &TTM_PAGE_FLAG_SG )) { +atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); +if (bdev->pool.use_dma32) +atomic_long_sub (ttm->num_pages, + &ttm_dma32_pages_allocated); + }return ret; }EXPORT_SYMBOL (ttm_tt_populate);@@ -382,9 +388,12 @@ void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm)else ttm_pool_free (&bdev->pool, ttm); -atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); -if (bdev->pool.use_dma32) -atomic_long_sub (ttm->num_pages, &ttm_dma32_pages_allocated); +if (!(ttm->page_flags &TTM_PAGE_FLAG_SG )) { +atomic_long_sub (ttm->num_pages, &ttm_pages_allocated); +if (bdev->pool.use_dma32) +atomic_long_sub (ttm->num_pages, + &ttm_dma32_pages_allocated); + } ttm->page_flags &= ~TTM_PAGE_FLAG_PRIV_POPULATED ; }Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerPATCH 9/9 drm/amdgpu: Lock the attached dmabuf in unpopulate
In reply to Felix Kuehlingamdgpu_ttm_tt_unpopulate can be called during bo_destroy. The dmabuf->resv must not be held by the caller or dma_buf_detach will deadlock. This is probably not the right fix. I get a recursive lock warning with the reservation held in ttm_bo_release. Should unmap_attachment move to backend_unbind instead?
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +13 -0
@@ -1216,9 +1216,22 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,if (ttm->sg && gtt->gobj->import_attach) {struct dma_buf_attachment *attach; +bool locked; attach = gtt->gobj->import_attach; +/* FIXME: unpopulate can be called during bo_destroy. +* The dmabuf->resv must not be held by the caller or +* dma_buf_detach will deadlock. This is probably not +* the right fix. I get a recursive lock warning with the +* reservation held in ttm_bo_releas.. Should +* unmap_attachment move to backend_unbind instead? +*/ + locked =dma_resv_is_locked (attach->dmabuf->resv); +if (!locked) +dma_resv_lock (attach->dmabuf->resv,NULL );dma_buf_unmap_attachment (attach, ttm->sg,DMA_BIDIRECTIONAL ); +if (!locked) +dma_resv_unlock (attach->dmabuf->resv); ttm->sg =NULL ;return ; }
Signature · 6 lines
2.31.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 9/9] drm/amdgpu: Lock the attached dmabuf in unpopulate
Am 14.04.21 um 08:46 schrieb Felix Kuehling:
Quoted 5 lines
amdgpu_ttm_tt_unpopulatecan be called duringbo_destroy. Thedmabuf->resvmust not be held by the caller ordma_buf_detachwill deadlock. This is probably not the right fix. I get a recursive lock warning with the reservation held inttm_bo_release. Shouldunmap_attachmentmove tobackend_unbindinstead?
Yes probably, but I'm really wondering if we should call unpopulate without holding the reservation lock.
Christian.
Quoted 23 lines
Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +7
-0@@ -1216,9 +1216,22 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev,if (ttm->sg && gtt->gobj->import_attach) {struct dma_buf_attachment *attach; +bool locked; attach = gtt->gobj->import_attach; +/* FIXME: unpopulate can be called during bo_destroy. +* The dmabuf->resv must not be held by the caller or +* dma_buf_detach will deadlock. This is probably not +* the right fix. I get a recursive lock warning with the +* reservation held in ttm_bo_releas.. Should +* unmap_attachment move to backend_unbind instead?
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, · line 1237
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6
-0+*/ + locked =dma_resv_is_locked (attach->dmabuf->resv); +if (!locked) +dma_resv_lock (attach->dmabuf->resv,NULL );dma_buf_unmap_attachment (attach, ttm->sg,DMA_BIDIRECTIONAL ); +if (!locked) +dma_resv_unlock (attach->dmabuf->resv); ttm->sg =NULL ;return ; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerRe: [PATCH 9/9] drm/amdgpu: Lock the attached dmabuf in unpopulate
Am 2021-04-14 um 3:33 a.m. schrieb Christian König:
Quoted 10 lines
Am 14.04.21 um 08:46 schrieb Felix Kuehling:
Quoted 6 lines
amdgpu_ttm_tt_unpopulatecan be called duringbo_destroy. Thedmabuf->resv
must not be held by the caller ordma_buf_detachwill deadlock. This is probably not the right fix. I get a recursive lock warning with the reservation held inttm_bo_release. Shouldunmap_attachmentmove tobackend_unbindinstead?Yes probably, but I'm really wondering if we should call unpopulate without holding the reservation lock.
There is an error handling code path in ttm_tt_populate that calls unpopulate. I believe that has to be holding the reservation lock. The other cases (destroy and swapout) do not hold the lock, AIUI.
Regards,
Felix
Quoted 28 lines
Christian.
Quoted 25 lines
Signed-off-by Felix Kuehling <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 13 +++++++++++++1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9
-0@@ -1216,9 +1216,22 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, if (ttm->sg && gtt->gobj->import_attach) { struct dma_buf_attachment *attach; + bool locked; attach = gtt->gobj->import_attach; + /* FIXME: unpopulate can be called during bo_destroy. + * The dmabuf->resv must not be held by the caller or + * dma_buf_detach will deadlock. This is probably not + * the right fix. I get a recursive lock warning with the + * reservation held in ttm_bo_releas.. Should + * unmap_attachment move to backend_unbind instead? + */ + locked = dma_resv_is_locked(attach->dmabuf->resv);
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, · line 1237
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4
-0+ if (!locked) + dma_resv_lock(attach->dmabuf->resv, NULL); dma_buf_unmap_attachment(attach, ttm->sg, DMA_BIDIRECTIONAL); + if (!locked) + dma_resv_unlock(attach->dmabuf->resv); ttm->sg = NULL; return; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerRe: [PATCH 9/9] drm/amdgpu: Lock the attached dmabuf in unpopulate
Am 14.04.21 um 17:15 schrieb Felix Kuehling:
Quoted 8 lines
Am 2021-04-14 um 3:33 a.m. schrieb Christian König:
Quoted 7 lines
Am 14.04.21 um 08:46 schrieb Felix Kuehling:
Quoted 6 lines
amdgpu_ttm_tt_unpopulatecan be called duringbo_destroy. Thedmabuf->resv
must not be held by the caller ordma_buf_detachwill deadlock. This is probably not the right fix. I get a recursive lock warning with the reservation held inttm_bo_release. Shouldunmap_attachmentmove tobackend_unbindinstead?
Quoted 4 lines
Quoted 2 lines
Yes probably, but I'm really wondering if we should call unpopulate without holding the reservation lock.
There is an error handling code path in
ttm_tt_populatethat calls unpopulate.
That should be harmless. For populating the page array we need the same lock as for unpopulating it.
Quoted 1 line
I believe that has to be holding the reservation lock.
Correct, yes.
Quoted 1 line
The other cases (destroy and swapout) do not hold the lock, AIUI.
That's not correct. See ttm_bo_release() for example:
...
if (!dma_resv_test_signaled_rcu(bo->base.resv, true) || !dma_resv_trylock(bo->base.resv)) {
...
We intentionally lock the reservation object here or put it on the delayed delete list because dropping the tt object without holding the lock is illegal for multiple reasons.
If you run into an unpopulate which doesn't hold the lock then I really need that backtrace because we are running into a much larger bug here.
Thanks,
Christian.
Quoted 31 lines
Regards,
FelixQuoted 26 lines
Christian.
Quoted 24 lines
Signed-off-by Felix Kuehling <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +9
-0@@ -1216,9 +1216,22 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, if (ttm->sg && gtt->gobj->import_attach) { struct dma_buf_attachment *attach; + bool locked; attach = gtt->gobj->import_attach; + /* FIXME: unpopulate can be called during bo_destroy. + * The dmabuf->resv must not be held by the caller or + * dma_buf_detach will deadlock. This is probably not + * the right fix. I get a recursive lock warning with the + * reservation held in ttm_bo_releas.. Should + * unmap_attachment move to backend_unbind instead? + */ + locked = dma_resv_is_locked(attach->dmabuf->resv);
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, · line 1237
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4
-0+ if (!locked) + dma_resv_lock(attach->dmabuf->resv, NULL); dma_buf_unmap_attachment(attach, ttm->sg, DMA_BIDIRECTIONAL); + if (!locked) + dma_resv_unlock(attach->dmabuf->resv); ttm->sg = NULL; return; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Felix Kuehling
maintainerRe: [PATCH 9/9] drm/amdgpu: Lock the attached dmabuf in unpopulate
Am 2021-04-15 um 3:41 a.m. schrieb Christian König:
Quoted 28 lines
Am 14.04.21 um 17:15 schrieb Felix Kuehling:
Quoted 9 lines
Am 2021-04-14 um 3:33 a.m. schrieb Christian König:
Quoted 8 lines
Am 14.04.21 um 08:46 schrieb Felix Kuehling:
Quoted 7 lines
amdgpu_ttm_tt_unpopulatecan be called duringbo_destroy. Thedmabuf->resv
must not be held by the caller ordma_buf_detachwill deadlock. This is
probably not the right fix. I get a recursive lock warning with the reservation held inttm_bo_release. Shouldunmap_attachmentmove tobackend_unbindinstead?Quoted 4 lines
Quoted 2 lines
Yes probably, but I'm really wondering if we should call unpopulate without holding the reservation lock.
There is an error handling code path in
ttm_tt_populatethat calls unpopulate.That should be harmless. For populating the page array we need the same lock as for unpopulating it.
Quoted 1 line
I believe that has to be holding the reservation lock.
Correct, yes.
Quoted 1 line
The other cases (destroy and swapout) do not hold the lock, AIUI.
That's not correct. See
ttm_bo_release()for example:
Quoted 8 lines
...
if (!dma_resv_test_signaled_rcu(bo->base.resv, true) || !dma_resv_trylock(bo->base.resv)) {
...We intentionally lock the reservation object here or put it on the delayed delete list because dropping the tt object without holding the lock is illegal for multiple reasons.
I think this is because I manually individualized the reservation in patch 4. Without that I was running into different problems (probably need to dig a bit more to understand what's happening there). So the lock held by release is not the same as the lock of the original dmabuf.
Regards,
Felix
Quoted 41 lines
If you run into an unpopulate which doesn't hold the lock then I really need that backtrace because we are running into a much larger bug here.
Thanks,
Christian.Quoted 32 lines
Regards,
FelixQuoted 27 lines
Christian.
Quoted 25 lines
Signed-off-by Felix Kuehling <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 13 +++++++++++++1 file changed, 13 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +10
-0@@ -1216,9 +1216,22 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, if (ttm->sg && gtt->gobj->import_attach) { struct dma_buf_attachment *attach; + bool locked; attach = gtt->gobj->import_attach; + /* FIXME: unpopulate can be called during bo_destroy. + * The dmabuf->resv must not be held by the caller or + * dma_buf_detach will deadlock. This is probably not + * the right fix. I get a recursive lock warning with the + * reservation held in ttm_bo_releas.. Should + * unmap_attachment move to backend_unbind instead? + */ + locked = dma_resv_is_locked(attach->dmabuf->resv); + if (!locked)
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, · line 1237
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-0+ dma_resv_lock(attach->dmabuf->resv, NULL); dma_buf_unmap_attachment(attach, ttm->sg,DMA_BIDIRECTIONAL ); + if (!locked) + dma_resv_unlock(attach->dmabuf->resv); ttm->sg = NULL; return; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Felix Kuehling
maintainerSorry for the spam. I mis-spelled the amd-gfx list on the To: line of this patch series. Please ignore this and see the patch series I sent a minute later.
Regards,
Felix
Quoted 21 lines · Felix Kuehling
This patch series fixes DMA-mappings of system memory (GTT and userptr) for KFD running on multi-GPU systems with IOMMU enabled. One SG-BO per GPU is needed to maintain the DMA mappings of each BO.
I ran into some reservation issues when unmapping or freeing DMA-buf imports. There are a few FIXME comments in this patch series where I'm hoping for some expert advice. Patches 8 and 9 are some related fixes in TTM and
amdgpu_ttm. I'm pretty sure patch 9 is not the right way to do this.Felix Kuehling (9):
drm/amdgpu: Renamekfd_bo_va_listtokfd_mem_attachmentdrm/amdgpu: Keep a bo-reference per-attachment drm/amdgpu: Simplify AQL queue mapping drm/amdgpu: Add multi-GPU DMA mapping helpers drm/amdgpu: DMA map/unmap when updating GPU mappings drm/amdgpu: Movekfd_mem_attachoutside reservation drm/amdgpu: Add DMA mapping of GTT BOs
drm/ttm: Don't count pages in SG BOs againstpages_limitdrm/amdgpu: Lock the attached dmabuf in unpopulate
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 18 +- .../gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 535 ++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 13 + drivers/gpu/drm/ttm/ttm_tt.c | 27 +- 4 files changed, 420 insertions(+), 173 deletions(-)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel