Revert "tty: make receive_buf() return the amout of bytes received"
This reverts commitb1c43f82c5
. 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 commita5660b41af
: "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 ina5660b41af
. 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>
This commit is contained in:
@@ -456,7 +456,7 @@ out:
|
||||
* a block of 6pack data has been received, which can now be decapsulated
|
||||
* and sent on to some IP layer for further processing.
|
||||
*/
|
||||
static unsigned int sixpack_receive_buf(struct tty_struct *tty,
|
||||
static void sixpack_receive_buf(struct tty_struct *tty,
|
||||
const unsigned char *cp, char *fp, int count)
|
||||
{
|
||||
struct sixpack *sp;
|
||||
@@ -464,11 +464,11 @@ static unsigned int sixpack_receive_buf(struct tty_struct *tty,
|
||||
int count1;
|
||||
|
||||
if (!count)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
sp = sp_get(tty);
|
||||
if (!sp)
|
||||
return -ENODEV;
|
||||
return;
|
||||
|
||||
memcpy(buf, cp, count < sizeof(buf) ? count : sizeof(buf));
|
||||
|
||||
@@ -487,8 +487,6 @@ static unsigned int sixpack_receive_buf(struct tty_struct *tty,
|
||||
|
||||
sp_put(sp);
|
||||
tty_unthrottle(tty);
|
||||
|
||||
return count1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -923,14 +923,13 @@ static long mkiss_compat_ioctl(struct tty_struct *tty, struct file *file,
|
||||
* a block of data has been received, which can now be decapsulated
|
||||
* and sent on to the AX.25 layer for further processing.
|
||||
*/
|
||||
static unsigned int mkiss_receive_buf(struct tty_struct *tty,
|
||||
const unsigned char *cp, char *fp, int count)
|
||||
static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp,
|
||||
char *fp, int count)
|
||||
{
|
||||
struct mkiss *ax = mkiss_get(tty);
|
||||
int bytes = count;
|
||||
|
||||
if (!ax)
|
||||
return -ENODEV;
|
||||
return;
|
||||
|
||||
/*
|
||||
* Argh! mtu change time! - costs us the packet part received
|
||||
@@ -940,7 +939,7 @@ static unsigned int mkiss_receive_buf(struct tty_struct *tty,
|
||||
ax_changedmtu(ax);
|
||||
|
||||
/* Read the characters out of the buffer */
|
||||
while (bytes--) {
|
||||
while (count--) {
|
||||
if (fp != NULL && *fp++) {
|
||||
if (!test_and_set_bit(AXF_ERROR, &ax->flags))
|
||||
ax->dev->stats.rx_errors++;
|
||||
@@ -953,8 +952,6 @@ static unsigned int mkiss_receive_buf(struct tty_struct *tty,
|
||||
|
||||
mkiss_put(ax);
|
||||
tty_unthrottle(tty);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user