From 6015f6f35ab809eb00b4a97332d433a7caabf2b4 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Mon, 19 Oct 2009 07:17:37 +0000 Subject: [PATCH] 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 --- sys/kern/tty.c | 4 ++-- sys/sys/ttyqueue.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index a3db944e7c44..81f674163f6b 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 aac6b3c011f9..2d1a565af965 100644 --- a/sys/sys/ttyqueue.h +++ b/sys/sys/ttyqueue.h @@ -92,6 +92,13 @@ ttyinq_getsize(struct ttyinq *ti) return (ti->ti_nblocks * TTYINQ_DATASIZE); } +static __inline size_t +ttyinq_getallocatedsize(struct ttyinq *ti) +{ + + return (ti->ti_quota * TTYINQ_DATASIZE); +} + static __inline size_t ttyinq_bytesleft(struct ttyinq *ti) { @@ -142,6 +149,13 @@ ttyoutq_getsize(struct ttyoutq *to) return (to->to_nblocks * TTYOUTQ_DATASIZE); } +static __inline size_t +ttyoutq_getallocatedsize(struct ttyoutq *to) +{ + + return (to->to_quota * TTYOUTQ_DATASIZE); +} + static __inline size_t ttyoutq_bytesleft(struct ttyoutq *to) {