CHROMEOS: HACK: Work around bluetooth kernel panic.
authorAndrew de los Reyes <adlr@chromium.org>
Tue, 9 Apr 2013 16:21:10 +0000 (09:21 -0700)
committerChromeBot <chrome-bot@google.com>
Thu, 11 Apr 2013 02:23:17 +0000 (19:23 -0700)
This patch is originally from Doron Keren <doronkeren@ti.com>
http://www.spinics.net/lists/linux-bluetooth/msg15564.html . Original
description:

The patch fixes kernel panic which is due to race condition
between the setup of incomming connection and clean-up of the
dead one. Observed in the following case: attached HID device
disconnects unexpectedly (without performing ACL disconnect ),
the device tries to connect again before the ACL link time-out
fires, this translates to the HCI_DISCONNECT, HCI_CONNECT_REQ
events on the same handle, since HCI_DISCONNECT trigers the clean
up of the HID device and handled in different context, the
linking/unlinking connection object to sysfs, may mess up.

BUG=chromium:228937

TEST=The following used to cause a panic reliably, but now doesn't:
- have Apple Magic Trackpad connected and working
- sleep/wake computer
- immediately click/rub fingers on trackpad

Change-Id: I63e0e37afe572641d7bda593887d2e3269043b5a
Signed-off-by: Ilia Kolominsky <iliak@ti.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/47653
Reviewed-by: Grant Grundler <grundler@chromium.org>
Reviewed-by: Scott James Remnant <keybuk@chromium.org>
Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
Commit-Queue: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Andrew de los Reyes <adlr@chromium.org>
net/bluetooth/hci_sysfs.c

index 55cceee..207f8d3 100644 (file)
@@ -6,6 +6,7 @@
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
+static int acl_conn_index;
 static struct class *bt_class;
 
 struct dentry *bt_debugfs;
@@ -117,7 +118,9 @@ void hci_conn_add_sysfs(struct hci_conn *conn)
 
        BT_DBG("conn %p", conn);
 
-       dev_set_name(&conn->dev, "%s:%d", hdev->name, conn->handle);
+       acl_conn_index++;
+       dev_set_name(&conn->dev, "%s:%d:%d", hdev->name, conn->handle,
+                    acl_conn_index);
 
        if (device_add(&conn->dev) < 0) {
                BT_ERR("Failed to register connection device");