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 Fix lockdebug_locked annotations.



details:   https://anonhg.NetBSD.org/src/rev/84b12637d67d
branches:  trunk
changeset: 826272:84b12637d67d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Aug 25 14:14:44 2017 +0000

description:
Fix lockdebug_locked annotations.

When thread A grants ownership to thread B waiting with a context,
thread B needs to assert lockdebug_locked; otherwise, when it
releases, lockdebug_unlocked thinks it's releasing an unlocked
ww_mutex.

Fixes LOCKDEBUG failure with radeon noticed by martin@.

diffstat:

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

diffs (120 lines):

diff -r d34663b38da7 -r 84b12637d67d sys/external/bsd/drm2/linux/linux_ww_mutex.c
--- a/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Fri Aug 25 12:28:51 2017 +0000
+++ b/sys/external/bsd/drm2/linux/linux_ww_mutex.c      Fri Aug 25 14:14:44 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_ww_mutex.c,v 1.2 2015/05/21 21:55:55 riastradh Exp $     */
+/*     $NetBSD: linux_ww_mutex.c,v 1.3 2017/08/25 14:14:44 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.2 2015/05/21 21:55:55 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.3 2017/08/25 14:14:44 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -334,7 +334,6 @@
        case WW_UNLOCKED:
                mutex->wwm_state = WW_OWNED;
                mutex->wwm_u.owner = curlwp;
-               WW_LOCKED(mutex);
                break;
        case WW_OWNED:
                KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -356,6 +355,7 @@
        }
        KASSERT(mutex->wwm_state == WW_OWNED);
        KASSERT(mutex->wwm_u.owner == curlwp);
+       WW_LOCKED(mutex);
        mutex_exit(&mutex->wwm_lock);
 }
 
@@ -369,7 +369,6 @@
        case WW_UNLOCKED:
                mutex->wwm_state = WW_OWNED;
                mutex->wwm_u.owner = curlwp;
-               WW_LOCKED(mutex);
                break;
        case WW_OWNED:
                KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -395,6 +394,7 @@
        }
        KASSERT(mutex->wwm_state == WW_OWNED);
        KASSERT(mutex->wwm_u.owner == curlwp);
+       WW_LOCKED(mutex);
        ret = 0;
 out:   mutex_exit(&mutex->wwm_lock);
        return ret;
@@ -433,7 +433,6 @@
                WW_WANTLOCK(mutex);
                mutex->wwm_state = WW_CTX;
                mutex->wwm_u.ctx = ctx;
-               WW_LOCKED(mutex);
                goto locked;
        case WW_OWNED:
                WW_WANTLOCK(mutex);
@@ -490,10 +489,11 @@
         */
        ww_mutex_lock_wait(mutex, ctx);
 
-locked:        ctx->wwx_acquired++;
-       KASSERT((mutex->wwm_state == WW_CTX) ||
+locked:        KASSERT((mutex->wwm_state == WW_CTX) ||
            (mutex->wwm_state == WW_WANTOWN));
        KASSERT(mutex->wwm_u.ctx == ctx);
+       WW_LOCKED(mutex);
+       ctx->wwx_acquired++;
        mutex_exit(&mutex->wwm_lock);
        return 0;
 }
@@ -531,7 +531,6 @@
                WW_WANTLOCK(mutex);
                mutex->wwm_state = WW_CTX;
                mutex->wwm_u.ctx = ctx;
-               WW_LOCKED(mutex);
                goto locked;
        case WW_OWNED:
                WW_WANTLOCK(mutex);
@@ -597,6 +596,7 @@
 locked:        KASSERT((mutex->wwm_state == WW_CTX) ||
            (mutex->wwm_state == WW_WANTOWN));
        KASSERT(mutex->wwm_u.ctx == ctx);
+       WW_LOCKED(mutex);
        ctx->wwx_acquired++;
        ret = 0;
 out:   mutex_exit(&mutex->wwm_lock);
@@ -634,7 +634,6 @@
        case WW_UNLOCKED:
                mutex->wwm_state = WW_CTX;
                mutex->wwm_u.ctx = ctx;
-               WW_LOCKED(mutex);
                goto locked;
        case WW_OWNED:
                KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -665,6 +664,7 @@
 locked:        KASSERT((mutex->wwm_state == WW_CTX) ||
            (mutex->wwm_state == WW_WANTOWN));
        KASSERT(mutex->wwm_u.ctx == ctx);
+       WW_LOCKED(mutex);
        ctx->wwx_acquired++;
        mutex_exit(&mutex->wwm_lock);
 }
@@ -699,7 +699,6 @@
        case WW_UNLOCKED:
                mutex->wwm_state = WW_CTX;
                mutex->wwm_u.ctx = ctx;
-               WW_LOCKED(mutex);
                goto locked;
        case WW_OWNED:
                KASSERTMSG((mutex->wwm_u.owner != curlwp),
@@ -736,6 +735,7 @@
 locked:        KASSERT((mutex->wwm_state == WW_CTX) ||
            (mutex->wwm_state == WW_WANTOWN));
        KASSERT(mutex->wwm_u.ctx == ctx);
+       WW_LOCKED(mutex);
        ctx->wwx_acquired++;
        ret = 0;
 out:   mutex_exit(&mutex->wwm_lock);



Home | Main Index | Thread Index | Old Index