aboutsummaryrefslogtreecommitdiffstats
path: root/meta-v1000/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch
blob: ba405a66ed6d1944219e06145ac0ff25976a3fb2 (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
From 7d54d5964d54bfb8e788d80c291d554b4bf2cf8a Mon Sep 17 00:00:00 2001
From: Yong Zhao <yong.zhao@amd.com>
Date: Fri, 16 Sep 2016 17:55:58 -0400
Subject: [PATCH 1506/4131] drm/amdkfd: Fix ttm warnings when doing fork with
 BOs on DGPU

When running kfdtest, we saw floods of ttm warning messages originating
from ttm_bo_vm_open(), which is only triggered when doing fork() with
BOs on DGPU. KFD relies on amdgpu to allocate BOs, and each BO is
associated with corresponding amdgpu dev by bo->bdev->dev_mapping.
When mapping BOs on /dev/kfd, vma->vm_file->f_mapping of /dev/kfd is
used. Those two mappings are apparently different, and they could not
be reconciled because of the one to many mapping between kfd and amdgpu
devices.

Therefore, we skip the check for KFD BOs by overwriting the open
function pointer in amdgpu_ttm_vm_ops to avoid directly making changes
in ttm.

Fix BUG: SWDEV-101844

Change-Id: I26c64c5f1580aefb5ecc99fc7d2fe8397fd6e246
Signed-off-by: Yong Zhao <yong.zhao@amd.com>
Signed-off-by: kalyan alle <kalyan.alle@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 50d1d55..512207e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1722,6 +1722,25 @@ static int amdgpu_ttm_vm_access(struct vm_area_struct *vma, unsigned long addr,
         return len;
 }
 
+/* This function is a tweak variance of ttm_bo_vm_open() just to avoid the
+ * warning message when fork() with KFD BOs on DGPU.
+ */
+static void amdgpu_ttm_vm_open(struct vm_area_struct *vma)
+{
+	struct ttm_buffer_object *bo =
+		(struct ttm_buffer_object *)vma->vm_private_data;
+	struct amdgpu_bo *abo = container_of(bo, struct amdgpu_bo, tbo);
+
+	/* Because vma->vm_file for /dev/kfd can not be associated with any
+	* ttm_bo_device due to the one to many mapping between kfd and
+	* amdgpu devices, for KFD BOs we should just skip the check.
+	*/
+	if (!abo->kfd_bo)
+		WARN_ON(bo->bdev->dev_mapping != vma->vm_file->f_mapping);
+
+	(void)ttm_bo_reference(bo);
+}
+
 int amdgpu_bo_mmap(struct file *filp, struct vm_area_struct *vma,
 		   struct ttm_bo_device *bdev)
 {
@@ -1735,6 +1754,7 @@ int amdgpu_bo_mmap(struct file *filp, struct vm_area_struct *vma,
 		ttm_vm_ops = vma->vm_ops;
 		amdgpu_ttm_vm_ops = *ttm_vm_ops;
 		amdgpu_ttm_vm_ops.access = &amdgpu_ttm_vm_access;
+		amdgpu_ttm_vm_ops.open = &amdgpu_ttm_vm_open;
 	}
 	vma->vm_ops = &amdgpu_ttm_vm_ops;
 
-- 
2.7.4