diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-06-03 17:33:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-06-03 17:33:24 -0400 |
commit | 55db4c64eddf37e31279ec15fe90314713bc9cfa (patch) | |
tree | 4bd186333049c5fcc1eacdff0efc82ac8b80ff5e /drivers/input | |
parent | 1fa7b6a29c61358cc2ca6f64cef4aa0e1a7ca74c (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/input')
-rw-r--r-- | drivers/input/serio/serport.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/drivers/input/serio/serport.c b/drivers/input/serio/serport.c index f3698967edf6..8755f5f3ad37 100644 --- a/drivers/input/serio/serport.c +++ b/drivers/input/serio/serport.c | |||
@@ -120,21 +120,17 @@ static void serport_ldisc_close(struct tty_struct *tty) | |||
120 | * 'interrupt' routine. | 120 | * 'interrupt' routine. |
121 | */ | 121 | */ |
122 | 122 | ||
123 | static unsigned int serport_ldisc_receive(struct tty_struct *tty, | 123 | static void serport_ldisc_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) |
124 | const unsigned char *cp, char *fp, int count) | ||
125 | { | 124 | { |
126 | struct serport *serport = (struct serport*) tty->disc_data; | 125 | struct serport *serport = (struct serport*) tty->disc_data; |
127 | unsigned long flags; | 126 | unsigned long flags; |
128 | unsigned int ch_flags; | 127 | unsigned int ch_flags; |
129 | int ret = 0; | ||
130 | int i; | 128 | int i; |
131 | 129 | ||
132 | spin_lock_irqsave(&serport->lock, flags); | 130 | spin_lock_irqsave(&serport->lock, flags); |
133 | 131 | ||
134 | if (!test_bit(SERPORT_ACTIVE, &serport->flags)) { | 132 | if (!test_bit(SERPORT_ACTIVE, &serport->flags)) |
135 | ret = -EINVAL; | ||
136 | goto out; | 133 | goto out; |
137 | } | ||
138 | 134 | ||
139 | for (i = 0; i < count; i++) { | 135 | for (i = 0; i < count; i++) { |
140 | switch (fp[i]) { | 136 | switch (fp[i]) { |
@@ -156,8 +152,6 @@ static unsigned int serport_ldisc_receive(struct tty_struct *tty, | |||
156 | 152 | ||
157 | out: | 153 | out: |
158 | spin_unlock_irqrestore(&serport->lock, flags); | 154 | spin_unlock_irqrestore(&serport->lock, flags); |
159 | |||
160 | return ret == 0 ? count : ret; | ||
161 | } | 155 | } |
162 | 156 | ||
163 | /* | 157 | /* |