Commit aa2ac881 authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

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: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 721c4181
...@@ -118,7 +118,7 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci ...@@ -118,7 +118,7 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci
read_lock(&conn->chan_lock); read_lock(&conn->chan_lock);
c = __l2cap_get_chan_by_scid(conn, cid); c = __l2cap_get_chan_by_scid(conn, cid);
if (c) if (c)
bh_lock_sock(c->sk); lock_sock(c->sk);
read_unlock(&conn->chan_lock); read_unlock(&conn->chan_lock);
return c; return c;
} }
...@@ -141,7 +141,7 @@ static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn ...@@ -141,7 +141,7 @@ static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn
read_lock(&conn->chan_lock); read_lock(&conn->chan_lock);
c = __l2cap_get_chan_by_ident(conn, ident); c = __l2cap_get_chan_by_ident(conn, ident);
if (c) if (c)
bh_lock_sock(c->sk); lock_sock(c->sk);
read_unlock(&conn->chan_lock); read_unlock(&conn->chan_lock);
return c; return c;
} }
...@@ -889,7 +889,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) ...@@ -889,7 +889,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
parent = pchan->sk; parent = pchan->sk;
bh_lock_sock(parent); lock_sock(parent);
/* Check for backlog size */ /* Check for backlog size */
if (sk_acceptq_is_full(parent)) { if (sk_acceptq_is_full(parent)) {
...@@ -922,7 +922,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) ...@@ -922,7 +922,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
write_unlock_bh(&conn->chan_lock); write_unlock_bh(&conn->chan_lock);
clean: clean:
bh_unlock_sock(parent); release_sock(parent);
} }
static void l2cap_chan_ready(struct sock *sk) static void l2cap_chan_ready(struct sock *sk)
...@@ -1024,9 +1024,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) ...@@ -1024,9 +1024,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
/* Kill channels */ /* Kill channels */
list_for_each_entry_safe(chan, l, &conn->chan_l, list) { list_for_each_entry_safe(chan, l, &conn->chan_l, list) {
sk = chan->sk; sk = chan->sk;
bh_lock_sock(sk); lock_sock(sk);
l2cap_chan_del(chan, err); l2cap_chan_del(chan, err);
bh_unlock_sock(sk); release_sock(sk);
chan->ops->close(chan->data); chan->ops->close(chan->data);
} }
...@@ -2568,7 +2568,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -2568,7 +2568,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
parent = pchan->sk; parent = pchan->sk;
bh_lock_sock(parent); lock_sock(parent);
/* Check if the ACL is secure enough (if not SDP) */ /* Check if the ACL is secure enough (if not SDP) */
if (psm != cpu_to_le16(0x0001) && if (psm != cpu_to_le16(0x0001) &&
...@@ -2645,7 +2645,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -2645,7 +2645,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
write_unlock_bh(&conn->chan_lock); write_unlock_bh(&conn->chan_lock);
response: response:
bh_unlock_sock(parent); release_sock(parent);
sendresp: sendresp:
rsp.scid = cpu_to_le16(scid); rsp.scid = cpu_to_le16(scid);
...@@ -2727,19 +2727,11 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -2727,19 +2727,11 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
break; break;
default: default:
/* don't delete l2cap channel if sk is owned by user */
if (sock_owned_by_user(sk)) {
l2cap_state_change(chan, BT_DISCONN);
__clear_chan_timer(chan);
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
break;
}
l2cap_chan_del(chan, ECONNREFUSED); l2cap_chan_del(chan, ECONNREFUSED);
break; break;
} }
bh_unlock_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -2861,7 +2853,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -2861,7 +2853,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
} }
unlock: unlock:
bh_unlock_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -2968,7 +2960,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr ...@@ -2968,7 +2960,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
} }
done: done:
bh_unlock_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -2997,17 +2989,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -2997,17 +2989,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
sk->sk_shutdown = SHUTDOWN_MASK; sk->sk_shutdown = SHUTDOWN_MASK;
/* don't delete l2cap channel if sk is owned by user */
if (sock_owned_by_user(sk)) {
l2cap_state_change(chan, BT_DISCONN);
__clear_chan_timer(chan);
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
bh_unlock_sock(sk);
return 0;
}
l2cap_chan_del(chan, ECONNRESET); l2cap_chan_del(chan, ECONNRESET);
bh_unlock_sock(sk); release_sock(sk);
chan->ops->close(chan->data); chan->ops->close(chan->data);
return 0; return 0;
...@@ -3031,17 +3014,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd ...@@ -3031,17 +3014,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
sk = chan->sk; sk = chan->sk;
/* don't delete l2cap channel if sk is owned by user */
if (sock_owned_by_user(sk)) {
l2cap_state_change(chan, BT_DISCONN);
__clear_chan_timer(chan);
__set_chan_timer(chan, L2CAP_DISC_TIMEOUT);
bh_unlock_sock(sk);
return 0;
}
l2cap_chan_del(chan, 0); l2cap_chan_del(chan, 0);
bh_unlock_sock(sk); release_sock(sk);
chan->ops->close(chan->data); chan->ops->close(chan->data);
return 0; return 0;
...@@ -4284,7 +4258,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk ...@@ -4284,7 +4258,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
done: done:
if (sk) if (sk)
bh_unlock_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -4300,7 +4274,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str ...@@ -4300,7 +4274,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
sk = chan->sk; sk = chan->sk;
bh_lock_sock(sk); lock_sock(sk);
BT_DBG("sk %p, len %d", sk, skb->len); BT_DBG("sk %p, len %d", sk, skb->len);
...@@ -4318,7 +4292,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str ...@@ -4318,7 +4292,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
done: done:
if (sk) if (sk)
bh_unlock_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -4333,7 +4307,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct ...@@ -4333,7 +4307,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
sk = chan->sk; sk = chan->sk;
bh_lock_sock(sk); lock_sock(sk);
BT_DBG("sk %p, len %d", sk, skb->len); BT_DBG("sk %p, len %d", sk, skb->len);
...@@ -4351,7 +4325,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct ...@@ -4351,7 +4325,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
done: done:
if (sk) if (sk)
bh_unlock_sock(sk); release_sock(sk);
return 0; return 0;
} }
...@@ -4656,11 +4630,11 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl ...@@ -4656,11 +4630,11 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
BT_ERR("Frame exceeding recv MTU (len %d, " BT_ERR("Frame exceeding recv MTU (len %d, "
"MTU %d)", len, "MTU %d)", len,
chan->imtu); chan->imtu);
bh_unlock_sock(sk); release_sock(sk);
l2cap_conn_unreliable(conn, ECOMM); l2cap_conn_unreliable(conn, ECOMM);
goto drop; goto drop;
} }
bh_unlock_sock(sk); release_sock(sk);
} }
/* Allocate skb for the complete frame (with header) */ /* Allocate skb for the complete frame (with header) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment