1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
From 07e792058452e015c53e64780453af18060f9c62 Mon Sep 17 00:00:00 2001
From: Yong Zhao <yong.zhao@amd.com>
Date: Thu, 21 Apr 2016 17:02:08 -0400
Subject: [PATCH 1400/4131] Fix an error handling problem
Change-Id: Ifd7c1d591b6ce542f0ced7a7db8afff18e02da8a
---
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 0db8980..8ec4859 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -68,7 +68,8 @@ static bool check_if_add_bo_to_vm(struct amdgpu_vm *avm,
}
static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
- struct amdgpu_vm *avm, bool is_aql)
+ struct amdgpu_vm *avm, bool is_aql,
+ struct kfd_bo_va_list **p_bo_va_entry)
{
int ret;
struct kfd_bo_va_list *bo_va_entry;
@@ -121,6 +122,9 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
bo_va_entry->is_mapped = false;
list_add(&bo_va_entry->bo_list, list_bo_va);
+ if (p_bo_va_entry)
+ *p_bo_va_entry = bo_va_entry;
+
return 0;
err_vmsetaddr:
@@ -823,6 +827,8 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
uint32_t domain;
struct kfd_bo_va_list *entry;
struct bo_vm_reservation_context ctx;
+ struct kfd_bo_va_list *bo_va_entry = NULL;
+ struct kfd_bo_va_list *bo_va_entry_aql = NULL;
BUG_ON(kgd == NULL);
BUG_ON(mem == NULL);
@@ -847,14 +853,15 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
if (check_if_add_bo_to_vm((struct amdgpu_vm *)vm, mem)) {
pr_debug("amdkfd: add new BO_VA to list 0x%llx\n",
mem->data2.va);
- ret = add_bo_to_vm(adev, mem, (struct amdgpu_vm *)vm, false);
+ ret = add_bo_to_vm(adev, mem, (struct amdgpu_vm *)vm, false,
+ &bo_va_entry);
if (ret != 0)
goto add_bo_to_vm_failed;
if (mem->data2.aql_queue) {
ret = add_bo_to_vm(adev, mem, (struct amdgpu_vm *)vm,
- true);
+ true, &bo_va_entry_aql);
if (ret != 0)
- goto add_bo_to_vm_failed;
+ goto add_bo_to_vm_failed_aql;
}
}
@@ -914,6 +921,11 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
pin_bo_failed:
quiesce_failed:
update_user_pages_failed:
+ if (bo_va_entry_aql)
+ remove_bo_from_vm(adev, bo_va_entry_aql);
+add_bo_to_vm_failed_aql:
+ if (bo_va_entry)
+ remove_bo_from_vm(adev, bo_va_entry);
add_bo_to_vm_failed:
unreserve_bo_and_vms(&ctx, false);
bo_reserve_failed:
@@ -1391,7 +1403,7 @@ int amdgpu_amdkfd_gpuvm_import_dmabuf(struct kgd_dev *kgd, int dma_buf_fd,
AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT;
(*mem)->data2.mapped_to_gpu_memory = 0;
- r = add_bo_to_vm(adev, *mem, vm, false);
+ r = add_bo_to_vm(adev, *mem, vm, false, NULL);
if (r) {
amdgpu_bo_unref(&bo);
--
2.7.4
|