aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
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/bluetooth
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/bluetooth')
-rw-r--r--drivers/bluetooth/hci_ldisc.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index b3f01996318f..48ad2a7ab080 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -355,29 +355,24 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
355 * flags pointer to flags for data 355 * flags pointer to flags for data
356 * count count of received data in bytes 356 * count count of received data in bytes
357 * 357 *
358 * Return Value: Number of bytes received 358 * Return Value: None
359 */ 359 */
360static unsigned int hci_uart_tty_receive(struct tty_struct *tty, 360static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
361 const u8 *data, char *flags, int count)
362{ 361{
363 struct hci_uart *hu = (void *)tty->disc_data; 362 struct hci_uart *hu = (void *)tty->disc_data;
364 int received;
365 363
366 if (!hu || tty != hu->tty) 364 if (!hu || tty != hu->tty)
367 return -ENODEV; 365 return;
368 366
369 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags)) 367 if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
370 return -EINVAL; 368 return;
371 369
372 spin_lock(&hu->rx_lock); 370 spin_lock(&hu->rx_lock);
373 received = hu->proto->recv(hu, (void *) data, count); 371 hu->proto->recv(hu, (void *) data, count);
374 if (received > 0) 372 hu->hdev->stat.byte_rx += count;
375 hu->hdev->stat.byte_rx += received;
376 spin_unlock(&hu->rx_lock); 373 spin_unlock(&hu->rx_lock);
377 374
378 tty_unthrottle(tty); 375 tty_unthrottle(tty);
379
380 return received;
381} 376}
382 377
383static int hci_uart_register_dev(struct hci_uart *hu) 378static int hci_uart_register_dev(struct hci_uart *hu)