Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Aug 2008 21:28:03 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 146870 for review
Message-ID:  <200808072128.m77LS356025334@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808072128.m77LS356025334>