Skip to content

Commit aa2ac88

Browse files
author
Gustavo F. Padovan
committed
Bluetooth: Don't use spin_lock socket lock anymore
We now run everything in process context, so the mutex lock is the best option. But in some places we still need the bh_lock_sock() Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 721c418 commit aa2ac88

1 file changed

Lines changed: 20 additions & 46 deletions

File tree

‎net/bluetooth/l2cap_core.c‎

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci
118118
read_lock(&conn->chan_lock);
119119
c = __l2cap_get_chan_by_scid(conn, cid);
120120
if (c)
121-
bh_lock_sock(c->sk);
121+
lock_sock(c->sk);
122122
read_unlock(&conn->chan_lock);
123123
return c;
124124
}
@@ -141,7 +141,7 @@ static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn
141141
read_lock(&conn->chan_lock);
142142
c = __l2cap_get_chan_by_ident(conn, ident);
143143
if (c)
144-
bh_lock_sock(c->sk);
144+
lock_sock(c->sk);
145145
read_unlock(&conn->chan_lock);
146146
return c;
147147
}
@@ -889,7 +889,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
889889

890890
parent = pchan->sk;
891891

892-
bh_lock_sock(parent);
892+
lock_sock(parent);
893893

894894
/* Check for backlog size */
895895
if (sk_acceptq_is_full(parent)) {
@@ -922,7 +922,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
922922
write_unlock_bh(&conn->chan_lock);
923923

924924
clean:
925-
bh_unlock_sock(parent);
925+
release_sock(parent);
926926
}
927927

928928
static void l2cap_chan_ready(struct sock *sk)
@@ -1024,9 +1024,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
10241024
/* Kill channels */
10251025
list_for_each_entry_safe(chan, l, &conn->chan_l, list) {
10261026
sk = chan->sk;
1027-
bh_lock_sock(sk);
1027+
lock_sock(sk);
10281028
l2cap_chan_del(chan, err);
1029-
bh_unlock_sock(sk);
1029+
release_sock(sk);
10301030
chan->ops->close(chan->data);
10311031
}
10321032

@@ -2568,7 +2568,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
25682568

25692569
parent = pchan->sk;
25702570

2571-
bh_lock_sock(parent);
2571+
lock_sock(parent);
25722572

25732573
/* Check if the ACL is secure enough (if not SDP) */
25742574
if (psm != cpu_to_le16(0x0001) &&
@@ -2645,7 +2645,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
26452645
write_unlock_bh(&conn->chan_lock);
26462646

26472647
response:
2648-
bh_unlock_sock(parent);
2648+
release_sock(parent);
26492649

26502650
sendresp:
26512651
rsp.scid = cpu_to_le16(scid);
@@ -2727,19 +2727,11 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
27272727
break;
27282728

27292729
default:
2730-
/* don't delete l2cap channel if sk is owned by user */
2731-
if (sock_owned_by_user(sk)) {
2732-
l2cap_state_change(chan, BT_DISCONN);
2733-
__clear_chan_timer(chan);
2734-
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
2735-
break;
2736-
}
2737-
27382730
l2cap_chan_del(chan, ECONNREFUSED);
27392731
break;
27402732
}
27412733

2742-
bh_unlock_sock(sk);
2734+
release_sock(sk);
27432735
return 0;
27442736
}
27452737

@@ -2861,7 +2853,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
28612853
}
28622854

28632855
unlock:
2864-
bh_unlock_sock(sk);
2856+
release_sock(sk);
28652857
return 0;
28662858
}
28672859

@@ -2968,7 +2960,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
29682960
}
29692961

29702962
done:
2971-
bh_unlock_sock(sk);
2963+
release_sock(sk);
29722964
return 0;
29732965
}
29742966

@@ -2997,17 +2989,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
29972989

29982990
sk->sk_shutdown = SHUTDOWN_MASK;
29992991

3000-
/* don't delete l2cap channel if sk is owned by user */
3001-
if (sock_owned_by_user(sk)) {
3002-
l2cap_state_change(chan, BT_DISCONN);
3003-
__clear_chan_timer(chan);
3004-
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
3005-
bh_unlock_sock(sk);
3006-
return 0;
3007-
}
3008-
30092992
l2cap_chan_del(chan, ECONNRESET);
3010-
bh_unlock_sock(sk);
2993+
release_sock(sk);
30112994

30122995
chan->ops->close(chan->data);
30132996
return 0;
@@ -3031,17 +3014,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
30313014

30323015
sk = chan->sk;
30333016

3034-
/* don't delete l2cap channel if sk is owned by user */
3035-
if (sock_owned_by_user(sk)) {
3036-
l2cap_state_change(chan, BT_DISCONN);
3037-
__clear_chan_timer(chan);
3038-
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
3039-
bh_unlock_sock(sk);
3040-
return 0;
3041-
}
3042-
30433017
l2cap_chan_del(chan, 0);
3044-
bh_unlock_sock(sk);
3018+
release_sock(sk);
30453019

30463020
chan->ops->close(chan->data);
30473021
return 0;
@@ -4284,7 +4258,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
42844258

42854259
done:
42864260
if (sk)
4287-
bh_unlock_sock(sk);
4261+
release_sock(sk);
42884262

42894263
return 0;
42904264
}
@@ -4300,7 +4274,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
43004274

43014275
sk = chan->sk;
43024276

4303-
bh_lock_sock(sk);
4277+
lock_sock(sk);
43044278

43054279
BT_DBG("sk %p, len %d", sk, skb->len);
43064280

@@ -4318,7 +4292,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
43184292

43194293
done:
43204294
if (sk)
4321-
bh_unlock_sock(sk);
4295+
release_sock(sk);
43224296
return 0;
43234297
}
43244298

@@ -4333,7 +4307,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
43334307

43344308
sk = chan->sk;
43354309

4336-
bh_lock_sock(sk);
4310+
lock_sock(sk);
43374311

43384312
BT_DBG("sk %p, len %d", sk, skb->len);
43394313

@@ -4351,7 +4325,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
43514325

43524326
done:
43534327
if (sk)
4354-
bh_unlock_sock(sk);
4328+
release_sock(sk);
43554329
return 0;
43564330
}
43574331

@@ -4656,11 +4630,11 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
46564630
BT_ERR("Frame exceeding recv MTU (len %d, "
46574631
"MTU %d)", len,
46584632
chan->imtu);
4659-
bh_unlock_sock(sk);
4633+
release_sock(sk);
46604634
l2cap_conn_unreliable(conn, ECOMM);
46614635
goto drop;
46624636
}
4663-
bh_unlock_sock(sk);
4637+
release_sock(sk);
46644638
}
46654639

46664640
/* Allocate skb for the complete frame (with header) */

0 commit comments

Comments
 (0)