aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1398-Reserve-PD-BO-along-with-BO-together-when-add_bo_to_.patch
blob: 083084f37f3f9022cbc3c74b37391347e6b11cac (plain)
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
87
88
89
90
From 4cc4e9bbef35849571e199565cde3cad8100be9e Mon Sep 17 00:00:00 2001
From: Yong Zhao <yong.zhao@amd.com>
Date: Thu, 21 Apr 2016 14:42:57 -0400
Subject: [PATCH 1398/4131] Reserve PD BO along with BO together when
 add_bo_to_vm()

Change-Id: Icd82c9a2f6d912a6767f636bf4207e43b6d8f17a
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 4f7219a..e1e83b4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -91,8 +91,6 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
 	pr_debug("amdkfd: adding bo_va to bo %p and va 0x%llx id 0x%x\n",
 			bo, va, adev->dev->id);
 
-	amdgpu_bo_reserve(bo, true);
-
 	/* Add BO to VM internal data structures*/
 	bo_va_entry->bo_va = amdgpu_vm_bo_add(adev, avm, bo);
 	if (bo_va_entry->bo_va == NULL) {
@@ -119,8 +117,6 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
 		goto err_vmsetaddr;
 	}
 
-	amdgpu_bo_unreserve(bo);
-
 	bo_va_entry->kgd_dev = (void *)adev;
 	bo_va_entry->is_mapped = false;
 	list_add(&bo_va_entry->bo_list, list_bo_va);
@@ -134,7 +130,6 @@ static int add_bo_to_vm(struct amdgpu_device *adev, struct kgd_mem *mem,
 	 * we don't call it here. That can wait until the next time
 	 * the page tables are updated for a map or unmap. */
 err_vmadd:
-	amdgpu_bo_unreserve(bo);
 	kfree(bo_va_entry);
 	return ret;
 }
@@ -841,6 +836,10 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 	pr_debug("amdgpu: try to map VA 0x%llx domain %d\n",
 			mem->data2.va, domain);
 
+	ret = reserve_bo_and_vms(mem, vm, false, &ctx);
+	if (unlikely(ret != 0))
+		goto bo_reserve_failed;
+
 	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);
@@ -856,10 +855,6 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 	}
 
 	if (!mem->data2.evicted) {
-		ret = reserve_bo_and_vms(mem, vm, false, &ctx);
-		if (unlikely(ret != 0))
-			goto bo_reserve_failed;
-
 		ret = update_user_pages(mem, current->mm, &ctx);
 		if (ret != 0)
 			goto update_user_pages_failed;
@@ -905,8 +900,8 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 		}
 	}
 
-	if (!mem->data2.evicted)
-		unreserve_bo_and_vms(&ctx, true);
+	unreserve_bo_and_vms(&ctx, true);
+
 	mutex_unlock(&mem->data2.lock);
 	return 0;
 
@@ -915,10 +910,9 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 pin_bo_failed:
 quiesce_failed:
 update_user_pages_failed:
-	if (!mem->data2.evicted)
-		unreserve_bo_and_vms(&ctx, false);
-bo_reserve_failed:
 add_bo_to_vm_failed:
+	unreserve_bo_and_vms(&ctx, false);
+bo_reserve_failed:
 	mutex_unlock(&mem->data2.lock);
 	return ret;
 }
-- 
2.7.4