Module Name:    src
Committed By:   riastradh
Date:           Fri Mar 18 23:33:41 UTC 2022

Modified Files:
        src/sys/external/bsd/drm2/linux: linux_ww_mutex.c

Log Message:
drm: In ww_mutex_unlock, do lockdebug check first.

This way we get a full lockdebug dump when LOCKDEBUG is enabled,
instead of just the panic message (which includes the lock address
you could pass to `show lock' in ddb, but let's get the dump by
default even if you don't enter ddb).

Also in the KASSERT print the mutex.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/linux/linux_ww_mutex.c
diff -u src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.13 src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.14
--- src/sys/external/bsd/drm2/linux/linux_ww_mutex.c:1.13	Sun Dec 26 16:14:34 2021
+++ src/sys/external/bsd/drm2/linux/linux_ww_mutex.c	Fri Mar 18 23:33:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_ww_mutex.c,v 1.13 2021/12/26 16:14:34 riastradh Exp $	*/
+/*	$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.13 2021/12/26 16:14:34 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.14 2022/03/18 23:33:41 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -1041,7 +1041,8 @@ ww_mutex_unlock(struct ww_mutex *mutex)
 	struct ww_acquire_ctx *ctx;
 
 	mutex_enter(&mutex->wwm_lock);
-	KASSERT(mutex->wwm_state != WW_UNLOCKED);
+	WW_UNLOCKED(mutex);
+	KASSERTMSG(mutex->wwm_state != WW_UNLOCKED, "mutex %p", mutex);
 	switch (mutex->wwm_state) {
 	case WW_UNLOCKED:
 		panic("unlocking unlocked wait/wound mutex: %p", mutex);
@@ -1070,7 +1071,6 @@ ww_mutex_unlock(struct ww_mutex *mutex)
 		mutex->wwm_state = WW_UNLOCKED;
 		break;
 	}
-	WW_UNLOCKED(mutex);
 	cv_broadcast(&mutex->wwm_cv);
 	mutex_exit(&mutex->wwm_lock);
 }

Reply via email to