diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-06-15 03:43:45 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2024-06-15 03:43:45 +0000 |
commit | 3b2bb3649116a7d9ed6cad3642104719c88b11b6 (patch) | |
tree | b7bf7b4bbe09a3df1a4889995bd6f7400ba76d7d /sys/dev/pci/drm/amd/amdkfd | |
parent | 0fcb07c9ee2764948a083c22878db7e082c8c366 (diff) |
drm/amdkfd: Add VRAM accounting for SVM migration
From Mukul Joshi
bdbb7611dd2ebb6b6035c8c039ef931452af8f41 in linux-6.6.y/6.6.33
1e214f7faaf5d842754cd5cfcd76308bfedab3b5 in mainline linux
Diffstat (limited to 'sys/dev/pci/drm/amd/amdkfd')
-rw-r--r-- | sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c | 16 | ||||
-rw-r--r-- | sys/dev/pci/drm/amd/amdkfd/kfd_svm.c | 2 |
2 files changed, 16 insertions, 2 deletions
diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c b/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c index 659313648b2..3263b5fa182 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c @@ -516,10 +516,19 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc, start = prange->start << PAGE_SHIFT; end = (prange->last + 1) << PAGE_SHIFT; + r = amdgpu_amdkfd_reserve_mem_limit(node->adev, + prange->npages * PAGE_SIZE, + KFD_IOC_ALLOC_MEM_FLAGS_VRAM, + node->xcp ? node->xcp->id : 0); + if (r) { + dev_dbg(node->adev->dev, "failed to reserve VRAM, r: %ld\n", r); + return -ENOSPC; + } + r = svm_range_vram_node_new(node, prange, true); if (r) { dev_dbg(node->adev->dev, "fail %ld to alloc vram\n", r); - return r; + goto out; } ttm_res_offset = prange->offset << PAGE_SHIFT; @@ -549,6 +558,11 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc, svm_range_vram_node_free(prange); } +out: + amdgpu_amdkfd_unreserve_mem_limit(node->adev, + prange->npages * PAGE_SIZE, + KFD_IOC_ALLOC_MEM_FLAGS_VRAM, + node->xcp ? node->xcp->id : 0); return r < 0 ? r : 0; } diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c index 87e9ca65e58..ce76d455499 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c @@ -3416,7 +3416,7 @@ svm_range_trigger_migration(struct mm_struct *mm, struct svm_range *prange, r = svm_migrate_to_vram(prange, best_loc, mm, KFD_MIGRATE_TRIGGER_PREFETCH); *migrated = !r; - return r; + return 0; } int svm_range_schedule_evict_svm_bo(struct amdgpu_amdkfd_fence *fence) |