提交 2c3bb20f 编写于 作者: P Paul Fulghum 提交者: Linus Torvalds

[PATCH] add receive_room flow control to flush_to_ldisc

Flush data serially to line discipline in blocks no larger than
tty->receive_room to avoid losing data if line discipline is busy (such as
N_TTY operating at high speed on heavily loaded system) or does not accept
data in large blocks (such as N_MOUSE).
Signed-off-by: NPaul Fulghum <paulkf@microgate.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 817d6d3b
...@@ -2771,8 +2771,7 @@ static void flush_to_ldisc(void *private_) ...@@ -2771,8 +2771,7 @@ static void flush_to_ldisc(void *private_)
struct tty_struct *tty = (struct tty_struct *) private_; struct tty_struct *tty = (struct tty_struct *) private_;
unsigned long flags; unsigned long flags;
struct tty_ldisc *disc; struct tty_ldisc *disc;
struct tty_buffer *tbuf; struct tty_buffer *tbuf, *head;
int count;
char *char_buf; char *char_buf;
unsigned char *flag_buf; unsigned char *flag_buf;
...@@ -2781,21 +2780,33 @@ static void flush_to_ldisc(void *private_) ...@@ -2781,21 +2780,33 @@ static void flush_to_ldisc(void *private_)
return; return;
spin_lock_irqsave(&tty->buf.lock, flags); spin_lock_irqsave(&tty->buf.lock, flags);
while((tbuf = tty->buf.head) != NULL) { head = tty->buf.head;
while ((count = tbuf->commit - tbuf->read) != 0) { if (head != NULL) {
char_buf = tbuf->char_buf_ptr + tbuf->read; tty->buf.head = NULL;
flag_buf = tbuf->flag_buf_ptr + tbuf->read; for (;;) {
tbuf->read += count; int count = head->commit - head->read;
if (!count) {
if (head->next == NULL)
break;
tbuf = head;
head = head->next;
tty_buffer_free(tty, tbuf);
continue;
}
if (!tty->receive_room) {
schedule_delayed_work(&tty->buf.work, 1);
break;
}
if (count > tty->receive_room)
count = tty->receive_room;
char_buf = head->char_buf_ptr + head->read;
flag_buf = head->flag_buf_ptr + head->read;
head->read += count;
spin_unlock_irqrestore(&tty->buf.lock, flags); spin_unlock_irqrestore(&tty->buf.lock, flags);
disc->receive_buf(tty, char_buf, flag_buf, count); disc->receive_buf(tty, char_buf, flag_buf, count);
spin_lock_irqsave(&tty->buf.lock, flags); spin_lock_irqsave(&tty->buf.lock, flags);
} }
if (tbuf->active) tty->buf.head = head;
break;
tty->buf.head = tbuf->next;
if (tty->buf.head == NULL)
tty->buf.tail = NULL;
tty_buffer_free(tty, tbuf);
} }
spin_unlock_irqrestore(&tty->buf.lock, flags); spin_unlock_irqrestore(&tty->buf.lock, flags);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册