From owner-p4-projects@FreeBSD.ORG Thu Aug 7 21:28:08 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 7184610656C9; Thu, 7 Aug 2008 21:28:08 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3456C10656C6 for ; Thu, 7 Aug 2008 21:28:08 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 220DD8FC2C for ; Thu, 7 Aug 2008 21:28:08 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m77LS3r9025336 for ; Thu, 7 Aug 2008 21:28:03 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m77LS356025334 for perforce@freebsd.org; Thu, 7 Aug 2008 21:28:03 GMT (envelope-from ed@FreeBSD.org) Date: Thu, 7 Aug 2008 21:28:03 GMT Message-Id: <200808072128.m77LS356025334@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 146870 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Aug 2008 21:28:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=146870 Change 146870 by ed@ed_dull on 2008/08/07 21:27:50 Now that our condvar(9) supports Giant as its interlock, remove the evil hacks I had to make to the TTY code. We can now live without them. Affected files ... .. //depot/projects/mpsafetty/sys/kern/tty.c#17 edit Differences ... ==== //depot/projects/mpsafetty/sys/kern/tty.c#17 (text+ko) ==== @@ -880,8 +880,12 @@ STAILQ_INIT(&tp->t_outq.to_list); /* Allow drivers to use a custom mutex to lock the TTY */ - mtx_init(&tp->t_mtxobj, "tty lock", NULL, MTX_DEF); - tp->t_mtx = mutex != NULL ? mutex : &tp->t_mtxobj; + if (mutex != NULL) { + tp->t_mtx = mutex; + } else { + tp->t_mtx = &tp->t_mtxobj; + mtx_init(&tp->t_mtxobj, "tty lock", NULL, MTX_DEF); + } knlist_init(&tp->t_inpoll.si_note, tp->t_mtx, NULL, NULL, NULL); knlist_init(&tp->t_outpoll.si_note, tp->t_mtx, NULL, NULL, NULL); @@ -912,7 +916,8 @@ cv_destroy(&tp->t_bgwait); cv_destroy(&tp->t_dcdwait); - mtx_destroy(&tp->t_mtxobj); + if (tp->t_mtx == &tp->t_mtxobj) + mtx_destroy(&tp->t_mtxobj); ttydevsw_free(tp); free(tp, M_TTY); } @@ -1189,18 +1194,7 @@ #endif tty_lock_assert(tp, MA_OWNED); - if (tp->t_mtx == &Giant) { - /* - * XXX: condvar(9) doesn't allow Giant to be passed as - * its mutex. Because we don't use the per-TTY mutex - * here, temporarily abuse it to make condvar(9) work. - */ - mtx_lock(&tp->t_mtxobj); - error = cv_wait_sig(cv, &tp->t_mtxobj); - mtx_unlock(&tp->t_mtxobj); - } else { - error = cv_wait_sig(cv, tp->t_mtx); - } + error = cv_wait_sig(cv, tp->t_mtx); /* Restart the system call when we may have been revoked */ if (tp->t_revokecnt != revokecnt) @@ -1225,18 +1219,7 @@ #endif tty_lock_assert(tp, MA_OWNED); - if (tp->t_mtx == &Giant) { - /* - * XXX: condvar(9) doesn't allow Giant to be passed as - * its mutex. Because we don't use the per-TTY mutex - * here, temporarily abuse it to make condvar(9) work. - */ - mtx_lock(&tp->t_mtxobj); - error = cv_timedwait_sig(cv, &tp->t_mtxobj, hz); - mtx_unlock(&tp->t_mtxobj); - } else { - error = cv_timedwait_sig(cv, tp->t_mtx, hz); - } + error = cv_timedwait_sig(cv, tp->t_mtx, hz); /* Restart the system call when we may have been revoked */ if (tp->t_revokecnt != revokecnt)