summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-10-19 07:17:37 +0000
committered <ed@FreeBSD.org>2009-10-19 07:17:37 +0000
commitd92da0f1c09a2f4ad0c89cde70730ba61a90c4e1 (patch)
treee5b553b26bb78eec8b8bd6b72dd2d03c7da28716
parentdc93fde3ad5398c4dda4df4aa39db70ffbf4e889 (diff)
downloadFreeBSD-src-d92da0f1c09a2f4ad0c89cde70730ba61a90c4e1.zip
FreeBSD-src-d92da0f1c09a2f4ad0c89cde70730ba61a90c4e1.tar.gz
Properly set the low watermarks when reducing the baud rate.
Now that buffers are deallocated lazily, we should not use tty*q_getsize() to obtain the buffer size to calculate the low watermarks. Doing this may cause the watermark to be placed outside the typical buffer size. This caused some regressions after my previous commit to the TTY code, which allows pseudo-devices to resize the buffers as well. Reported by: yongari, dougb MFC after: 1 week
-rw-r--r--sys/kern/tty.c4
-rw-r--r--sys/sys/ttyqueue.h14
2 files changed, 16 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index a3db944..81f6741 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -109,14 +109,14 @@ tty_watermarks(struct tty *tp)
ttyinq_setsize(&tp->t_inq, tp, bs);
/* Set low watermark at 10% (when 90% is available). */
- tp->t_inlow = (ttyinq_getsize(&tp->t_inq) * 9) / 10;
+ tp->t_inlow = (ttyinq_getallocatedsize(&tp->t_inq) * 9) / 10;
/* Provide an ouput buffer for 0.2 seconds of data. */
bs = MIN(tp->t_termios.c_ospeed / 5, TTYBUF_MAX);
ttyoutq_setsize(&tp->t_outq, tp, bs);
/* Set low watermark at 10% (when 90% is available). */
- tp->t_outlow = (ttyoutq_getsize(&tp->t_outq) * 9) / 10;
+ tp->t_outlow = (ttyoutq_getallocatedsize(&tp->t_outq) * 9) / 10;
}
static int
diff --git a/sys/sys/ttyqueue.h b/sys/sys/ttyqueue.h
index aac6b3c..2d1a565 100644
--- a/sys/sys/ttyqueue.h
+++ b/sys/sys/ttyqueue.h
@@ -93,6 +93,13 @@ ttyinq_getsize(struct ttyinq *ti)
}
static __inline size_t
+ttyinq_getallocatedsize(struct ttyinq *ti)
+{
+
+ return (ti->ti_quota * TTYINQ_DATASIZE);
+}
+
+static __inline size_t
ttyinq_bytesleft(struct ttyinq *ti)
{
size_t len;
@@ -143,6 +150,13 @@ ttyoutq_getsize(struct ttyoutq *to)
}
static __inline size_t
+ttyoutq_getallocatedsize(struct ttyoutq *to)
+{
+
+ return (to->to_quota * TTYOUTQ_DATASIZE);
+}
+
+static __inline size_t
ttyoutq_bytesleft(struct ttyoutq *to)
{
size_t len;
OpenPOWER on IntegriCloud