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
This commit is contained in:
Ed Schouten 2009-10-19 07:17:37 +00:00
parent 23b5fd2285
commit 6015f6f35a
2 changed files with 16 additions and 2 deletions

View File

@ -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

View File

@ -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)
{