Bluetooth: hci_ldisc: watchdog timeout while BT file transfer

Serial core's uart_write_wakeup( ) is used to unthrottle line
discipline to send more data notifying that there is less number
of data available in TTY circular buffer by MSM HSUART driver with
uart port spinlock acquire. Here serial core is calling
HCI Line Discipline driver's hci_uart_tty_wakeup( ) without scheduling
tasklet in 3.4 kernel compare to 3.0 kernel. Due to that HCI
Line Discipline driver pushes all available data to TTY Core as part of
hardirq context in 3.4 kernel compare to softirq context on 3.0 kernel,
which is causing watchdog timeout issue. Hence move all
hci_uart_tty_wakeup() work to tasklet context to resolve this issue.

Change-Id: I7e5d98d3cda7b6c862e97799cddbfbe97a28467f
Signed-off-by: Ram Mohan Korukonda <rkorukon@codeaurora.org>
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 121bf7c9..5c04693 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -4,7 +4,7 @@
  *
  *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
  *  Copyright (C) 2004-2005  Marcel Holtmann <marcel@holtmann.org>
- *  Copyright (c) 2000-2001, 2010-2011, Code Aurora Forum. All rights reserved.
+ *  Copyright (c) 2000-2001, 2010-2012, Code Aurora Forum. All rights reserved.
  *
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -51,6 +51,7 @@
 static bool reset = 0;
 
 static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO];
+static void hci_uart_tty_wakeup_action(unsigned long data);
 
 int hci_uart_register_proto(struct hci_uart_proto *p)
 {
@@ -276,6 +277,8 @@
 	tty->receive_room = 65536;
 
 	spin_lock_init(&hu->rx_lock);
+	tasklet_init(&hu->tty_wakeup_task, hci_uart_tty_wakeup_action,
+			 (unsigned long)hu);
 
 	/* Flush any pending characters in the driver and line discipline. */
 
@@ -309,6 +312,8 @@
 		if (hdev)
 			hci_uart_close(hdev);
 
+		tasklet_kill(&hu->tty_wakeup_task);
+
 		if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) {
 			hu->proto->close(hu);
 			if (hdev) {
@@ -323,6 +328,8 @@
  *
  *    Callback for transmit wakeup. Called when low level
  *    device driver can accept more send data.
+ *    This callback gets called from the isr context so
+ *    schedule the send data operation to tasklet.
  *
  * Arguments:        tty    pointer to associated tty instance data
  * Return Value:    None
@@ -330,12 +337,26 @@
 static void hci_uart_tty_wakeup(struct tty_struct *tty)
 {
 	struct hci_uart *hu = (void *)tty->disc_data;
+	tasklet_schedule(&hu->tty_wakeup_task);
+}
+
+/* hci_uart_tty_wakeup_action()
+ *
+ * Scheduled action to transmit data when low level device
+ * driver can accept more data.
+ */
+static void hci_uart_tty_wakeup_action(unsigned long data)
+{
+	struct hci_uart *hu = (struct hci_uart *)data;
+	struct tty_struct *tty;
 
 	BT_DBG("");
 
 	if (!hu)
 		return;
 
+	tty = hu->tty;
+
 	clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
 
 	if (tty != hu->tty)