diff options
author | Octavian Purdila <tavi.purdila@gmail.com> | 2012-01-21 17:28:34 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-15 06:09:26 -0500 |
commit | b5a30dda6598af216c070165ece6068f9f00f33a (patch) | |
tree | 049eff0341a243dbd02af3c83a7166f941177833 | |
parent | 331660637b4e5136602a98200a84f6b65ed8d5be (diff) |
Bluetooth: silence lockdep warning
Since bluetooth uses multiple protocols types, to avoid lockdep
warnings, we need to use different lockdep classes (one for each
protocol type).
This is already done in bt_sock_create but it misses a couple of cases
when new connections are created. This patch corrects that to fix the
following warning:
<4>[ 1864.732366] =======================================================
<4>[ 1864.733030] [ INFO: possible circular locking dependency detected ]
<4>[ 1864.733544] 3.0.16-mid3-00007-gc9a0f62 #3
<4>[ 1864.733883] -------------------------------------------------------
<4>[ 1864.734408] t.android.btclc/4204 is trying to acquire lock:
<4>[ 1864.734869] (rfcomm_mutex){+.+.+.}, at: [<c14970ea>] rfcomm_dlc_close+0x15/0x30
<4>[ 1864.735541]
<4>[ 1864.735549] but task is already holding lock:
<4>[ 1864.736045] (sk_lock-AF_BLUETOOTH){+.+.+.}, at: [<c1498bf7>] lock_sock+0xa/0xc
<4>[ 1864.736732]
<4>[ 1864.736740] which lock already depends on the new lock.
<4>[ 1864.736750]
<4>[ 1864.737428]
<4>[ 1864.737437] the existing dependency chain (in reverse order) is:
<4>[ 1864.738016]
<4>[ 1864.738023] -> #1 (sk_lock-AF_BLUETOOTH){+.+.+.}:
<4>[ 1864.738549] [<c1062273>] lock_acquire+0x104/0x140
<4>[ 1864.738977] [<c13d35c1>] lock_sock_nested+0x58/0x68
<4>[ 1864.739411] [<c1493c33>] l2cap_sock_sendmsg+0x3e/0x76
<4>[ 1864.739858] [<c13d06c3>] __sock_sendmsg+0x50/0x59
<4>[ 1864.740279] [<c13d0ea2>] sock_sendmsg+0x94/0xa8
<4>[ 1864.740687] [<c13d0ede>] kernel_sendmsg+0x28/0x37
<4>[ 1864.741106] [<c14969ca>] rfcomm_send_frame+0x30/0x38
<4>[ 1864.741542] [<c1496a2a>] rfcomm_send_ua+0x58/0x5a
<4>[ 1864.741959] [<c1498447>] rfcomm_run+0x441/0xb52
<4>[ 1864.742365] [<c104f095>] kthread+0x63/0x68
<4>[ 1864.742742] [<c14d5182>] kernel_thread_helper+0x6/0xd
<4>[ 1864.743187]
<4>[ 1864.743193] -> #0 (rfcomm_mutex){+.+.+.}:
<4>[ 1864.743667] [<c1061ada>] __lock_acquire+0x988/0xc00
<4>[ 1864.744100] [<c1062273>] lock_acquire+0x104/0x140
<4>[ 1864.744519] [<c14d2c70>] __mutex_lock_common+0x3b/0x33f
<4>[ 1864.744975] [<c14d303e>] mutex_lock_nested+0x2d/0x36
<4>[ 1864.745412] [<c14970ea>] rfcomm_dlc_close+0x15/0x30
<4>[ 1864.745842] [<c14990d9>] __rfcomm_sock_close+0x5f/0x6b
<4>[ 1864.746288] [<c1499114>] rfcomm_sock_shutdown+0x2f/0x62
<4>[ 1864.746737] [<c13d275d>] sys_socketcall+0x1db/0x422
<4>[ 1864.747165] [<c14d42f0>] syscall_call+0x7/0xb
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r-- | include/net/bluetooth/bluetooth.h | 2 | ||||
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 12 | ||||
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 2 | ||||
-rw-r--r-- | net/bluetooth/rfcomm/sock.c | 2 |
4 files changed, 11 insertions, 7 deletions
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index abaad6ed9b83..4a82ca0bb0b2 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
@@ -256,4 +256,6 @@ void l2cap_exit(void); | |||
256 | int sco_init(void); | 256 | int sco_init(void); |
257 | void sco_exit(void); | 257 | void sco_exit(void); |
258 | 258 | ||
259 | void bt_sock_reclassify_lock(struct sock *sk, int proto); | ||
260 | |||
259 | #endif /* __BLUETOOTH_H */ | 261 | #endif /* __BLUETOOTH_H */ |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index ef92864ac625..72eb187a5f60 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -71,19 +71,16 @@ static const char *const bt_slock_key_strings[BT_MAX_PROTO] = { | |||
71 | "slock-AF_BLUETOOTH-BTPROTO_AVDTP", | 71 | "slock-AF_BLUETOOTH-BTPROTO_AVDTP", |
72 | }; | 72 | }; |
73 | 73 | ||
74 | static inline void bt_sock_reclassify_lock(struct socket *sock, int proto) | 74 | void bt_sock_reclassify_lock(struct sock *sk, int proto) |
75 | { | 75 | { |
76 | struct sock *sk = sock->sk; | 76 | BUG_ON(!sk); |
77 | |||
78 | if (!sk) | ||
79 | return; | ||
80 | |||
81 | BUG_ON(sock_owned_by_user(sk)); | 77 | BUG_ON(sock_owned_by_user(sk)); |
82 | 78 | ||
83 | sock_lock_init_class_and_name(sk, | 79 | sock_lock_init_class_and_name(sk, |
84 | bt_slock_key_strings[proto], &bt_slock_key[proto], | 80 | bt_slock_key_strings[proto], &bt_slock_key[proto], |
85 | bt_key_strings[proto], &bt_lock_key[proto]); | 81 | bt_key_strings[proto], &bt_lock_key[proto]); |
86 | } | 82 | } |
83 | EXPORT_SYMBOL(bt_sock_reclassify_lock); | ||
87 | 84 | ||
88 | int bt_sock_register(int proto, const struct net_proto_family *ops) | 85 | int bt_sock_register(int proto, const struct net_proto_family *ops) |
89 | { | 86 | { |
@@ -145,7 +142,8 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto, | |||
145 | 142 | ||
146 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { | 143 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { |
147 | err = bt_proto[proto]->create(net, sock, proto, kern); | 144 | err = bt_proto[proto]->create(net, sock, proto, kern); |
148 | bt_sock_reclassify_lock(sock, proto); | 145 | if (!err) |
146 | bt_sock_reclassify_lock(sock->sk, proto); | ||
149 | module_put(bt_proto[proto]->owner); | 147 | module_put(bt_proto[proto]->owner); |
150 | } | 148 | } |
151 | 149 | ||
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index c57027f7606f..401d9428ae4c 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
@@ -849,6 +849,8 @@ static struct l2cap_chan *l2cap_sock_new_connection_cb(void *data) | |||
849 | if (!sk) | 849 | if (!sk) |
850 | return NULL; | 850 | return NULL; |
851 | 851 | ||
852 | bt_sock_reclassify_lock(sk, BTPROTO_L2CAP); | ||
853 | |||
852 | l2cap_sock_init(sk, parent); | 854 | l2cap_sock_init(sk, parent); |
853 | 855 | ||
854 | return l2cap_pi(sk)->chan; | 856 | return l2cap_pi(sk)->chan; |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index f066678faeee..22169c3f1482 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -956,6 +956,8 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc * | |||
956 | if (!sk) | 956 | if (!sk) |
957 | goto done; | 957 | goto done; |
958 | 958 | ||
959 | bt_sock_reclassify_lock(sk, BTPROTO_RFCOMM); | ||
960 | |||
959 | rfcomm_sock_init(sk, parent); | 961 | rfcomm_sock_init(sk, parent); |
960 | bacpy(&bt_sk(sk)->src, &src); | 962 | bacpy(&bt_sk(sk)->src, &src); |
961 | bacpy(&bt_sk(sk)->dst, &dst); | 963 | bacpy(&bt_sk(sk)->dst, &dst); |