aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1606-amdkfd-Fix-a-kernel-crash-bug-when-memory-eviction-i.patch
blob: 8f227431e783536b63ae1881164e9674f34e230b (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
From 03d898fce90852e4a6667662f84fd82a1d1cb852 Mon Sep 17 00:00:00 2001
From: Yong Zhao <Yong.Zhao@amd.com>
Date: Fri, 3 Mar 2017 18:41:38 -0500
Subject: [PATCH 1606/4131] amdkfd: Fix a kernel crash bug when memory eviction
 is triggered

The bug was accidentally introduced when rebasing commits from
kernel 4.6 to 4.9.

Change-Id: I9f5a772e9e4e9b1f330361afddda3be396e5192a
Signed-off-by: Yong Zhao <Yong.Zhao@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 31 +++++++++---------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 294482f..9a26cff 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -2135,7 +2135,6 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 				    &pd_bo_list[i]);
 		i++;
 	}
-	mutex_unlock(&process_info->lock);
 
 	/* Needed to splicing and cutting the lists */
 	last_pd_bo_entry = list_last_entry(&ctx.list,
@@ -2143,7 +2142,6 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 					   tv.head);
 
 	/* Reserve all BOs and page tables/directory. */
-	mutex_lock(&process_info->lock);
 	list_splice_init(&ctx.list, &process_info->kfd_bo_list);
 	ret = ttm_eu_reserve_buffers(&ctx.ticket, &process_info->kfd_bo_list,
 				     false, &duplicate_save);
@@ -2176,30 +2174,23 @@ int amdgpu_amdkfd_gpuvm_restore_process_bos(void *info)
 			goto validate_map_fail;
 		}
 	}
-        /* This isn't used for PTs any more, but can there be other
-	 * duplicates? */
-	WARN_ONCE(!list_empty(&ctx.duplicates), "Duplicates not empty");
-	list_for_each_entry(entry, &ctx.duplicates, tv.head) {
-		struct amdgpu_bo *bo = entry->robj;
 
-		ret = amdgpu_amdkfd_bo_validate(bo, bo->prefered_domains,
-						false);
+	param.domain = AMDGPU_GEM_DOMAIN_VRAM;
+	param.wait = false;
+
+	/* Validate PTs*/
+	list_for_each_entry(peer_vm, &process_info->vm_list_head,
+			vm_list_node) {
+		adev = amdgpu_ttm_adev(peer_vm->base.page_directory->tbo.bdev);
+		ret = amdgpu_vm_validate_pt_bos(adev, &peer_vm->base,
+				amdgpu_amdkfd_validate, &param);
 		if (ret) {
 			pr_debug("Memory eviction: Validate PTs failed. Try again\n");
 			goto validate_map_fail;
 		}
+		peer_vm->base.last_eviction_counter =
+				atomic64_read(&adev->num_evictions);
 	}
-	param.domain = AMDGPU_GEM_DOMAIN_VRAM;
-	param.wait = false;
-	adev = amdgpu_ttm_adev(peer_vm->base.page_directory->tbo.bdev);
-	ret = amdgpu_vm_validate_pt_bos(adev, &peer_vm->base,
-					amdgpu_amdkfd_validate, &param);
-	if (ret) {
-		pr_debug("Memory eviction: Validate failed. Try again\n");
-		goto validate_map_fail;
-	}
-	peer_vm->base.last_eviction_counter =
-		atomic64_read(&adev->num_evictions);
 
 	/* Wait for PD/PTs validate to finish and attach eviction fence.
 	 * PD/PT share the same reservation object
-- 
2.7.4