aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1641-drm-amdgpu-Simplify-process-termination-in-amdgpu_tt.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1641-drm-amdgpu-Simplify-process-termination-in-amdgpu_tt.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1641-drm-amdgpu-Simplify-process-termination-in-amdgpu_tt.patch116
1 files changed, 116 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1641-drm-amdgpu-Simplify-process-termination-in-amdgpu_tt.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1641-drm-amdgpu-Simplify-process-termination-in-amdgpu_tt.patch
new file mode 100644
index 00000000..b901640e
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/1641-drm-amdgpu-Simplify-process-termination-in-amdgpu_tt.patch
@@ -0,0 +1,116 @@
+From 95d5c092f00e9a020a951392d07a846aea6193a0 Mon Sep 17 00:00:00 2001
+From: Felix Kuehling <Felix.Kuehling@amd.com>
+Date: Tue, 21 Mar 2017 12:05:18 -0400
+Subject: [PATCH 1641/4131] drm/amdgpu: Simplify process termination in
+ amdgpu_ttm_tt_get_user_pages
+
+Most of this is taken care of by the new userptr restore worker by
+holding task and mm references when calling amdgpu_ttm_tt_get_user_pages.
+
+Change-Id: I0075e5ff997b7bc65f164e6d8bf84d43eb734092
+Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
+---
+ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 33 ++++++++++-----------------------
+ 1 file changed, 10 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+index c4b1c9d..af526a8 100644
+--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+@@ -666,8 +666,7 @@ struct amdgpu_ttm_tt {
+ struct amdgpu_device *adev;
+ u64 offset;
+ uint64_t userptr;
+- struct mm_struct *usermm;
+- struct pid *userpid;
++ struct task_struct *usertask;
+ uint32_t userflags;
+ spinlock_t guptasklock;
+ struct list_head guptasks;
+@@ -679,11 +678,14 @@ struct amdgpu_ttm_tt {
+ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
+ {
+ struct amdgpu_ttm_tt *gtt = (void *)ttm;
++ struct mm_struct *mm = gtt->usertask->mm;
+ unsigned int flags = 0;
+ unsigned pinned = 0;
+- struct task_struct *usertask;
+ int r;
+
++ if (!mm) /* Happens during process shutdown */
++ return -ESRCH;
++
+ if (!(gtt->userflags & AMDGPU_GEM_USERPTR_READONLY))
+ flags |= FOLL_WRITE;
+
+@@ -693,22 +695,11 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
+ unsigned long end = gtt->userptr + ttm->num_pages * PAGE_SIZE;
+ struct vm_area_struct *vma;
+
+- vma = find_vma(gtt->usermm, gtt->userptr);
++ vma = find_vma(mm, gtt->userptr);
+ if (!vma || vma->vm_file || vma->vm_end < end)
+ return -EPERM;
+ }
+
+- if (!gtt->userpid)
+- return -EINVAL;
+- usertask = get_pid_task(gtt->userpid, PIDTYPE_PID);
+- if (!usertask)
+- return -ESRCH;
+- if (usertask->mm != gtt->usermm) {
+- /* Happens during process shutdown */
+- put_task_struct(usertask);
+- return -ESRCH;
+- }
+-
+ do {
+ unsigned num_pages = ttm->num_pages - pinned;
+ uint64_t userptr = gtt->userptr + pinned * PAGE_SIZE;
+@@ -733,12 +724,10 @@ int amdgpu_ttm_tt_get_user_pages(struct ttm_tt *ttm, struct page **pages)
+
+ } while (pinned < ttm->num_pages);
+
+- put_task_struct(usertask);
+ return 0;
+
+ release_pages:
+ release_pages(pages, pinned, 0);
+- put_task_struct(usertask);
+ return r;
+ }
+
+@@ -991,9 +980,6 @@ static void amdgpu_ttm_backend_destroy(struct ttm_tt *ttm)
+ {
+ struct amdgpu_ttm_tt *gtt = (void *)ttm;
+
+- if (gtt->userpid)
+- put_pid(gtt->userpid);
+-
+ ttm_dma_tt_fini(&gtt->ttm);
+ kfree(gtt);
+ }
+@@ -1095,8 +1081,6 @@ int amdgpu_ttm_tt_set_userptr(struct ttm_tt *ttm, uint64_t addr,
+
+ gtt->userptr = addr;
+ gtt->usertask = current->group_leader;
+- gtt->usermm = current->mm;
+- gtt->userpid = get_task_pid(current->group_leader, PIDTYPE_PID);
+ gtt->userflags = flags;
+ spin_lock_init(&gtt->guptasklock);
+ INIT_LIST_HEAD(&gtt->guptasks);
+@@ -1113,7 +1097,10 @@ struct mm_struct *amdgpu_ttm_tt_get_usermm(struct ttm_tt *ttm)
+ if (gtt == NULL)
+ return NULL;
+
+- return gtt->usermm;
++ if (gtt->usertask == NULL)
++ return NULL;
++
++ return gtt->usertask->mm;
+ }
+
+ bool amdgpu_ttm_tt_affect_userptr(struct ttm_tt *ttm, unsigned long start,
+--
+2.7.4
+