@@ -329,6 +329,52 @@ for execution also include a list of all locations within buffers that
329
329
refer to GPU-addresses so that the kernel can edit the buffer correctly.
330
330
This process is dubbed relocation.
331
331
332
+ Locking Guidelines
333
+ ------------------
334
+
335
+ .. note ::
336
+ This is a description of how the locking should be after
337
+ refactoring is done. Does not necessarily reflect what the locking
338
+ looks like while WIP.
339
+
340
+ #. All locking rules and interface contracts with cross-driver interfaces
341
+ (dma-buf, dma_fence) need to be followed.
342
+
343
+ #. No struct_mutex anywhere in the code
344
+
345
+ #. dma_resv will be the outermost lock (when needed) and ww_acquire_ctx
346
+ is to be hoisted at highest level and passed down within i915_gem_ctx
347
+ in the call chain
348
+
349
+ #. While holding lru/memory manager (buddy, drm_mm, whatever) locks
350
+ system memory allocations are not allowed
351
+
352
+ * Enforce this by priming lockdep (with fs_reclaim). If we
353
+ allocate memory while holding these looks we get a rehash
354
+ of the shrinker vs. struct_mutex saga, and that would be
355
+ real bad.
356
+
357
+ #. Do not nest different lru/memory manager locks within each other.
358
+ Take them in turn to update memory allocations, relying on the object’s
359
+ dma_resv ww_mutex to serialize against other operations.
360
+
361
+ #. The suggestion for lru/memory managers locks is that they are small
362
+ enough to be spinlocks.
363
+
364
+ #. All features need to come with exhaustive kernel selftests and/or
365
+ IGT tests when appropriate
366
+
367
+ #. All LMEM uAPI paths need to be fully restartable (_interruptible()
368
+ for all locks/waits/sleeps)
369
+
370
+ * Error handling validation through signal injection.
371
+ Still the best strategy we have for validating GEM uAPI
372
+ corner cases.
373
+ Must be excessively used in the IGT, and we need to check
374
+ that we really have full path coverage of all error cases.
375
+
376
+ * -EDEADLK handling with ww_mutex
377
+
332
378
GEM BO Management Implementation Details
333
379
----------------------------------------
334
380
0 commit comments