summaryrefslogtreecommitdiffstats
path: root/sys/sys/ttyqueue.h
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2017-03-02 04:23:53 +0000
committerian <ian@FreeBSD.org>2017-03-02 04:23:53 +0000
commit441c0c0ed529fc9fb17e0feb520d123e21acb7f5 (patch)
tree798f99c36b3f220290c85d5b78d50866d47b5875 /sys/sys/ttyqueue.h
parenta8e4be5c56fa510af7512ec8fc2bfe5dc41ffe45 (diff)
downloadFreeBSD-src-441c0c0ed529fc9fb17e0feb520d123e21acb7f5.zip
FreeBSD-src-441c0c0ed529fc9fb17e0feb520d123e21acb7f5.tar.gz
MFC r311954, r311996, r312077, r312080:
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. Restructure the tty_drain loop so that device-busy is checked one more time after tty_timedwait() returns an error only if the error is EWOULDBLOCK; other errors cause an immediate return. This fixes the case of the tty disappearing while in tty_drain(). Check tty_gone() after allocating IO buffers. The tty lock has to be dropped then reacquired due to using M_WAITOK, which opens a window in which the tty device can disappear. Check for this and return ENXIO back up the call chain so that callers can cope. Correct the comments about how much buffer is allocated.
Diffstat (limited to 'sys/sys/ttyqueue.h')
-rw-r--r--sys/sys/ttyqueue.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/sys/ttyqueue.h b/sys/sys/ttyqueue.h
index 2d1a565..c8d85d6 100644
--- a/sys/sys/ttyqueue.h
+++ b/sys/sys/ttyqueue.h
@@ -69,7 +69,7 @@ struct ttyoutq {
#ifdef _KERNEL
/* Input queue handling routines. */
-void ttyinq_setsize(struct ttyinq *ti, struct tty *tp, size_t len);
+int ttyinq_setsize(struct ttyinq *ti, struct tty *tp, size_t len);
void ttyinq_free(struct ttyinq *ti);
int ttyinq_read_uio(struct ttyinq *ti, struct tty *tp, struct uio *uio,
size_t readlen, size_t flushlen);
@@ -136,7 +136,7 @@ void ttyinq_line_iterate_from_reprintpos(struct ttyinq *ti,
/* Output queue handling routines. */
void ttyoutq_flush(struct ttyoutq *to);
-void ttyoutq_setsize(struct ttyoutq *to, struct tty *tp, size_t len);
+int ttyoutq_setsize(struct ttyoutq *to, struct tty *tp, size_t len);
void ttyoutq_free(struct ttyoutq *to);
size_t ttyoutq_read(struct ttyoutq *to, void *buf, size_t len);
int ttyoutq_read_uio(struct ttyoutq *to, struct tty *tp, struct uio *uio);
OpenPOWER on IntegriCloud