mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
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:
committed by
Alex Deucher
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user