Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/linux linux/ww_mutex: Disable locking-...



details:   https://anonhg.NetBSD.org/src/rev/20e90a0a8706
branches:  trunk
changeset: 1028573:20e90a0a8706
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 19 11:21:20 2021 +0000

description:
linux/ww_mutex: Disable locking-against-self asserts in trylock.

This seems to be done intentionally in Linux.

diffstat:

 sys/external/bsd/drm2/linux/linux_ww_mutex.c |  19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 92367896a51d -r 20e90a0a8706 sys/external/bsd/drm2/linux/linux_ww_mutex.c
--- a/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Sun Dec 19 11:21:12 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Sun Dec 19 11:21:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_ww_mutex.c,v 1.8 2021/12/19 10:38:14 riastradh Exp $     */
+/*     $NetBSD: linux_ww_mutex.c,v 1.9 2021/12/19 11:21:20 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.8 2021/12/19 10:38:14 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.9 2021/12/19 11:21:20 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -760,12 +760,27 @@
                WW_LOCKED(mutex);
                ret = 1;
        } else {
+               /*
+                * It is tempting to assert that we do not hold the
+                * mutex here, because trylock when we hold the lock
+                * already generally indicates a bug in the design of
+                * the code.  However, it seems that Linux relies on
+                * this deep in ttm buffer reservation logic, so these
+                * assertions are disabled until we find another way to
+                * work around that or fix the bug that leads to it.
+                *
+                * That said: we should not be in the WW_WANTOWN state,
+                * which happens only while we're in the ww mutex logic
+                * waiting to acquire the lock.
+                */
+#if 0
                KASSERTMSG(((mutex->wwm_state != WW_OWNED) ||
                    (mutex->wwm_u.owner != curlwp)),
                    "locking %p against myself: %p", mutex, curlwp);
                KASSERTMSG(((mutex->wwm_state != WW_CTX) ||
                    (mutex->wwm_u.ctx->wwx_owner != curlwp)),
                    "locking %p against myself: %p", mutex, curlwp);
+#endif
                KASSERTMSG(((mutex->wwm_state != WW_WANTOWN) ||
                    (mutex->wwm_u.ctx->wwx_owner != curlwp)),
                    "locking %p against myself: %p", mutex, curlwp);



Home | Main Index | Thread Index | Old Index