Skip to content

Commit ca69a3c

Browse files
drm/i915: Document locking guidelines
To ensure cross-driver locking compatibility, document the expected guidelines for implementing the GEM locking in i915. Note that this is a description of how things should end up after being reworked, and does not reflect the current state of things. v2: Use rst note:: tag (Rodrigo) Signed-off-by: Joonas Lahtinen <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Signed-off-by: Chris Wilson <[email protected]> Cc: Dave Airlie <[email protected]> Cc: Matthew Auld <[email protected]> Cc: Abdiel Janulgue <[email protected]> Cc: CQ Tang <[email protected]> Reviewed-by: Rodrigo Vivi <[email protected]> Acked-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 802a582 commit ca69a3c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Documentation/gpu/i915.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,52 @@ for execution also include a list of all locations within buffers that
329329
refer to GPU-addresses so that the kernel can edit the buffer correctly.
330330
This process is dubbed relocation.
331331

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+
332378
GEM BO Management Implementation Details
333379
----------------------------------------
334380

0 commit comments

Comments
 (0)