Skip to content

Commit 795c38e

Browse files
fxkamdAlexandru Tudor
authored andcommitted
drm/amdkfd: Don't trigger evictions unmapping dmabuf attachments
Don't move DMABuf attachments for PCIe P2P mappings to the SYSTEM domain when unmapping. This avoids triggering eviction fences unnecessarily. Instead do the move to SYSTEM and back to GTT when mapping these attachments to ensure the SG table gets updated after evictions. This may still trigger unnecessary evictions if user mode unmaps and remaps the same BO. However, this is unlikely in real applications. Signed-off-by: Felix Kuehling <[email protected]> Reviewed-by: Eric Huang <[email protected]> (cherry picked from commit b52649cf41d0c2ac98a835a518d36a03cdaf1087) Change-Id: I1c9cc6c3332e18a90484215d901d6b24f8668cf3
1 parent a3940ea commit 795c38e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,12 @@ kfd_mem_dmamap_dmabuf(struct kfd_mem_attachment *attachment)
527527
{
528528
struct ttm_operation_ctx ctx = {.interruptible = true};
529529
struct amdgpu_bo *bo = attachment->bo_va->base.bo;
530+
int ret;
531+
532+
amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
533+
ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
534+
if (ret)
535+
return ret;
530536

531537
amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_GTT);
532538
return ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
@@ -659,11 +665,10 @@ kfd_mem_dmaunmap_userptr(struct kgd_mem *mem,
659665
static void
660666
kfd_mem_dmaunmap_dmabuf(struct kfd_mem_attachment *attachment)
661667
{
662-
struct ttm_operation_ctx ctx = {.interruptible = true};
663-
struct amdgpu_bo *bo = attachment->bo_va->base.bo;
664-
665-
amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
666-
ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
668+
/* This is a no-op. We don't want to trigger eviction fences when
669+
* unmapping DMABufs. Therefore the invalidation (moving to system
670+
* domain) is done in kfd_mem_dmamap_dmabuf.
671+
*/
667672
}
668673

669674
/**

0 commit comments

Comments
 (0)