aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.14.71/1638-drm-amdkfd-Enable-quiesce-resume_mm-of-multiple-kfd_.patch
blob: 9f39ecedffe1f2b834cf5551c1494e786fac07b1 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
From b517d9ab9a68af163b7467a143b78b464ce9dcb7 Mon Sep 17 00:00:00 2001
From: Felix Kuehling <Felix.Kuehling@amd.com>
Date: Tue, 21 Mar 2017 11:47:11 -0400
Subject: [PATCH 1638/4131] drm/amdkfd: Enable quiesce/resume_mm of multiple
 kfd_devs

If kfd_dev* passed to the quiesce_mm/resume_mm functions is NULL,
quiesce or resume all devices. This capability will be used by a
rewritten MMU-notifier.

Change-Id: Ifffd7083d6c4ebe1646bc4cd215b11d41dd0736d
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_device.c | 108 ++++++++++++++++----------------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index 1d10eed..0e95fb2 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -721,60 +721,6 @@ void kgd2kfd_interrupt(struct kfd_dev *kfd, const void *ih_ring_entry)
 	spin_unlock(&kfd->interrupt_lock);
 }
 
-int kgd2kfd_quiesce_mm(struct kfd_dev *kfd, struct mm_struct *mm)
-{
-	struct kfd_process *p;
-	struct kfd_process_device *pdd;
-	int r;
-
-	BUG_ON(kfd == NULL);
-	if (!kfd->init_complete)
-		return 0;
-
-	/* Because we are called from arbitrary context (workqueue) as opposed
-	 * to process context, kfd_process could attempt to exit while we are
-	 * running so the lookup function increments the process ref count.
-	 */
-	p = kfd_lookup_process_by_mm(mm);
-	if (!p)
-		return -ENODEV;
-
-	r = -ENODEV;
-	pdd = kfd_get_process_device_data(kfd, p);
-	if (pdd)
-		r = process_evict_queues(kfd->dqm, &pdd->qpd);
-
-	kfd_unref_process(p);
-	return r;
-}
-
-int kgd2kfd_resume_mm(struct kfd_dev *kfd, struct mm_struct *mm)
-{
-	struct kfd_process *p;
-	struct kfd_process_device *pdd;
-	int r;
-
-	BUG_ON(kfd == NULL);
-	if (!kfd->init_complete)
-		return 0;
-
-	/* Because we are called from arbitrary context (workqueue) as opposed
-	 * to process context, kfd_process could attempt to exit while we are
-	 * running so the lookup function increments the process ref count.
-	 */
-	p = kfd_lookup_process_by_mm(mm);
-	if (!p)
-		return -ENODEV;
-
-	r = -ENODEV;
-	pdd = kfd_get_process_device_data(kfd, p);
-	if (pdd)
-		r = process_restore_queues(kfd->dqm, &pdd->qpd);
-
-	kfd_unref_process(p);
-	return r;
-}
-
 /* quiesce_process_mm -
  *  Quiesce all user queues that belongs to given process p
  */
@@ -839,6 +785,60 @@ static int resume_process_mm(struct kfd_process *p)
 	return ret;
 }
 
+int kgd2kfd_quiesce_mm(struct kfd_dev *kfd, struct mm_struct *mm)
+{
+	struct kfd_process *p;
+	struct kfd_process_device *pdd;
+	int r;
+
+	/* Because we are called from arbitrary context (workqueue) as opposed
+	 * to process context, kfd_process could attempt to exit while we are
+	 * running so the lookup function increments the process ref count.
+	 */
+	p = kfd_lookup_process_by_mm(mm);
+	if (!p)
+		return -ENODEV;
+
+	if (kfd) {
+		r = -ENODEV;
+		pdd = kfd_get_process_device_data(kfd, p);
+		if (pdd)
+			r = process_evict_queues(kfd->dqm, &pdd->qpd);
+	} else {
+		r = quiesce_process_mm(p);
+	}
+
+	kfd_unref_process(p);
+	return r;
+}
+
+int kgd2kfd_resume_mm(struct kfd_dev *kfd, struct mm_struct *mm)
+{
+	struct kfd_process *p;
+	struct kfd_process_device *pdd;
+	int r;
+
+	/* Because we are called from arbitrary context (workqueue) as opposed
+	 * to process context, kfd_process could attempt to exit while we are
+	 * running so the lookup function increments the process ref count.
+	 */
+	p = kfd_lookup_process_by_mm(mm);
+	if (!p)
+		return -ENODEV;
+
+	if (kfd) {
+		r = -ENODEV;
+		pdd = kfd_get_process_device_data(kfd, p);
+		if (pdd)
+			r = process_restore_queues(kfd->dqm, &pdd->qpd);
+	} else {
+		r = resume_process_mm(p);
+	}
+
+	kfd_unref_process(p);
+	return r;
+}
+
 
 void kfd_restore_bo_worker(struct work_struct *work)
 {
-- 
2.7.4