.. | .. |
---|
22 | 22 | * |
---|
23 | 23 | */ |
---|
24 | 24 | |
---|
25 | | -#include "../i915_selftest.h" |
---|
| 25 | +#include "gem/i915_gem_pm.h" |
---|
| 26 | +#include "gem/selftests/igt_gem_utils.h" |
---|
| 27 | +#include "gem/selftests/mock_context.h" |
---|
| 28 | +#include "gt/intel_gt.h" |
---|
26 | 29 | |
---|
| 30 | +#include "i915_selftest.h" |
---|
| 31 | + |
---|
| 32 | +#include "igt_flush_test.h" |
---|
27 | 33 | #include "lib_sw_fence.h" |
---|
28 | | -#include "mock_context.h" |
---|
29 | 34 | #include "mock_drm.h" |
---|
30 | 35 | #include "mock_gem_device.h" |
---|
31 | 36 | |
---|
32 | | -static int populate_ggtt(struct drm_i915_private *i915) |
---|
| 37 | +static void quirk_add(struct drm_i915_gem_object *obj, |
---|
| 38 | + struct list_head *objects) |
---|
| 39 | +{ |
---|
| 40 | + /* quirk is only for live tiled objects, use it to declare ownership */ |
---|
| 41 | + GEM_BUG_ON(obj->mm.quirked); |
---|
| 42 | + obj->mm.quirked = true; |
---|
| 43 | + list_add(&obj->st_link, objects); |
---|
| 44 | +} |
---|
| 45 | + |
---|
| 46 | +static int populate_ggtt(struct i915_ggtt *ggtt, struct list_head *objects) |
---|
33 | 47 | { |
---|
34 | 48 | struct drm_i915_gem_object *obj; |
---|
35 | | - u64 size; |
---|
| 49 | + unsigned long count; |
---|
36 | 50 | |
---|
37 | | - for (size = 0; |
---|
38 | | - size + I915_GTT_PAGE_SIZE <= i915->ggtt.vm.total; |
---|
39 | | - size += I915_GTT_PAGE_SIZE) { |
---|
| 51 | + count = 0; |
---|
| 52 | + do { |
---|
40 | 53 | struct i915_vma *vma; |
---|
41 | 54 | |
---|
42 | | - obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE); |
---|
| 55 | + obj = i915_gem_object_create_internal(ggtt->vm.i915, |
---|
| 56 | + I915_GTT_PAGE_SIZE); |
---|
43 | 57 | if (IS_ERR(obj)) |
---|
44 | 58 | return PTR_ERR(obj); |
---|
45 | 59 | |
---|
46 | 60 | vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0); |
---|
47 | | - if (IS_ERR(vma)) |
---|
| 61 | + if (IS_ERR(vma)) { |
---|
| 62 | + i915_gem_object_put(obj); |
---|
| 63 | + if (vma == ERR_PTR(-ENOSPC)) |
---|
| 64 | + break; |
---|
| 65 | + |
---|
48 | 66 | return PTR_ERR(vma); |
---|
49 | | - } |
---|
| 67 | + } |
---|
50 | 68 | |
---|
51 | | - if (!list_empty(&i915->mm.unbound_list)) { |
---|
52 | | - size = 0; |
---|
53 | | - list_for_each_entry(obj, &i915->mm.unbound_list, mm.link) |
---|
54 | | - size++; |
---|
| 69 | + quirk_add(obj, objects); |
---|
| 70 | + count++; |
---|
| 71 | + } while (1); |
---|
| 72 | + pr_debug("Filled GGTT with %lu pages [%llu total]\n", |
---|
| 73 | + count, ggtt->vm.total / PAGE_SIZE); |
---|
55 | 74 | |
---|
56 | | - pr_err("Found %lld objects unbound!\n", size); |
---|
57 | | - return -EINVAL; |
---|
58 | | - } |
---|
59 | | - |
---|
60 | | - if (list_empty(&i915->ggtt.vm.inactive_list)) { |
---|
| 75 | + if (list_empty(&ggtt->vm.bound_list)) { |
---|
61 | 76 | pr_err("No objects on the GGTT inactive list!\n"); |
---|
62 | 77 | return -EINVAL; |
---|
63 | 78 | } |
---|
.. | .. |
---|
65 | 80 | return 0; |
---|
66 | 81 | } |
---|
67 | 82 | |
---|
68 | | -static void unpin_ggtt(struct drm_i915_private *i915) |
---|
| 83 | +static void unpin_ggtt(struct i915_ggtt *ggtt) |
---|
69 | 84 | { |
---|
70 | 85 | struct i915_vma *vma; |
---|
71 | 86 | |
---|
72 | | - list_for_each_entry(vma, &i915->ggtt.vm.inactive_list, vm_link) |
---|
73 | | - i915_vma_unpin(vma); |
---|
| 87 | + list_for_each_entry(vma, &ggtt->vm.bound_list, vm_link) |
---|
| 88 | + if (vma->obj->mm.quirked) |
---|
| 89 | + i915_vma_unpin(vma); |
---|
74 | 90 | } |
---|
75 | 91 | |
---|
76 | | -static void cleanup_objects(struct drm_i915_private *i915) |
---|
| 92 | +static void cleanup_objects(struct i915_ggtt *ggtt, struct list_head *list) |
---|
77 | 93 | { |
---|
78 | 94 | struct drm_i915_gem_object *obj, *on; |
---|
79 | 95 | |
---|
80 | | - list_for_each_entry_safe(obj, on, &i915->mm.unbound_list, mm.link) |
---|
| 96 | + list_for_each_entry_safe(obj, on, list, st_link) { |
---|
| 97 | + GEM_BUG_ON(!obj->mm.quirked); |
---|
| 98 | + obj->mm.quirked = false; |
---|
81 | 99 | i915_gem_object_put(obj); |
---|
| 100 | + } |
---|
82 | 101 | |
---|
83 | | - list_for_each_entry_safe(obj, on, &i915->mm.bound_list, mm.link) |
---|
84 | | - i915_gem_object_put(obj); |
---|
85 | | - |
---|
86 | | - mutex_unlock(&i915->drm.struct_mutex); |
---|
87 | | - |
---|
88 | | - i915_gem_drain_freed_objects(i915); |
---|
89 | | - |
---|
90 | | - mutex_lock(&i915->drm.struct_mutex); |
---|
| 102 | + i915_gem_drain_freed_objects(ggtt->vm.i915); |
---|
91 | 103 | } |
---|
92 | 104 | |
---|
93 | 105 | static int igt_evict_something(void *arg) |
---|
94 | 106 | { |
---|
95 | | - struct drm_i915_private *i915 = arg; |
---|
96 | | - struct i915_ggtt *ggtt = &i915->ggtt; |
---|
| 107 | + struct intel_gt *gt = arg; |
---|
| 108 | + struct i915_ggtt *ggtt = gt->ggtt; |
---|
| 109 | + LIST_HEAD(objects); |
---|
97 | 110 | int err; |
---|
98 | 111 | |
---|
99 | 112 | /* Fill the GGTT with pinned objects and try to evict one. */ |
---|
100 | 113 | |
---|
101 | | - err = populate_ggtt(i915); |
---|
| 114 | + err = populate_ggtt(ggtt, &objects); |
---|
102 | 115 | if (err) |
---|
103 | 116 | goto cleanup; |
---|
104 | 117 | |
---|
105 | 118 | /* Everything is pinned, nothing should happen */ |
---|
| 119 | + mutex_lock(&ggtt->vm.mutex); |
---|
106 | 120 | err = i915_gem_evict_something(&ggtt->vm, |
---|
107 | 121 | I915_GTT_PAGE_SIZE, 0, 0, |
---|
108 | 122 | 0, U64_MAX, |
---|
109 | 123 | 0); |
---|
| 124 | + mutex_unlock(&ggtt->vm.mutex); |
---|
110 | 125 | if (err != -ENOSPC) { |
---|
111 | 126 | pr_err("i915_gem_evict_something failed on a full GGTT with err=%d\n", |
---|
112 | 127 | err); |
---|
113 | 128 | goto cleanup; |
---|
114 | 129 | } |
---|
115 | 130 | |
---|
116 | | - unpin_ggtt(i915); |
---|
| 131 | + unpin_ggtt(ggtt); |
---|
117 | 132 | |
---|
118 | 133 | /* Everything is unpinned, we should be able to evict something */ |
---|
| 134 | + mutex_lock(&ggtt->vm.mutex); |
---|
119 | 135 | err = i915_gem_evict_something(&ggtt->vm, |
---|
120 | 136 | I915_GTT_PAGE_SIZE, 0, 0, |
---|
121 | 137 | 0, U64_MAX, |
---|
122 | 138 | 0); |
---|
| 139 | + mutex_unlock(&ggtt->vm.mutex); |
---|
123 | 140 | if (err) { |
---|
124 | 141 | pr_err("i915_gem_evict_something failed on a full GGTT with err=%d\n", |
---|
125 | 142 | err); |
---|
.. | .. |
---|
127 | 144 | } |
---|
128 | 145 | |
---|
129 | 146 | cleanup: |
---|
130 | | - cleanup_objects(i915); |
---|
| 147 | + cleanup_objects(ggtt, &objects); |
---|
131 | 148 | return err; |
---|
132 | 149 | } |
---|
133 | 150 | |
---|
134 | 151 | static int igt_overcommit(void *arg) |
---|
135 | 152 | { |
---|
136 | | - struct drm_i915_private *i915 = arg; |
---|
| 153 | + struct intel_gt *gt = arg; |
---|
| 154 | + struct i915_ggtt *ggtt = gt->ggtt; |
---|
137 | 155 | struct drm_i915_gem_object *obj; |
---|
138 | 156 | struct i915_vma *vma; |
---|
| 157 | + LIST_HEAD(objects); |
---|
139 | 158 | int err; |
---|
140 | 159 | |
---|
141 | 160 | /* Fill the GGTT with pinned objects and then try to pin one more. |
---|
142 | 161 | * We expect it to fail. |
---|
143 | 162 | */ |
---|
144 | 163 | |
---|
145 | | - err = populate_ggtt(i915); |
---|
| 164 | + err = populate_ggtt(ggtt, &objects); |
---|
146 | 165 | if (err) |
---|
147 | 166 | goto cleanup; |
---|
148 | 167 | |
---|
149 | | - obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE); |
---|
| 168 | + obj = i915_gem_object_create_internal(gt->i915, I915_GTT_PAGE_SIZE); |
---|
150 | 169 | if (IS_ERR(obj)) { |
---|
151 | 170 | err = PTR_ERR(obj); |
---|
152 | 171 | goto cleanup; |
---|
153 | 172 | } |
---|
154 | 173 | |
---|
| 174 | + quirk_add(obj, &objects); |
---|
| 175 | + |
---|
155 | 176 | vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0); |
---|
156 | | - if (!IS_ERR(vma) || PTR_ERR(vma) != -ENOSPC) { |
---|
157 | | - pr_err("Failed to evict+insert, i915_gem_object_ggtt_pin returned err=%d\n", (int)PTR_ERR(vma)); |
---|
| 177 | + if (vma != ERR_PTR(-ENOSPC)) { |
---|
| 178 | + pr_err("Failed to evict+insert, i915_gem_object_ggtt_pin returned err=%d\n", (int)PTR_ERR_OR_ZERO(vma)); |
---|
158 | 179 | err = -EINVAL; |
---|
159 | 180 | goto cleanup; |
---|
160 | 181 | } |
---|
161 | 182 | |
---|
162 | 183 | cleanup: |
---|
163 | | - cleanup_objects(i915); |
---|
| 184 | + cleanup_objects(ggtt, &objects); |
---|
164 | 185 | return err; |
---|
165 | 186 | } |
---|
166 | 187 | |
---|
167 | 188 | static int igt_evict_for_vma(void *arg) |
---|
168 | 189 | { |
---|
169 | | - struct drm_i915_private *i915 = arg; |
---|
170 | | - struct i915_ggtt *ggtt = &i915->ggtt; |
---|
| 190 | + struct intel_gt *gt = arg; |
---|
| 191 | + struct i915_ggtt *ggtt = gt->ggtt; |
---|
171 | 192 | struct drm_mm_node target = { |
---|
172 | 193 | .start = 0, |
---|
173 | 194 | .size = 4096, |
---|
174 | 195 | }; |
---|
| 196 | + LIST_HEAD(objects); |
---|
175 | 197 | int err; |
---|
176 | 198 | |
---|
177 | 199 | /* Fill the GGTT with pinned objects and try to evict a range. */ |
---|
178 | 200 | |
---|
179 | | - err = populate_ggtt(i915); |
---|
| 201 | + err = populate_ggtt(ggtt, &objects); |
---|
180 | 202 | if (err) |
---|
181 | 203 | goto cleanup; |
---|
182 | 204 | |
---|
183 | 205 | /* Everything is pinned, nothing should happen */ |
---|
| 206 | + mutex_lock(&ggtt->vm.mutex); |
---|
184 | 207 | err = i915_gem_evict_for_node(&ggtt->vm, &target, 0); |
---|
| 208 | + mutex_unlock(&ggtt->vm.mutex); |
---|
185 | 209 | if (err != -ENOSPC) { |
---|
186 | 210 | pr_err("i915_gem_evict_for_node on a full GGTT returned err=%d\n", |
---|
187 | 211 | err); |
---|
188 | 212 | goto cleanup; |
---|
189 | 213 | } |
---|
190 | 214 | |
---|
191 | | - unpin_ggtt(i915); |
---|
| 215 | + unpin_ggtt(ggtt); |
---|
192 | 216 | |
---|
193 | 217 | /* Everything is unpinned, we should be able to evict the node */ |
---|
| 218 | + mutex_lock(&ggtt->vm.mutex); |
---|
194 | 219 | err = i915_gem_evict_for_node(&ggtt->vm, &target, 0); |
---|
| 220 | + mutex_unlock(&ggtt->vm.mutex); |
---|
195 | 221 | if (err) { |
---|
196 | 222 | pr_err("i915_gem_evict_for_node returned err=%d\n", |
---|
197 | 223 | err); |
---|
.. | .. |
---|
199 | 225 | } |
---|
200 | 226 | |
---|
201 | 227 | cleanup: |
---|
202 | | - cleanup_objects(i915); |
---|
| 228 | + cleanup_objects(ggtt, &objects); |
---|
203 | 229 | return err; |
---|
204 | 230 | } |
---|
205 | 231 | |
---|
.. | .. |
---|
212 | 238 | |
---|
213 | 239 | static int igt_evict_for_cache_color(void *arg) |
---|
214 | 240 | { |
---|
215 | | - struct drm_i915_private *i915 = arg; |
---|
216 | | - struct i915_ggtt *ggtt = &i915->ggtt; |
---|
| 241 | + struct intel_gt *gt = arg; |
---|
| 242 | + struct i915_ggtt *ggtt = gt->ggtt; |
---|
217 | 243 | const unsigned long flags = PIN_OFFSET_FIXED; |
---|
218 | 244 | struct drm_mm_node target = { |
---|
219 | 245 | .start = I915_GTT_PAGE_SIZE * 2, |
---|
.. | .. |
---|
222 | 248 | }; |
---|
223 | 249 | struct drm_i915_gem_object *obj; |
---|
224 | 250 | struct i915_vma *vma; |
---|
| 251 | + LIST_HEAD(objects); |
---|
225 | 252 | int err; |
---|
226 | 253 | |
---|
227 | | - /* Currently the use of color_adjust is limited to cache domains within |
---|
228 | | - * the ggtt, and so the presence of mm.color_adjust is assumed to be |
---|
229 | | - * i915_gtt_color_adjust throughout our driver, so using a mock color |
---|
230 | | - * adjust will work just fine for our purposes. |
---|
| 254 | + /* |
---|
| 255 | + * Currently the use of color_adjust for the GGTT is limited to cache |
---|
| 256 | + * coloring and guard pages, and so the presence of mm.color_adjust for |
---|
| 257 | + * the GGTT is assumed to be i915_ggtt_color_adjust, hence using a mock |
---|
| 258 | + * color adjust will work just fine for our purposes. |
---|
231 | 259 | */ |
---|
232 | 260 | ggtt->vm.mm.color_adjust = mock_color_adjust; |
---|
| 261 | + GEM_BUG_ON(!i915_vm_has_cache_coloring(&ggtt->vm)); |
---|
233 | 262 | |
---|
234 | | - obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE); |
---|
| 263 | + obj = i915_gem_object_create_internal(gt->i915, I915_GTT_PAGE_SIZE); |
---|
235 | 264 | if (IS_ERR(obj)) { |
---|
236 | 265 | err = PTR_ERR(obj); |
---|
237 | 266 | goto cleanup; |
---|
238 | 267 | } |
---|
239 | | - i915_gem_object_set_cache_level(obj, I915_CACHE_LLC); |
---|
| 268 | + i915_gem_object_set_cache_coherency(obj, I915_CACHE_LLC); |
---|
| 269 | + quirk_add(obj, &objects); |
---|
240 | 270 | |
---|
241 | 271 | vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, |
---|
242 | 272 | I915_GTT_PAGE_SIZE | flags); |
---|
.. | .. |
---|
246 | 276 | goto cleanup; |
---|
247 | 277 | } |
---|
248 | 278 | |
---|
249 | | - obj = i915_gem_object_create_internal(i915, I915_GTT_PAGE_SIZE); |
---|
| 279 | + obj = i915_gem_object_create_internal(gt->i915, I915_GTT_PAGE_SIZE); |
---|
250 | 280 | if (IS_ERR(obj)) { |
---|
251 | 281 | err = PTR_ERR(obj); |
---|
252 | 282 | goto cleanup; |
---|
253 | 283 | } |
---|
254 | | - i915_gem_object_set_cache_level(obj, I915_CACHE_LLC); |
---|
| 284 | + i915_gem_object_set_cache_coherency(obj, I915_CACHE_LLC); |
---|
| 285 | + quirk_add(obj, &objects); |
---|
255 | 286 | |
---|
256 | 287 | /* Neighbouring; same colour - should fit */ |
---|
257 | 288 | vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, |
---|
.. | .. |
---|
265 | 296 | i915_vma_unpin(vma); |
---|
266 | 297 | |
---|
267 | 298 | /* Remove just the second vma */ |
---|
| 299 | + mutex_lock(&ggtt->vm.mutex); |
---|
268 | 300 | err = i915_gem_evict_for_node(&ggtt->vm, &target, 0); |
---|
| 301 | + mutex_unlock(&ggtt->vm.mutex); |
---|
269 | 302 | if (err) { |
---|
270 | 303 | pr_err("[0]i915_gem_evict_for_node returned err=%d\n", err); |
---|
271 | 304 | goto cleanup; |
---|
.. | .. |
---|
276 | 309 | */ |
---|
277 | 310 | target.color = I915_CACHE_L3_LLC; |
---|
278 | 311 | |
---|
| 312 | + mutex_lock(&ggtt->vm.mutex); |
---|
279 | 313 | err = i915_gem_evict_for_node(&ggtt->vm, &target, 0); |
---|
| 314 | + mutex_unlock(&ggtt->vm.mutex); |
---|
280 | 315 | if (!err) { |
---|
281 | 316 | pr_err("[1]i915_gem_evict_for_node returned err=%d\n", err); |
---|
282 | 317 | err = -EINVAL; |
---|
.. | .. |
---|
286 | 321 | err = 0; |
---|
287 | 322 | |
---|
288 | 323 | cleanup: |
---|
289 | | - unpin_ggtt(i915); |
---|
290 | | - cleanup_objects(i915); |
---|
| 324 | + unpin_ggtt(ggtt); |
---|
| 325 | + cleanup_objects(ggtt, &objects); |
---|
291 | 326 | ggtt->vm.mm.color_adjust = NULL; |
---|
292 | 327 | return err; |
---|
293 | 328 | } |
---|
294 | 329 | |
---|
295 | 330 | static int igt_evict_vm(void *arg) |
---|
296 | 331 | { |
---|
297 | | - struct drm_i915_private *i915 = arg; |
---|
298 | | - struct i915_ggtt *ggtt = &i915->ggtt; |
---|
| 332 | + struct intel_gt *gt = arg; |
---|
| 333 | + struct i915_ggtt *ggtt = gt->ggtt; |
---|
| 334 | + LIST_HEAD(objects); |
---|
299 | 335 | int err; |
---|
300 | 336 | |
---|
301 | 337 | /* Fill the GGTT with pinned objects and try to evict everything. */ |
---|
302 | 338 | |
---|
303 | | - err = populate_ggtt(i915); |
---|
| 339 | + err = populate_ggtt(ggtt, &objects); |
---|
304 | 340 | if (err) |
---|
305 | 341 | goto cleanup; |
---|
306 | 342 | |
---|
307 | 343 | /* Everything is pinned, nothing should happen */ |
---|
| 344 | + mutex_lock(&ggtt->vm.mutex); |
---|
308 | 345 | err = i915_gem_evict_vm(&ggtt->vm); |
---|
| 346 | + mutex_unlock(&ggtt->vm.mutex); |
---|
309 | 347 | if (err) { |
---|
310 | 348 | pr_err("i915_gem_evict_vm on a full GGTT returned err=%d]\n", |
---|
311 | 349 | err); |
---|
312 | 350 | goto cleanup; |
---|
313 | 351 | } |
---|
314 | 352 | |
---|
315 | | - unpin_ggtt(i915); |
---|
| 353 | + unpin_ggtt(ggtt); |
---|
316 | 354 | |
---|
| 355 | + mutex_lock(&ggtt->vm.mutex); |
---|
317 | 356 | err = i915_gem_evict_vm(&ggtt->vm); |
---|
| 357 | + mutex_unlock(&ggtt->vm.mutex); |
---|
318 | 358 | if (err) { |
---|
319 | 359 | pr_err("i915_gem_evict_vm on a full GGTT returned err=%d]\n", |
---|
320 | 360 | err); |
---|
.. | .. |
---|
322 | 362 | } |
---|
323 | 363 | |
---|
324 | 364 | cleanup: |
---|
325 | | - cleanup_objects(i915); |
---|
| 365 | + cleanup_objects(ggtt, &objects); |
---|
326 | 366 | return err; |
---|
327 | 367 | } |
---|
328 | 368 | |
---|
329 | 369 | static int igt_evict_contexts(void *arg) |
---|
330 | 370 | { |
---|
331 | 371 | const u64 PRETEND_GGTT_SIZE = 16ull << 20; |
---|
332 | | - struct drm_i915_private *i915 = arg; |
---|
| 372 | + struct intel_gt *gt = arg; |
---|
| 373 | + struct i915_ggtt *ggtt = gt->ggtt; |
---|
| 374 | + struct drm_i915_private *i915 = gt->i915; |
---|
333 | 375 | struct intel_engine_cs *engine; |
---|
334 | 376 | enum intel_engine_id id; |
---|
335 | 377 | struct reserved { |
---|
336 | 378 | struct drm_mm_node node; |
---|
337 | 379 | struct reserved *next; |
---|
338 | 380 | } *reserved = NULL; |
---|
| 381 | + intel_wakeref_t wakeref; |
---|
339 | 382 | struct drm_mm_node hole; |
---|
340 | 383 | unsigned long count; |
---|
341 | 384 | int err; |
---|
.. | .. |
---|
351 | 394 | * where the GTT space of the request is separate from the GGTT |
---|
352 | 395 | * allocation required to build the request. |
---|
353 | 396 | */ |
---|
354 | | - if (!USES_FULL_PPGTT(i915)) |
---|
| 397 | + if (!HAS_FULL_PPGTT(i915)) |
---|
355 | 398 | return 0; |
---|
356 | 399 | |
---|
357 | | - mutex_lock(&i915->drm.struct_mutex); |
---|
358 | | - intel_runtime_pm_get(i915); |
---|
| 400 | + wakeref = intel_runtime_pm_get(&i915->runtime_pm); |
---|
359 | 401 | |
---|
360 | 402 | /* Reserve a block so that we know we have enough to fit a few rq */ |
---|
361 | 403 | memset(&hole, 0, sizeof(hole)); |
---|
362 | | - err = i915_gem_gtt_insert(&i915->ggtt.vm, &hole, |
---|
| 404 | + mutex_lock(&ggtt->vm.mutex); |
---|
| 405 | + err = i915_gem_gtt_insert(&ggtt->vm, &hole, |
---|
363 | 406 | PRETEND_GGTT_SIZE, 0, I915_COLOR_UNEVICTABLE, |
---|
364 | | - 0, i915->ggtt.vm.total, |
---|
| 407 | + 0, ggtt->vm.total, |
---|
365 | 408 | PIN_NOEVICT); |
---|
366 | 409 | if (err) |
---|
367 | 410 | goto out_locked; |
---|
.. | .. |
---|
371 | 414 | do { |
---|
372 | 415 | struct reserved *r; |
---|
373 | 416 | |
---|
| 417 | + mutex_unlock(&ggtt->vm.mutex); |
---|
374 | 418 | r = kcalloc(1, sizeof(*r), GFP_KERNEL); |
---|
| 419 | + mutex_lock(&ggtt->vm.mutex); |
---|
375 | 420 | if (!r) { |
---|
376 | 421 | err = -ENOMEM; |
---|
377 | 422 | goto out_locked; |
---|
378 | 423 | } |
---|
379 | 424 | |
---|
380 | | - if (i915_gem_gtt_insert(&i915->ggtt.vm, &r->node, |
---|
| 425 | + if (i915_gem_gtt_insert(&ggtt->vm, &r->node, |
---|
381 | 426 | 1ul << 20, 0, I915_COLOR_UNEVICTABLE, |
---|
382 | | - 0, i915->ggtt.vm.total, |
---|
| 427 | + 0, ggtt->vm.total, |
---|
383 | 428 | PIN_NOEVICT)) { |
---|
384 | 429 | kfree(r); |
---|
385 | 430 | break; |
---|
.. | .. |
---|
391 | 436 | count++; |
---|
392 | 437 | } while (1); |
---|
393 | 438 | drm_mm_remove_node(&hole); |
---|
394 | | - mutex_unlock(&i915->drm.struct_mutex); |
---|
| 439 | + mutex_unlock(&ggtt->vm.mutex); |
---|
395 | 440 | pr_info("Filled GGTT with %lu 1MiB nodes\n", count); |
---|
396 | 441 | |
---|
397 | 442 | /* Overfill the GGTT with context objects and so try to evict one. */ |
---|
398 | | - for_each_engine(engine, i915, id) { |
---|
| 443 | + for_each_engine(engine, gt, id) { |
---|
399 | 444 | struct i915_sw_fence fence; |
---|
400 | | - struct drm_file *file; |
---|
| 445 | + struct file *file; |
---|
401 | 446 | |
---|
402 | 447 | file = mock_file(i915); |
---|
403 | | - if (IS_ERR(file)) |
---|
404 | | - return PTR_ERR(file); |
---|
| 448 | + if (IS_ERR(file)) { |
---|
| 449 | + err = PTR_ERR(file); |
---|
| 450 | + break; |
---|
| 451 | + } |
---|
405 | 452 | |
---|
406 | 453 | count = 0; |
---|
407 | | - mutex_lock(&i915->drm.struct_mutex); |
---|
408 | 454 | onstack_fence_init(&fence); |
---|
409 | 455 | do { |
---|
410 | 456 | struct i915_request *rq; |
---|
411 | 457 | struct i915_gem_context *ctx; |
---|
412 | 458 | |
---|
413 | 459 | ctx = live_context(i915, file); |
---|
414 | | - if (!ctx) |
---|
| 460 | + if (IS_ERR(ctx)) |
---|
415 | 461 | break; |
---|
416 | 462 | |
---|
417 | 463 | /* We will need some GGTT space for the rq's context */ |
---|
418 | 464 | igt_evict_ctl.fail_if_busy = true; |
---|
419 | | - rq = i915_request_alloc(engine, ctx); |
---|
| 465 | + rq = igt_request_alloc(ctx, engine); |
---|
420 | 466 | igt_evict_ctl.fail_if_busy = false; |
---|
421 | 467 | |
---|
422 | 468 | if (IS_ERR(rq)) { |
---|
423 | 469 | /* When full, fail_if_busy will trigger EBUSY */ |
---|
424 | 470 | if (PTR_ERR(rq) != -EBUSY) { |
---|
425 | | - pr_err("Unexpected error from request alloc (ctx hw id %u, on %s): %d\n", |
---|
426 | | - ctx->hw_id, engine->name, |
---|
| 471 | + pr_err("Unexpected error from request alloc (on %s): %d\n", |
---|
| 472 | + engine->name, |
---|
427 | 473 | (int)PTR_ERR(rq)); |
---|
428 | 474 | err = PTR_ERR(rq); |
---|
429 | 475 | } |
---|
.. | .. |
---|
441 | 487 | count++; |
---|
442 | 488 | err = 0; |
---|
443 | 489 | } while(1); |
---|
444 | | - mutex_unlock(&i915->drm.struct_mutex); |
---|
445 | | - |
---|
446 | 490 | onstack_fence_fini(&fence); |
---|
447 | 491 | pr_info("Submitted %lu contexts/requests on %s\n", |
---|
448 | 492 | count, engine->name); |
---|
449 | 493 | |
---|
450 | | - mock_file_free(i915, file); |
---|
| 494 | + fput(file); |
---|
451 | 495 | if (err) |
---|
452 | 496 | break; |
---|
453 | 497 | } |
---|
454 | 498 | |
---|
455 | | - mutex_lock(&i915->drm.struct_mutex); |
---|
| 499 | + mutex_lock(&ggtt->vm.mutex); |
---|
456 | 500 | out_locked: |
---|
| 501 | + if (igt_flush_test(i915)) |
---|
| 502 | + err = -EIO; |
---|
457 | 503 | while (reserved) { |
---|
458 | 504 | struct reserved *next = reserved->next; |
---|
459 | 505 | |
---|
.. | .. |
---|
464 | 510 | } |
---|
465 | 511 | if (drm_mm_node_allocated(&hole)) |
---|
466 | 512 | drm_mm_remove_node(&hole); |
---|
467 | | - intel_runtime_pm_put(i915); |
---|
468 | | - mutex_unlock(&i915->drm.struct_mutex); |
---|
| 513 | + mutex_unlock(&ggtt->vm.mutex); |
---|
| 514 | + intel_runtime_pm_put(&i915->runtime_pm, wakeref); |
---|
469 | 515 | |
---|
470 | 516 | return err; |
---|
471 | 517 | } |
---|
.. | .. |
---|
480 | 526 | SUBTEST(igt_overcommit), |
---|
481 | 527 | }; |
---|
482 | 528 | struct drm_i915_private *i915; |
---|
483 | | - int err; |
---|
| 529 | + intel_wakeref_t wakeref; |
---|
| 530 | + int err = 0; |
---|
484 | 531 | |
---|
485 | 532 | i915 = mock_gem_device(); |
---|
486 | 533 | if (!i915) |
---|
487 | 534 | return -ENOMEM; |
---|
488 | 535 | |
---|
489 | | - mutex_lock(&i915->drm.struct_mutex); |
---|
490 | | - err = i915_subtests(tests, i915); |
---|
491 | | - mutex_unlock(&i915->drm.struct_mutex); |
---|
| 536 | + with_intel_runtime_pm(&i915->runtime_pm, wakeref) |
---|
| 537 | + err = i915_subtests(tests, &i915->gt); |
---|
492 | 538 | |
---|
493 | | - drm_dev_put(&i915->drm); |
---|
| 539 | + mock_destroy_device(i915); |
---|
494 | 540 | return err; |
---|
495 | 541 | } |
---|
496 | 542 | |
---|
.. | .. |
---|
500 | 546 | SUBTEST(igt_evict_contexts), |
---|
501 | 547 | }; |
---|
502 | 548 | |
---|
503 | | - if (i915_terminally_wedged(&i915->gpu_error)) |
---|
| 549 | + if (intel_gt_is_wedged(&i915->gt)) |
---|
504 | 550 | return 0; |
---|
505 | 551 | |
---|
506 | | - return i915_subtests(tests, i915); |
---|
| 552 | + return intel_gt_live_subtests(tests, &i915->gt); |
---|
507 | 553 | } |
---|