summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2023-04-07 04:11:43 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2023-04-07 04:11:43 +0000
commit268edc6c83ad0c54883236b46ef10aad2e5a9a07 (patch)
tree995054a54cbe1e74aaf9d7dc9ef02228f39ecc2c /sys
parentbd7a936bdf2203f99a4af0c1b06376807a0e7ebf (diff)
drm/amdkfd: Get prange->offset after svm_range_vram_node_new
From Xiaogang Chen d0386bd84e6d81990ef22e10657d5a5d9c209763 in linux-6.1.y/6.1.23 8eeddc0d4200762063e1c66b9cc63afa7b24ebf0 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c b/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c
index fad500dd224..88bf6221d4b 100644
--- a/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c
+++ b/sys/dev/pci/drm/amd/amdkfd/kfd_migrate.c
@@ -311,12 +311,6 @@ svm_migrate_copy_to_vram(struct amdgpu_device *adev, struct svm_range *prange,
src = scratch;
dst = (uint64_t *)(scratch + npages);
- r = svm_range_vram_node_new(adev, prange, true);
- if (r) {
- dev_dbg(adev->dev, "fail %d to alloc vram\n", r);
- goto out;
- }
-
amdgpu_res_first(prange->ttm_res, ttm_res_offset,
npages << PAGE_SHIFT, &cursor);
for (i = j = 0; i < npages; i++) {
@@ -397,7 +391,7 @@ out_free_vram_pages:
migrate->dst[i + 3] = 0;
}
#endif
-out:
+
return r;
}
@@ -526,6 +520,12 @@ 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 = svm_range_vram_node_new(adev, prange, true);
+ if (r) {
+ dev_dbg(adev->dev, "fail %ld to alloc vram\n", r);
+ return r;
+ }
ttm_res_offset = prange->offset << PAGE_SHIFT;
for (addr = start; addr < end;) {
@@ -549,6 +549,8 @@ svm_migrate_ram_to_vram(struct svm_range *prange, uint32_t best_loc,
if (cpages)
prange->actual_loc = best_loc;
+ else
+ svm_range_vram_node_free(prange);
return r < 0 ? r : 0;
}