[PATCH RFC 7/9] drm/locking: preserve deadlock diagnostics for trie-backed stacks

From: Caleb Kan

Date: Mon Aug 17 2026 - 08:46:28 EST


From: Caleb Kan <ckan@xxxxxxxxxxxxxx>

When a modeset lock acquisition returns -EDEADLK, DRM saves the call chain
and prints it if the caller later attempts another lock or drops its locks
without first calling drm_modeset_backoff(). This diagnostic currently
fetches the saved stack through stack_depot_fetch().

Persistent stack depot saves can now return trie-backed handles, while
stack_depot_fetch() remains limited to hash-backed records. Use
stack_depot_snprint() to format either backend. Preserve the PAGE_SIZE
buffer, two-space indentation, warning, and backtrace.

Signed-off-by: Caleb Kan <ckan@xxxxxxxxxxxxxx>
---
drivers/gpu/drm/drm_modeset_lock.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c
index 2c806b0146d6..a2ddb02b2aea 100644
--- a/drivers/gpu/drm/drm_modeset_lock.c
+++ b/drivers/gpu/drm/drm_modeset_lock.c
@@ -94,16 +94,13 @@ static noinline depot_stack_handle_t __drm_stack_depot_save(void)
static void __drm_stack_depot_print(depot_stack_handle_t stack_depot)
{
struct drm_printer p = drm_dbg_printer(NULL, DRM_UT_KMS, "drm_modeset_lock");
- unsigned long *entries;
- unsigned int nr_entries;
char *buf;

buf = kmalloc(PAGE_SIZE, GFP_NOWAIT | __GFP_NOWARN);
if (!buf)
return;

- nr_entries = stack_depot_fetch(stack_depot, &entries);
- stack_trace_snprint(buf, PAGE_SIZE, entries, nr_entries, 2);
+ stack_depot_snprint(stack_depot, buf, PAGE_SIZE, 2);

drm_printf(&p, "attempting to lock a contended lock without backoff:\n%s", buf);


--
Git-155)