aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/3286-drm-amdkfd-Fix-crash-in-unmap-to-gpu-while-PD-bo-evi.patch
blob: 44c03b3e0813734c10d339ab97f2754639ce4d1b (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
From 2b5a73cc4eb5b9359c010e73c741cc868be76a12 Mon Sep 17 00:00:00 2001
From: Philip Yang <Philip.Yang@amd.com>
Date: Tue, 23 Jan 2018 21:34:26 -0500
Subject: [PATCH 3286/4131] drm/amdkfd: Fix crash in unmap to gpu while PD bo
 evicted

PD and PT may be evicted during evict restore test, validate PD and
PT before accessing PD and PT in map and unmap memory to GPU path to
avoid WARNING and VMC page fault later.

Change-Id: I5b8c3e10383d2d4b515e23edc5f284bdbd620943
Signed-off-by: Philip Yang <Philip.Yang@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
index 2409b56..54d705a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
@@ -1302,6 +1302,10 @@ int amdgpu_amdkfd_gpuvm_map_memory_to_gpu(
 			if (ret != 0)
 				goto add_bo_to_vm_failed_aql;
 		}
+	} else {
+		ret = vm_validate_pt_pd_bos((struct amdkfd_vm *)vm);
+		if (unlikely(ret != 0))
+			goto add_bo_to_vm_failed;
 	}
 
 	if (mem->mapped_to_gpu_memory == 0 &&
@@ -1564,6 +1568,10 @@ int amdgpu_amdkfd_gpuvm_unmap_memory_from_gpu(
 	if (unlikely(ret != 0))
 		goto out;
 
+	ret = vm_validate_pt_pd_bos((struct amdkfd_vm *)vm);
+	if (unlikely(ret != 0))
+		goto unreserve_out;
+
 	pr_debug("Unmap VA 0x%llx - 0x%llx from vm %p\n",
 		mem->va,
 		mem->va + bo_size * (1 + mem->aql_queue),
-- 
2.7.4