drm/amdkfd: Add VRAM accounting for SVM migration
Do VRAM accounting when doing migrations to vram to make sure there is enough available VRAM and migrating to VRAM doesn't evict other possible non-unified memory BOs. If migrating to VRAM fails, driver can fall back to using system memory seamlessly. Signed-off-by: Mukul Joshi <mukul.joshi@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
fa7bb2cac0
commit
63335b383a
@ -509,10 +509,19 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,
|
||||
start = start_mgr << PAGE_SHIFT;
|
||||
end = (last_mgr + 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 = (start_mgr - prange->start + prange->offset) << PAGE_SHIFT;
|
||||
|
||||
@ -545,6 +554,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;
|
||||
}
|
||||
|
||||
|
@ -3426,7 +3426,7 @@ svm_range_trigger_migration(struct mm_struct *mm, struct svm_range *prange,
|
||||
mm, KFD_MIGRATE_TRIGGER_PREFETCH);
|
||||
*migrated = !r;
|
||||
|
||||
return r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int svm_range_schedule_evict_svm_bo(struct amdgpu_amdkfd_fence *fence)
|
||||
|
Loading…
x
Reference in New Issue
Block a user