aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2008-04-02 02:58:35 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-02 02:58:35 -0400
commit68845cb2c82275efd7390026bba70c320ca6ef86 (patch)
treed28413ecb9e8695bc3292386d3cfacb76928a668 /net/bluetooth
parent4965291acf8cc2c31dcb2fc7d292a04ee08da2dd (diff)
bluetooth : use lockdep sub-classes for diffrent bluetooth protocol
'rfcomm connect' will trigger lockdep warnings which is caused by locking diffrent kinds of bluetooth sockets at the same time. So using sub-classes per AF_BLUETOOTH sub-type for lockdep. Thanks for the hints from dave jones. --- > From: Dave Jones <davej@codemonkey.org.uk> > Date: Thu, 27 Mar 2008 12:21:56 -0400 > > > Mar 27 08:10:57 localhost kernel: Pid: 3611, comm: obex-data-serve Not tainted 2.6.25-0.121.rc5.git4.fc9 #1 > > Mar 27 08:10:57 localhost kernel: [__lock_acquire+2287/3089] __lock_acquire+0x8ef/0xc11 > > Mar 27 08:10:57 localhost kernel: [sched_clock+8/11] ? sched_clock+0x8/0xb > > Mar 27 08:10:57 localhost kernel: [lock_acquire+106/144] lock_acquire+0x6a/0x90 > > Mar 27 08:10:57 localhost kernel: [<f8bd9321>] ? l2cap_sock_bind+0x29/0x108 [l2cap] > > Mar 27 08:10:57 localhost kernel: [lock_sock_nested+182/198] lock_sock_nested+0xb6/0xc6 > > Mar 27 08:10:57 localhost kernel: [<f8bd9321>] ? l2cap_sock_bind+0x29/0x108 [l2cap] > > Mar 27 08:10:57 localhost kernel: [security_socket_post_create+22/27] ? security_socket_post_create+0x16/0x1b > > Mar 27 08:10:57 localhost kernel: [__sock_create+388/472] ? __sock_create+0x184/0x1d8 > > Mar 27 08:10:57 localhost kernel: [<f8bd9321>] l2cap_sock_bind+0x29/0x108 [l2cap] > > Mar 27 08:10:57 localhost kernel: [kernel_bind+10/13] kernel_bind+0xa/0xd > > Mar 27 08:10:57 localhost kernel: [<f8dad3d7>] rfcomm_dlc_open+0xc8/0x294 [rfcomm] > > Mar 27 08:10:57 localhost kernel: [lock_sock_nested+187/198] ? lock_sock_nested+0xbb/0xc6 > > Mar 27 08:10:57 localhost kernel: [<f8dae18c>] rfcomm_sock_connect+0x8b/0xc2 [rfcomm] > > Mar 27 08:10:57 localhost kernel: [sys_connect+96/125] sys_connect+0x60/0x7d > > Mar 27 08:10:57 localhost kernel: [__lock_acquire+1370/3089] ? __lock_acquire+0x55a/0xc11 > > Mar 27 08:10:57 localhost kernel: [sys_socketcall+140/392] sys_socketcall+0x8c/0x188 > > Mar 27 08:10:57 localhost kernel: [syscall_call+7/11] syscall_call+0x7/0xb --- Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/af_bluetooth.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 1220d8a41eb5..d366423c8392 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -53,6 +53,30 @@
53/* Bluetooth sockets */ 53/* Bluetooth sockets */
54#define BT_MAX_PROTO 8 54#define BT_MAX_PROTO 8
55static struct net_proto_family *bt_proto[BT_MAX_PROTO]; 55static struct net_proto_family *bt_proto[BT_MAX_PROTO];
56
57static struct lock_class_key bt_slock_key[BT_MAX_PROTO];
58static struct lock_class_key bt_lock_key[BT_MAX_PROTO];
59static const char *bt_key_strings[BT_MAX_PROTO] = {
60 "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP",
61 "sk_lock-AF_BLUETOOTH-BTPROTO_HCI",
62 "sk_lock-AF_BLUETOOTH-BTPROTO_SCO",
63 "sk_lock-AF_BLUETOOTH-BTPROTO_RFCOMM",
64 "sk_lock-AF_BLUETOOTH-BTPROTO_BNEP",
65 "sk_lock-AF_BLUETOOTH-BTPROTO_CMTP",
66 "sk_lock-AF_BLUETOOTH-BTPROTO_HIDP",
67 "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP",
68};
69
70static const char *bt_slock_key_strings[BT_MAX_PROTO] = {
71 "slock-AF_BLUETOOTH-BTPROTO_L2CAP",
72 "slock-AF_BLUETOOTH-BTPROTO_HCI",
73 "slock-AF_BLUETOOTH-BTPROTO_SCO",
74 "slock-AF_BLUETOOTH-BTPROTO_RFCOMM",
75 "slock-AF_BLUETOOTH-BTPROTO_BNEP",
76 "slock-AF_BLUETOOTH-BTPROTO_CMTP",
77 "slock-AF_BLUETOOTH-BTPROTO_HIDP",
78 "slock-AF_BLUETOOTH-BTPROTO_AVDTP",
79};
56static DEFINE_RWLOCK(bt_proto_lock); 80static DEFINE_RWLOCK(bt_proto_lock);
57 81
58int bt_sock_register(int proto, struct net_proto_family *ops) 82int bt_sock_register(int proto, struct net_proto_family *ops)
@@ -95,6 +119,21 @@ int bt_sock_unregister(int proto)
95} 119}
96EXPORT_SYMBOL(bt_sock_unregister); 120EXPORT_SYMBOL(bt_sock_unregister);
97 121
122static void bt_reclassify_sock_lock(struct socket *sock, int proto)
123{
124 struct sock *sk = sock->sk;
125
126 if (!sk)
127 return;
128 BUG_ON(sock_owned_by_user(sk));
129
130 sock_lock_init_class_and_name(sk,
131 bt_slock_key_strings[proto],
132 &bt_slock_key[proto],
133 bt_key_strings[proto],
134 &bt_lock_key[proto]);
135}
136
98static int bt_sock_create(struct net *net, struct socket *sock, int proto) 137static int bt_sock_create(struct net *net, struct socket *sock, int proto)
99{ 138{
100 int err; 139 int err;
@@ -117,6 +156,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto)
117 156
118 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { 157 if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
119 err = bt_proto[proto]->create(net, sock, proto); 158 err = bt_proto[proto]->create(net, sock, proto);
159 bt_reclassify_sock_lock(sock, proto);
120 module_put(bt_proto[proto]->owner); 160 module_put(bt_proto[proto]->owner);
121 } 161 }
122 162