aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_buffer.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-06-03 17:33:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-06-03 17:33:24 -0400
commit55db4c64eddf37e31279ec15fe90314713bc9cfa (patch)
tree4bd186333049c5fcc1eacdff0efc82ac8b80ff5e /drivers/tty/tty_buffer.c
parent1fa7b6a29c61358cc2ca6f64cef4aa0e1a7ca74c (diff)
Revert "tty: make receive_buf() return the amout of bytes received"
This reverts commit b1c43f82c5aa265442f82dba31ce985ebb7aa71c. It was broken in so many ways, and results in random odd pty issues. It re-introduced the buggy schedule_work() in flush_to_ldisc() that can cause endless work-loops (see commit a5660b41af6a: "tty: fix endless work loop when the buffer fills up"). It also used an "unsigned int" return value fo the ->receive_buf() function, but then made multiple functions return a negative error code, and didn't actually check for the error in the caller. And it didn't actually work at all. BenH bisected down odd tty behavior to it: "It looks like the patch is causing some major malfunctions of the X server for me, possibly related to PTYs. For example, cat'ing a large file in a gnome terminal hangs the kernel for -minutes- in a loop of what looks like flush_to_ldisc/workqueue code, (some ftrace data in the quoted bits further down). ... Some more data: It -looks- like what happens is that the flush_to_ldisc work queue entry constantly re-queues itself (because the PTY is full ?) and the workqueue thread will basically loop forver calling it without ever scheduling, thus starving the consumer process that could have emptied the PTY." which is pretty much exactly the problem we fixed in a5660b41af6a. Milton Miller pointed out the 'unsigned int' issue. Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reported-by: Milton Miller <miltonm@bga.com> Cc: Stefan Bigler <stefan.bigler@keymile.com> Cc: Toby Gray <toby.gray@realvnc.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Greg Kroah-Hartman <gregkh@suse.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/tty/tty_buffer.c')
-rw-r--r--drivers/tty/tty_buffer.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 46de2e075da..f1a7918d71a 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -416,7 +416,6 @@ static void flush_to_ldisc(struct work_struct *work)
416 struct tty_buffer *head, *tail = tty->buf.tail; 416 struct tty_buffer *head, *tail = tty->buf.tail;
417 int seen_tail = 0; 417 int seen_tail = 0;
418 while ((head = tty->buf.head) != NULL) { 418 while ((head = tty->buf.head) != NULL) {
419 int copied;
420 int count; 419 int count;
421 char *char_buf; 420 char *char_buf;
422 unsigned char *flag_buf; 421 unsigned char *flag_buf;
@@ -443,19 +442,17 @@ static void flush_to_ldisc(struct work_struct *work)
443 line discipline as we want to empty the queue */ 442 line discipline as we want to empty the queue */
444 if (test_bit(TTY_FLUSHPENDING, &tty->flags)) 443 if (test_bit(TTY_FLUSHPENDING, &tty->flags))
445 break; 444 break;
445 if (!tty->receive_room || seen_tail)
446 break;
447 if (count > tty->receive_room)
448 count = tty->receive_room;
446 char_buf = head->char_buf_ptr + head->read; 449 char_buf = head->char_buf_ptr + head->read;
447 flag_buf = head->flag_buf_ptr + head->read; 450 flag_buf = head->flag_buf_ptr + head->read;
451 head->read += count;
448 spin_unlock_irqrestore(&tty->buf.lock, flags); 452 spin_unlock_irqrestore(&tty->buf.lock, flags);
449 copied = disc->ops->receive_buf(tty, char_buf, 453 disc->ops->receive_buf(tty, char_buf,
450 flag_buf, count); 454 flag_buf, count);
451 spin_lock_irqsave(&tty->buf.lock, flags); 455 spin_lock_irqsave(&tty->buf.lock, flags);
452
453 head->read += copied;
454
455 if (copied == 0 || seen_tail) {
456 schedule_work(&tty->buf.work);
457 break;
458 }
459 } 456 }
460 clear_bit(TTY_FLUSHING, &tty->flags); 457 clear_bit(TTY_FLUSHING, &tty->flags);
461 } 458 }