diff options
| author | riastradh <riastradh@NetBSD.org> | 2021-12-19 11:21:20 +0000 |
|---|---|---|
| committer | riastradh <riastradh@NetBSD.org> | 2021-12-19 11:21:20 +0000 |
| commit | f3abf539cd19e029ce59cd31de8baaa699b9fcca (patch) | |
| tree | 4978c2a98867958698f5df28632cebbd88fb4af3 | |
| parent | 6851f4c2e8133d8067c384907c8d94dc011745ee (diff) | |
linux/ww_mutex: Disable locking-against-self asserts in trylock.
This seems to be done intentionally in Linux.
| -rw-r--r-- | sys/external/bsd/drm2/linux/linux_ww_mutex.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/external/bsd/drm2/linux/linux_ww_mutex.c b/sys/external/bsd/drm2/linux/linux_ww_mutex.c index 79f248effc7..3d3d903ecc7 100644 --- a/sys/external/bsd/drm2/linux/linux_ww_mutex.c +++ b/sys/external/bsd/drm2/linux/linux_ww_mutex.c @@ -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_mutex_trylock(struct ww_mutex *mutex) 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); |
