Date: Tue, 19 Jan 2016 18:36:04 -0800 From: John Baldwin <jhb@freebsd.org> To: Marius Strobl <marius@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r294362 - in head/sys: dev/uart kern sys Message-ID: <1839427.BLR7n8zvy2@ralph.baldwin.cx> In-Reply-To: <2881455.20ba4MY9ds@ralph.baldwin.cx> References: <201601192334.u0JNYST5080954@repo.freebsd.org> <2881455.20ba4MY9ds@ralph.baldwin.cx>
next in thread | previous in thread | raw e-mail | index | archive | help
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 > >=20 > > Log: > > Fix tty_drain() and, thus, TIOCDRAIN of the current tty(4) incarn= ation > > to actually wait until the TX FIFOs of UARTs have be drained befo= re > > returning. This is done by bringing the equivalent of the TS_BUSY= flag > > found in the previous implementation back in an ABI-preserving wa= y. > > Reported and tested by: Patrick Powell > > =20 > > Most likely, drivers for USB-serial-adapters likewise incorporati= ng > > TX FIFOs as well as other terminal devices that buffer output in = some > > form should also provide implementations of tsw_busy. > > =20 > > MFC after:=093 days >=20 > Hmm, I got a panic on boot that I think is from this: >=20 > panic: Assertion tty_gone(tp) failed at /ufs/src-head-clean/sys/sys/t= tydevsw.h:19 > cpuid =3D 8 > KDB: stack backtrace: > db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0= 85c93a430 > 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=3D0xfffff8000b9c9800, leaving=3D= 1) at ttydevsw.h:191 191 MPASS(tty_gone(tp)); Current language: auto; currently minimal (kgdb) p tp $1 =3D (struct tty *) 0xfffff8000b9c9800 (kgdb) p *tp $2 =3D {t_mtx =3D 0xfffff8000b9c9808, t_mtxobj =3D {lock_object =3D { lo_name =3D 0xffffffff81389f66 "ttymtx", lo_flags =3D 16973824, l= o_data =3D 0,=20 lo_witness =3D 0xfffffe0000bafd80}, mtx_lock =3D 1844673527793480= 9088},=20 t_list =3D {tqe_next =3D 0xfffff8000b9c9400, tqe_prev =3D 0xfffff8000= b9c9c28},=20 t_flags =3D 128, t_revokecnt =3D 1, t_inq =3D {ti_firstblock =3D 0xff= fff8001f5c86e0,=20 ti_startblock =3D 0x0, ti_reprintblock =3D 0x0, ti_lastblock =3D 0x= 0,=20 ti_begin =3D 0, ti_linestart =3D 0, ti_reprint =3D 0, ti_end =3D 0,= =20 ti_nblocks =3D 15, ti_quota =3D 15}, t_inlow =3D 1728, t_outq =3D {= to_firstblock =3D 0xfffff8001f4b0900, to_lastblock =3D 0x0, to_begi= n =3D 0,=20 to_end =3D 0, to_nblocks =3D 8, to_quota =3D 8}, t_outlow =3D 1785,= t_inwait =3D { cv_description =3D 0xffffffff81389f45 "ttyin", cv_waiters =3D 0}, t= _outwait =3D { cv_description =3D 0xffffffff81389f4b "ttyout", cv_waiters =3D 0},=20= t_outserwait =3D {cv_description =3D 0xffffffff81389f52 "ttyosr",=20 cv_waiters =3D 0}, t_bgwait =3D {cv_description =3D 0xffffffff81389= f59 "ttybg",=20 cv_waiters =3D 0}, t_dcdwait =3D { cv_description =3D 0xffffffff81389f5f "ttydcd", cv_waiters =3D 0}, = t_inpoll =3D { si_tdlist =3D {tqh_first =3D 0x0, tqh_last =3D 0x0}, si_note =3D {k= l_list =3D { slh_first =3D 0x0}, kl_lock =3D 0xffffffff809dd1e0 <knlist_mtx_= lock>,=20 kl_unlock =3D 0xffffffff809dd200 <knlist_mtx_unlock>,=20 kl_assert_locked =3D 0xffffffff809dd220 <knlist_mtx_assert_locked= >,=20 kl_assert_unlocked =3D 0xffffffff809dd240 <knlist_mtx_assert_unlo= cked>,=20 kl_lockarg =3D 0xfffff8000b9c9808}, si_mtx =3D 0x0}, t_outpoll =3D= { si_tdlist =3D {tqh_first =3D 0x0, tqh_last =3D 0x0}, si_note =3D {k= l_list =3D { slh_first =3D 0x0}, kl_lock =3D 0xffffffff809dd1e0 <knlist_mtx_= lock>,=20 kl_unlock =3D 0xffffffff809dd200 <knlist_mtx_unlock>,=20 ---Type <return> to continue, or q <return> to quit--- kl_assert_locked =3D 0xffffffff809dd220 <knlist_mtx_assert_locked= >,=20 kl_assert_unlocked =3D 0xffffffff809dd240 <knlist_mtx_assert_unlo= cked>,=20 kl_lockarg =3D 0xfffff8000b9c9808}, si_mtx =3D 0x0}, t_sigio =3D = 0x0,=20 t_termios =3D {c_iflag =3D 11010, c_oflag =3D 3, c_cflag =3D 19200, c= _lflag =3D 1483,=20 c_cc =3D 0xfffff8000b9c99a0 "\004=EF=BF=BD=EF=BF=BD\177\027\025\022= \b\003\034\032\031\021\023\026\017\001", c_ispeed =3D 9600, c_ospeed =3D= 9600}, t_winsize =3D {ws_row =3D 30,=20 ws_col =3D 80, ws_xpixel =3D 640, ws_ypixel =3D 480}, t_column =3D = 0,=20 t_writepos =3D 0, t_compatflags =3D 0, t_termios_init_in =3D {c_iflag= =3D 11010,=20 c_oflag =3D 3, c_cflag =3D 19200, c_lflag =3D 1483,=20 c_cc =3D 0xfffff8000b9c99e0 "\004=EF=BF=BD=EF=BF=BD\177\027\025\022= \b\003\034\032\031\021\023\026\017\001", c_ispeed =3D 9600, c_ospeed =3D= 9600}, t_termios_lock_in =3D { c_iflag =3D 0, c_oflag =3D 0, c_cflag =3D 0, c_lflag =3D 0,=20 c_cc =3D 0xfffff8000b9c9a0c "", c_ispeed =3D 0, c_ospeed =3D 0},=20= t_termios_init_out =3D {c_iflag =3D 11010, c_oflag =3D 3, c_cflag =3D= 19200,=20 c_lflag =3D 1483,=20 c_cc =3D 0xfffff8000b9c9a38 "\004=EF=BF=BD=EF=BF=BD\177\027\025\022= \b\003\034\032\031\021\023\026\017\001", c_ispeed =3D 9600, c_ospeed =3D= 9600}, t_termios_lock_out =3D { c_iflag =3D 0, c_oflag =3D 0, c_cflag =3D 0, c_lflag =3D 0,=20 c_cc =3D 0xfffff8000b9c9a64 "", c_ispeed =3D 0, c_ospeed =3D 0},=20= t_devsw =3D 0xffffffff81885300, t_hook =3D 0x0, t_pgrp =3D 0x0, t_ses= sion =3D 0x0,=20 t_sessioncnt =3D 0, t_devswsoftc =3D 0xffffffff8185bd88, t_hooksoftc = =3D 0x0,=20 t_dev =3D 0xfffff8000b9d4400} (kgdb) p tp->t_dev $3 =3D (struct cdev *) 0xfffff8000b9d4400 (kgdb) p tp->t_dev->si_name $4 =3D 0xfffff8000b9d44e0 "ttyv0" The code in ttydev_leave() is: =09/* Drain any output. */ =09MPASS((tp->t_flags & TF_STOPPED) =3D=3D 0); =09if (!tty_gone(tp)) =09=09tty_drain(tp, 1); Nothing in tty_drain() sets TF_GONE yet, so this seems to be a guarante= ed panic. Various other places also call tty_drain() when then tty is not "gone" including the ioctl's backing tcsetattr(). --=20 John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1839427.BLR7n8zvy2>