aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch
new file mode 100644
index 00000000..ba405a66
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1506-drm-amdkfd-Fix-ttm-warnings-when-doing-fork-with-BOs.patch
@@ -0,0 +1,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
+