svn commit: r294362 - in head/sys: dev/uart kern sys

John Baldwin jhb at freebsd.org
Wed Jan 20 02:45:32 UTC 2016


On Tuesday, January 19, 2016 06:36:04 PM John Baldwin wrote:
> On Tuesday, January 19, 2016 06:14:14 PM John Baldwin wrote:
> > On Tuesday, January 19, 2016 11:34:28 PM Marius Strobl wrote:
> > > Author: marius
> > > Date: Tue Jan 19 23:34:27 2016
> > > New Revision: 294362
> > > URL: https://svnweb.freebsd.org/changeset/base/294362
> > > 
> > > Log:
> > >   Fix tty_drain() and, thus, TIOCDRAIN of the current tty(4) incarnation
> > >   to actually wait until the TX FIFOs of UARTs have be drained before
> > >   returning. This is done by bringing the equivalent of the TS_BUSY flag
> > >   found in the previous implementation back in an ABI-preserving way.
> > >   Reported and tested by: Patrick Powell
> > >   
> > >   Most likely, drivers for USB-serial-adapters likewise incorporating
> > >   TX FIFOs as well as other terminal devices that buffer output in some
> > >   form should also provide implementations of tsw_busy.
> > >   
> > >   MFC after:	3 days
> > 
> > Hmm, I got a panic on boot that I think is from this:
> > 
> > panic: Assertion tty_gone(tp) failed at /ufs/src-head-clean/sys/sys/ttydevsw.h:19
> > cpuid = 8
> > KDB: stack backtrace:
> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe085c93a430
> > vpanic() at vpanic+0x182/frame 0xfffffe085c93a4b0
> > kassert_panic() at kassert_panic+0x126/frame 0xfffffe085c93a520
> > tty_drain() at tty_drain+0x80/frame 0xfffffe085c93a560
> > ttydev_leave() at ttydev_leave+0x8d/frame 0xfffffe085c93a580
> > ttydev_close() at ttydev_close+0xaf/frame 0xfffffe085c93a5a0
> > devfs_close() at devfs_close+0x223/frame 0xfffffe085c93a610
> > VOP_CLOSE_APV() at VOP_CLOSE_APV+0xf1/frame 0xfffffe085c93a640
> > vn_close() at vn_close+0xcd/frame 0xfffffe085c93a6b0
> > vn_closefile() at vn_closefile+0x4a/frame 0xfffffe085c93a730
> > devfs_close_f() at devfs_close_f+0x2c/frame 0xfffffe085c93a760
> > _fdrop() at _fdrop+0x1a/frame 0xfffffe085c93a780
> > closef() at closef+0x1e1/frame 0xfffffe085c93a810
> > fdescfree_fds() at fdescfree_fds+0x9d/frame 0xfffffe085c93a850
> > fdescfree() at fdescfree+0x46c/frame 0xfffffe085c93a910
> > exit1() at exit1+0x4e6/frame 0xfffffe085c93a990
> > sys_sys_exit() at sys_sys_exit+0xd/frame 0xfffffe085c93a9a0
> > amd64_syscall() at amd64_syscall+0x2db/frame 0xfffffe085c93aab0
> 
> (kgdb) frame 4
> #4  0xffffffff80a93360 in tty_drain (tp=0xfffff8000b9c9800, leaving=1)
>     at ttydevsw.h:191
> 191             MPASS(tty_gone(tp));
> Current language:  auto; currently minimal
> (kgdb) p tp
> $1 = (struct tty *) 0xfffff8000b9c9800
> (kgdb) p *tp
> $2 = {t_mtx = 0xfffff8000b9c9808, t_mtxobj = {lock_object = {
>       lo_name = 0xffffffff81389f66 "ttymtx", lo_flags = 16973824, lo_data = 0, 
>       lo_witness = 0xfffffe0000bafd80}, mtx_lock = 18446735277934809088}, 
>   t_list = {tqe_next = 0xfffff8000b9c9400, tqe_prev = 0xfffff8000b9c9c28}, 
>   t_flags = 128, t_revokecnt = 1, t_inq = {ti_firstblock = 0xfffff8001f5c86e0, 
>     ti_startblock = 0x0, ti_reprintblock = 0x0, ti_lastblock = 0x0, 
>     ti_begin = 0, ti_linestart = 0, ti_reprint = 0, ti_end = 0, 
>     ti_nblocks = 15, ti_quota = 15}, t_inlow = 1728, t_outq = {
>     to_firstblock = 0xfffff8001f4b0900, to_lastblock = 0x0, to_begin = 0, 
>     to_end = 0, to_nblocks = 8, to_quota = 8}, t_outlow = 1785, t_inwait = {
>     cv_description = 0xffffffff81389f45 "ttyin", cv_waiters = 0}, t_outwait = {
>     cv_description = 0xffffffff81389f4b "ttyout", cv_waiters = 0}, 
>   t_outserwait = {cv_description = 0xffffffff81389f52 "ttyosr", 
>     cv_waiters = 0}, t_bgwait = {cv_description = 0xffffffff81389f59 "ttybg", 
>     cv_waiters = 0}, t_dcdwait = {
>     cv_description = 0xffffffff81389f5f "ttydcd", cv_waiters = 0}, t_inpoll = {
>     si_tdlist = {tqh_first = 0x0, tqh_last = 0x0}, si_note = {kl_list = {
>         slh_first = 0x0}, kl_lock = 0xffffffff809dd1e0 <knlist_mtx_lock>, 
>       kl_unlock = 0xffffffff809dd200 <knlist_mtx_unlock>, 
>       kl_assert_locked = 0xffffffff809dd220 <knlist_mtx_assert_locked>, 
>       kl_assert_unlocked = 0xffffffff809dd240 <knlist_mtx_assert_unlocked>, 
>       kl_lockarg = 0xfffff8000b9c9808}, si_mtx = 0x0}, t_outpoll = {
>     si_tdlist = {tqh_first = 0x0, tqh_last = 0x0}, si_note = {kl_list = {
>         slh_first = 0x0}, kl_lock = 0xffffffff809dd1e0 <knlist_mtx_lock>, 
>       kl_unlock = 0xffffffff809dd200 <knlist_mtx_unlock>, 
> ---Type <return> to continue, or q <return> to quit---
>       kl_assert_locked = 0xffffffff809dd220 <knlist_mtx_assert_locked>, 
>       kl_assert_unlocked = 0xffffffff809dd240 <knlist_mtx_assert_unlocked>, 
>       kl_lockarg = 0xfffff8000b9c9808}, si_mtx = 0x0}, t_sigio = 0x0, 
>   t_termios = {c_iflag = 11010, c_oflag = 3, c_cflag = 19200, c_lflag = 1483, 
>     c_cc = 0xfffff8000b9c99a0 "\004��\177\027\025\022\b\003\034\032\031\021\023\026\017\001", c_ispeed = 9600, c_ospeed = 9600}, t_winsize = {ws_row = 30, 
>     ws_col = 80, ws_xpixel = 640, ws_ypixel = 480}, t_column = 0, 
>   t_writepos = 0, t_compatflags = 0, t_termios_init_in = {c_iflag = 11010, 
>     c_oflag = 3, c_cflag = 19200, c_lflag = 1483, 
>     c_cc = 0xfffff8000b9c99e0 "\004��\177\027\025\022\b\003\034\032\031\021\023\026\017\001", c_ispeed = 9600, c_ospeed = 9600}, t_termios_lock_in = {
>     c_iflag = 0, c_oflag = 0, c_cflag = 0, c_lflag = 0, 
>     c_cc = 0xfffff8000b9c9a0c "", c_ispeed = 0, c_ospeed = 0}, 
>   t_termios_init_out = {c_iflag = 11010, c_oflag = 3, c_cflag = 19200, 
>     c_lflag = 1483, 
>     c_cc = 0xfffff8000b9c9a38 "\004��\177\027\025\022\b\003\034\032\031\021\023\026\017\001", c_ispeed = 9600, c_ospeed = 9600}, t_termios_lock_out = {
>     c_iflag = 0, c_oflag = 0, c_cflag = 0, c_lflag = 0, 
>     c_cc = 0xfffff8000b9c9a64 "", c_ispeed = 0, c_ospeed = 0}, 
>   t_devsw = 0xffffffff81885300, t_hook = 0x0, t_pgrp = 0x0, t_session = 0x0, 
>   t_sessioncnt = 0, t_devswsoftc = 0xffffffff8185bd88, t_hooksoftc = 0x0, 
>   t_dev = 0xfffff8000b9d4400}
> (kgdb) p tp->t_dev
> $3 = (struct cdev *) 0xfffff8000b9d4400
> (kgdb) p tp->t_dev->si_name
> $4 = 0xfffff8000b9d44e0 "ttyv0"
> 
> The code in ttydev_leave() is:
> 
> 	/* Drain any output. */
> 	MPASS((tp->t_flags & TF_STOPPED) == 0);
> 	if (!tty_gone(tp))
> 		tty_drain(tp, 1);
> 
> Nothing in tty_drain() sets TF_GONE yet, so this seems to be a guaranteed
> panic.
> 
> Various other places also call tty_drain() when then tty is not "gone"
> including the ioctl's backing tcsetattr().

On a whim, I inverted the assertion and this booted ok for me:

Index: sys/sys/ttydevsw.h
===================================================================
--- sys/sys/ttydevsw.h  (revision 294367)
+++ sys/sys/ttydevsw.h  (working copy)
@@ -188,7 +188,7 @@
 ttydevsw_busy(struct tty *tp)
 {
 
-       MPASS(tty_gone(tp));
+       MPASS(!tty_gone(tp));
 
        return (tp->t_devsw->tsw_busy(tp));
 }

-- 
John Baldwin


More information about the svn-src-head mailing list