#
f64342e3 |
| 12-Jan-2017 |
Ian Lepore <ian@FreeBSD.org> |
Rework tty_drain() to poll the hardware for completion, and restore drain timeout handling to historical freebsd behavior.
The primary reason for these changes is the need to have tty_drain() call t
Rework tty_drain() to poll the hardware for completion, and restore drain timeout handling to historical freebsd behavior.
The primary reason for these changes is the need to have tty_drain() call ttydevsw_busy() at some reasonable sub-second rate, to poll hardware that doesn't signal an interrupt when the transmit shift register becomes empty (which includes virtually all USB serial hardware). Such hardware hangs in a ttyout wait, because it never gets an opportunity to trigger a wakeup from the sleep in tty_drain() by calling ttydisc_getc() again, after handing the last of the buffered data to the hardware.
While researching the history of changes to tty_drain() I stumbled across some email describing the historical BSD behavior of tcdrain() and close() on serial ports, and the ability of comcontrol(1) to control timeout behavior. Using that and some advice from Bruce Evans as a guide, I've put together these changes to implement the hardware polling and restore the historical timeout behaviors...
- tty_drain() now calls ttydevsw_busy() in a loop at 10 Hz to accomodate hardware that requires polling for busy state.
- The "new historical" behavior for draining during close(2) is retained: the drain timeout is "1 second without making any progress". When the 1-second timeout expires, if the count of bytes remaining in the tty layer buffer is smaller than last time, the timeout is extended for another second. Unfortunately, the same logic cannot be extended all the way down to the hardware, because the interface to that layer is a simple busy/not-busy indication.
- Due to the previous point, an application that needs a guarantee that all data has been transmitted must use TIOCDRAIN/tcdrain(3) before calling close(2).
- The historical behavior of honoring the drainwait setting for TIOCDRAIN (used by tcdrain(3)) is restored.
- The historical kern.drainwait sysctl to control the global default drainwait time is restored, but is now named kern.tty_drainwait.
- The historical default drainwait timeout of 300 seconds is restored.
- Handling of TIOCGDRAINWAIT and TIOCSDRAINWAIT ioctls is restored (this also makes the comcontrol(1) drainwait verb work again).
- Manpages are updated to document these behaviors.
Reviewed by: bde (prior version)
show more ...
|
Revision tags: release/11.0.1, release/11.0.0 |
|
#
e3043798 |
| 30-Apr-2016 |
Pedro F. Giffuni <pfg@FreeBSD.org> |
sys/kern: spelling fixes in comments.
No functional change.
|
Revision tags: release/10.3.0 |
|
#
2414e864 |
| 03-Feb-2016 |
Bjoern A. Zeeb <bz@FreeBSD.org> |
MfH @r295202
Expect to see panics in routing code at least now.
|
#
752d0060 |
| 27-Jan-2016 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r294777 through r294960.
|
#
0e186c0a |
| 27-Jan-2016 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: The FreeBSD Foundation
|
#
2cd5358a |
| 26-Jan-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Don't clear the software flow control flag before draining for last close or assert the bug that it is clear when leaving.
Remove an unrelated rotted comment that was attached to the buggy clearing.
Don't clear the software flow control flag before draining for last close or assert the bug that it is clear when leaving.
Remove an unrelated rotted comment that was attached to the buggy clearing.
Since draining is not done in more cases, flushing is needed in more cases, so start fixing flushing: - do a full flush in ttydisc_close(). State what POSIX requires more clearly. This was missing ttydevsw_pktnotify() calls to tell the devsw layer to flush. Hardware tty drivers don't actually flush since they don't understand this API. - fix 2 missing wakeups in tty_flush(). Most of the wakeups here are unnecessary for last close. But ttydisc_close() did one of the missing ones.
This flow control bug ameliorated the design bug of requiring potentially unbounded waits in draining. Software flow control is the easiest way to get an unbounded wait, and a long wait is sometimes actually useful. Users can type the xoff character on the receiver and (if ixon is set on the sender) expect the output to be held until the user is ready for more.
Hardware flow control can also give the unbounded wait, and this bug didn't affect hardware flow control. Unbounded waits from hardware flow control take a more unusual configuration. E.g., a terminal program that controls the modem status lines, or unplugging the cable in a configuration where this doesn't break the connection.
The design bug is still ameliorated by a newer bug in draining for last close -- the 1 second timeout. E.g., if the user types the xoff character and the sender reaches last close, then output is not resumed and the wait times out after just 1 second. This is broken, but preferable to an unbounded wait. Before this change, the output was resumed immediately and usually completed.
Submitted by: bde MFC after: 2 weeks
show more ...
|
#
88d74d64 |
| 26-Jan-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Restore flushing of output for revoke(2) again. Document revoke()'s intended behaviour in its man page. Simplify tty_drain() to match. Don't call ttydevsw methods in tty_flush() if the device is go
Restore flushing of output for revoke(2) again. Document revoke()'s intended behaviour in its man page. Simplify tty_drain() to match. Don't call ttydevsw methods in tty_flush() if the device is gone since we now sometimes call it then.
The flushing was supposed to be implemented by passing the FNONBLOCK flag to VOP_CLOSE() for revoke(). The tty driver is one of the few that can block in close and was one of the fewer that knew about this.
This almost worked in FreeBSD-1 and similarly in Net/2. These versions only almost worked because there was and is considerable confusion between IO_NDELAY and FNONBLOCK (aka O_NONBLOCK). IO_NDELAY is only valid for VOP_READ() and VOP_WRITE(). For other VOPs it has the same value as O_SHLOCK. But since vfs_subr.c and tty.c consistently used the wrong flag and the O_SHLOCK flag is rarely set, this mostly worked. It also gave the feature than applications could get the non-blocking close by abusing O_SHLOCK.
This was first broken then fixed in 1995. I changed only the tty driver to use FNONBLOCK, as a hack to get non-blocking via the normal flag FNONBLOCK for last closes. I didn't know about revoke()'s use of IO_NDELAY or change it to be consistent, so revoke() was broken. Then I changed revoke() to match.
This was next broken in 1997 then fixed in 1998. Importing Lite2 made the flags inconsistent again by undoing the fix only in vfs_subr.c.
This was next broken in 2008 by replacing everything in tty.c and not checking any flags in last close. Other bugs in draining limited the resulting unbounded waits to drain in some cases.
It is now possible to fix this better using the new FREVOKE flag. Just restore flushing for revoke() for now. Don't restore or undo any hacks for ordinary last closes yet. But remove dead code in the 1-second relative timeout (r272789). This did extra work to extend the buggy draining for revoke() for as long as possible. The 1-second timeout made this not very long by usually flushing after 1 second.
Submitted by: bde MFC after: 2 weeks
show more ...
|
#
14d5c08b |
| 26-Jan-2016 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r294599 through r294776.
|
#
57169cea |
| 25-Jan-2016 |
Marius Strobl <marius@FreeBSD.org> |
- Make the code consistent with itself style-wise and bring it closer to style(9). - Mark unused arguments as such. - Make the ttystates table const.
|
#
2e77021e |
| 25-Jan-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Don't allow opening the callout device when the callin device is already open (in disguise as the console device). The only allowed combination was supposed to be the callin device with the console.
Don't allow opening the callout device when the callin device is already open (in disguise as the console device). The only allowed combination was supposed to be the callin device with the console.
Fix the assertion in ttydev_close() that was meant to detect this (it only detected all 3 devices being open). Assert this in ttydev_open() too.
Submitted by: bde MFC after: 2 weeks
show more ...
|
#
3593a18a |
| 25-Jan-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Fix the %b flags string for ddb. All bits above the 5th (TF_OPENED_CONS) were broken in r188147 by adding TF_OPENED_CONS without updating the string. It was especially confusing to display OPENED_C
Fix the %b flags string for ddb. All bits above the 5th (TF_OPENED_CONS) were broken in r188147 by adding TF_OPENED_CONS without updating the string. It was especially confusing to display OPENED_CONS as GONE and BYPASS as ZOMBIE. 2 flags at the end were not updated in r188487.
Don't print an extra 0x prefix for %p in a ddb command. In the rest of the kernel there are more than 6000 lines with %p and only about 40 with this bug.
Print a non-extra 0x prefix for %b in a ddb command. In the rest of the kernel, there are approx. 180 lines with %b and 2/3 of them have this bug.
Submitted by: bde MFC after: 2 weeks
show more ...
|
#
f9421853 |
| 25-Jan-2016 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: The FreeBSD Foundation
|
#
d9b9dae1 |
| 22-Jan-2016 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r294169 through r294598.
|
#
fa28b6e7 |
| 22-Jan-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
In tty_dealloc(), clear the queues. See the comment for a scenario which explains why ttydev_leave() cleanup might not happen.
Submitted by: bde MFC after: 3 weeks
|
#
009e81b1 |
| 22-Jan-2016 |
Bjoern A. Zeeb <bz@FreeBSD.org> |
MFH @r294567
|
#
59d43d11 |
| 20-Jan-2016 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: The FreeBSD Foundation
|
#
9750d9e5 |
| 20-Jan-2016 |
Marius Strobl <marius@FreeBSD.org> |
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
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
show more ...
|
#
e6068002 |
| 12-Jan-2016 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: The FreeBSD Foundation
|
#
b229c1a0 |
| 08-Jan-2016 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r293280 through r293429.
|
#
0de14554 |
| 07-Jan-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Convert tty common code to use make_dev_s().
Tty.c was untypical in that it handled the si_drv1 issue consistently and correctly, by always checking for si_drv1 being non-NULL and sleeping if NULL.
Convert tty common code to use make_dev_s().
Tty.c was untypical in that it handled the si_drv1 issue consistently and correctly, by always checking for si_drv1 being non-NULL and sleeping if NULL. The removed code also illustrated unneeded complications in drivers which are eliminated by the use of new KPI.
Reviewed by: hps, jhb Discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D4746
show more ...
|
Revision tags: release/10.2.0 |
|
#
98e0ffae |
| 27-May-2015 |
Simon J. Gerraty <sjg@FreeBSD.org> |
Merge sync of head
|
#
fa1e92b6 |
| 04-Mar-2015 |
Baptiste Daroussin <bapt@FreeBSD.org> |
Merge from head
|
#
072aeeb6 |
| 02-Mar-2015 |
Navdeep Parhar <np@FreeBSD.org> |
Merge r278538 through r279514.
|
#
0d36d957 |
| 19-Feb-2015 |
Dimitry Andric <dim@FreeBSD.org> |
Merging ^/head r278916 through r279022.
|
#
6c787c8f |
| 18-Feb-2015 |
Glen Barber <gjb@FreeBSD.org> |
MFH: r278593-r278966
Sponsored by: The FreeBSD Foundation
|