aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1584-drm-amdgpu-Fix-unbalanced-restore-errors.patch
blob: 19d5a98a2c126a23e6c54fd0aeeae0c5b7be4902 (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
From aad37c9aa53203814399824d65f7de1059e442ee Mon Sep 17 00:00:00 2001
From: Felix Kuehling <Felix.Kuehling@amd.com>
Date: Fri, 3 Feb 2017 18:01:25 -0500
Subject: [PATCH 1584/4131] drm/amdgpu: Fix unbalanced restore errors

When a restore is canceled by a subsequent eviction while the restore
worker was unlocked in update_user_pages, don't update mem->evicted to 0.

Bug: SWDEV-112268
Change-Id: I9d3d4b6dc50179a16042558060f51887bea8f15c
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c       |  4 ++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 17 +++++++++--------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
index a2d1b55..b613ce0 100755
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
@@ -282,8 +282,8 @@ static void amdgdu_amdkfd_restore_mem_worker(struct work_struct *work)
 	 * was scheduled.
 	 */
 	if (mem->evicted == 1) {
-		amdgpu_amdkfd_gpuvm_restore_mem(mem, mm);
-		mem->evicted = 0;
+		if (amdgpu_amdkfd_gpuvm_restore_mem(mem, mm) != -EBUSY)
+			mem->evicted = 0;
 	}
 
 	mem->mm = NULL;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 8d05564..3ec1ff1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1936,14 +1936,15 @@ int amdgpu_amdkfd_gpuvm_restore_mem(struct kgd_mem *mem, struct mm_struct *mm)
 			pr_err("get_user_pages failed. Probably userptr is freed. %d\n",
 			       ret);
 		}
-	}
-
-	/* update_user_pages drops the lock briefly. Check if someone
-	 * else evicted or restored the buffer in the mean time */
-	if (mem->evicted != 1) {
-		if (have_pages)
-			unreserve_bo_and_vms(&ctx, false);
-		return 0;
+		/* update_user_pages drops the lock briefly. Check if
+		 * someone else evicted or restored the buffer in the
+		 * mean time. Return -EBUSY to let the caller know.
+		 */
+		if (mem->evicted != 1) {
+			if (have_pages)
+				unreserve_bo_and_vms(&ctx, false);
+			return -EBUSY;
+		}
 	}
 
 	if (have_pages) {
-- 
2.7.4