diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-06-24 00:53:01 -0400 |
---|---|---|
committer | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-12-18 14:07:55 -0500 |
commit | aa2ac881ba1e4e9f878be2ece80001ae8563955c (patch) | |
tree | fd6d65e145d42700226b8894738772d3fd6ddbe6 | |
parent | 721c41812daf7b38759942563773a7832e3c990d (diff) |
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>
-rw-r--r-- | net/bluetooth/l2cap_core.c | 66 |
1 files changed, 20 insertions, 46 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 89cda6d82d0c..ed67ac0ca21c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
@@ -118,7 +118,7 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 ci | |||
118 | read_lock(&conn->chan_lock); | 118 | read_lock(&conn->chan_lock); |
119 | c = __l2cap_get_chan_by_scid(conn, cid); | 119 | c = __l2cap_get_chan_by_scid(conn, cid); |
120 | if (c) | 120 | if (c) |
121 | bh_lock_sock(c->sk); | 121 | lock_sock(c->sk); |
122 | read_unlock(&conn->chan_lock); | 122 | read_unlock(&conn->chan_lock); |
123 | return c; | 123 | return c; |
124 | } | 124 | } |
@@ -141,7 +141,7 @@ static inline struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn | |||
141 | read_lock(&conn->chan_lock); | 141 | read_lock(&conn->chan_lock); |
142 | c = __l2cap_get_chan_by_ident(conn, ident); | 142 | c = __l2cap_get_chan_by_ident(conn, ident); |
143 | if (c) | 143 | if (c) |
144 | bh_lock_sock(c->sk); | 144 | lock_sock(c->sk); |
145 | read_unlock(&conn->chan_lock); | 145 | read_unlock(&conn->chan_lock); |
146 | return c; | 146 | return c; |
147 | } | 147 | } |
@@ -889,7 +889,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) | |||
889 | 889 | ||
890 | parent = pchan->sk; | 890 | parent = pchan->sk; |
891 | 891 | ||
892 | bh_lock_sock(parent); | 892 | lock_sock(parent); |
893 | 893 | ||
894 | /* Check for backlog size */ | 894 | /* Check for backlog size */ |
895 | if (sk_acceptq_is_full(parent)) { | 895 | if (sk_acceptq_is_full(parent)) { |
@@ -922,7 +922,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn) | |||
922 | write_unlock_bh(&conn->chan_lock); | 922 | write_unlock_bh(&conn->chan_lock); |
923 | 923 | ||
924 | clean: | 924 | clean: |
925 | bh_unlock_sock(parent); | 925 | release_sock(parent); |
926 | } | 926 | } |
927 | 927 | ||
928 | static void l2cap_chan_ready(struct sock *sk) | 928 | static void l2cap_chan_ready(struct sock *sk) |
@@ -1024,9 +1024,9 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err) | |||
1024 | /* Kill channels */ | 1024 | /* Kill channels */ |
1025 | list_for_each_entry_safe(chan, l, &conn->chan_l, list) { | 1025 | list_for_each_entry_safe(chan, l, &conn->chan_l, list) { |
1026 | sk = chan->sk; | 1026 | sk = chan->sk; |
1027 | bh_lock_sock(sk); | 1027 | lock_sock(sk); |
1028 | l2cap_chan_del(chan, err); | 1028 | l2cap_chan_del(chan, err); |
1029 | bh_unlock_sock(sk); | 1029 | release_sock(sk); |
1030 | chan->ops->close(chan->data); | 1030 | chan->ops->close(chan->data); |
1031 | } | 1031 | } |
1032 | 1032 | ||
@@ -2568,7 +2568,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
2568 | 2568 | ||
2569 | parent = pchan->sk; | 2569 | parent = pchan->sk; |
2570 | 2570 | ||
2571 | bh_lock_sock(parent); | 2571 | lock_sock(parent); |
2572 | 2572 | ||
2573 | /* Check if the ACL is secure enough (if not SDP) */ | 2573 | /* Check if the ACL is secure enough (if not SDP) */ |
2574 | if (psm != cpu_to_le16(0x0001) && | 2574 | 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 | write_unlock_bh(&conn->chan_lock); | 2645 | write_unlock_bh(&conn->chan_lock); |
2646 | 2646 | ||
2647 | response: | 2647 | response: |
2648 | bh_unlock_sock(parent); | 2648 | release_sock(parent); |
2649 | 2649 | ||
2650 | sendresp: | 2650 | sendresp: |
2651 | rsp.scid = cpu_to_le16(scid); | 2651 | 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 | break; | 2727 | break; |
2728 | 2728 | ||
2729 | default: | 2729 | 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 | |||
2738 | l2cap_chan_del(chan, ECONNREFUSED); | 2730 | l2cap_chan_del(chan, ECONNREFUSED); |
2739 | break; | 2731 | break; |
2740 | } | 2732 | } |
2741 | 2733 | ||
2742 | bh_unlock_sock(sk); | 2734 | release_sock(sk); |
2743 | return 0; | 2735 | return 0; |
2744 | } | 2736 | } |
2745 | 2737 | ||
@@ -2861,7 +2853,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2861 | } | 2853 | } |
2862 | 2854 | ||
2863 | unlock: | 2855 | unlock: |
2864 | bh_unlock_sock(sk); | 2856 | release_sock(sk); |
2865 | return 0; | 2857 | return 0; |
2866 | } | 2858 | } |
2867 | 2859 | ||
@@ -2968,7 +2960,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
2968 | } | 2960 | } |
2969 | 2961 | ||
2970 | done: | 2962 | done: |
2971 | bh_unlock_sock(sk); | 2963 | release_sock(sk); |
2972 | return 0; | 2964 | return 0; |
2973 | } | 2965 | } |
2974 | 2966 | ||
@@ -2997,17 +2989,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd | |||
2997 | 2989 | ||
2998 | sk->sk_shutdown = SHUTDOWN_MASK; | 2990 | sk->sk_shutdown = SHUTDOWN_MASK; |
2999 | 2991 | ||
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 | |||
3009 | l2cap_chan_del(chan, ECONNRESET); | 2992 | l2cap_chan_del(chan, ECONNRESET); |
3010 | bh_unlock_sock(sk); | 2993 | release_sock(sk); |
3011 | 2994 | ||
3012 | chan->ops->close(chan->data); | 2995 | chan->ops->close(chan->data); |
3013 | return 0; | 2996 | return 0; |
@@ -3031,17 +3014,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd | |||
3031 | 3014 | ||
3032 | sk = chan->sk; | 3015 | sk = chan->sk; |
3033 | 3016 | ||
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 | |||
3043 | l2cap_chan_del(chan, 0); | 3017 | l2cap_chan_del(chan, 0); |
3044 | bh_unlock_sock(sk); | 3018 | release_sock(sk); |
3045 | 3019 | ||
3046 | chan->ops->close(chan->data); | 3020 | chan->ops->close(chan->data); |
3047 | return 0; | 3021 | return 0; |
@@ -4284,7 +4258,7 @@ drop: | |||
4284 | 4258 | ||
4285 | done: | 4259 | done: |
4286 | if (sk) | 4260 | if (sk) |
4287 | bh_unlock_sock(sk); | 4261 | release_sock(sk); |
4288 | 4262 | ||
4289 | return 0; | 4263 | return 0; |
4290 | } | 4264 | } |
@@ -4300,7 +4274,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str | |||
4300 | 4274 | ||
4301 | sk = chan->sk; | 4275 | sk = chan->sk; |
4302 | 4276 | ||
4303 | bh_lock_sock(sk); | 4277 | lock_sock(sk); |
4304 | 4278 | ||
4305 | BT_DBG("sk %p, len %d", sk, skb->len); | 4279 | BT_DBG("sk %p, len %d", sk, skb->len); |
4306 | 4280 | ||
@@ -4318,7 +4292,7 @@ drop: | |||
4318 | 4292 | ||
4319 | done: | 4293 | done: |
4320 | if (sk) | 4294 | if (sk) |
4321 | bh_unlock_sock(sk); | 4295 | release_sock(sk); |
4322 | return 0; | 4296 | return 0; |
4323 | } | 4297 | } |
4324 | 4298 | ||
@@ -4333,7 +4307,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct | |||
4333 | 4307 | ||
4334 | sk = chan->sk; | 4308 | sk = chan->sk; |
4335 | 4309 | ||
4336 | bh_lock_sock(sk); | 4310 | lock_sock(sk); |
4337 | 4311 | ||
4338 | BT_DBG("sk %p, len %d", sk, skb->len); | 4312 | BT_DBG("sk %p, len %d", sk, skb->len); |
4339 | 4313 | ||
@@ -4351,7 +4325,7 @@ drop: | |||
4351 | 4325 | ||
4352 | done: | 4326 | done: |
4353 | if (sk) | 4327 | if (sk) |
4354 | bh_unlock_sock(sk); | 4328 | release_sock(sk); |
4355 | return 0; | 4329 | return 0; |
4356 | } | 4330 | } |
4357 | 4331 | ||
@@ -4656,11 +4630,11 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl | |||
4656 | BT_ERR("Frame exceeding recv MTU (len %d, " | 4630 | BT_ERR("Frame exceeding recv MTU (len %d, " |
4657 | "MTU %d)", len, | 4631 | "MTU %d)", len, |
4658 | chan->imtu); | 4632 | chan->imtu); |
4659 | bh_unlock_sock(sk); | 4633 | release_sock(sk); |
4660 | l2cap_conn_unreliable(conn, ECOMM); | 4634 | l2cap_conn_unreliable(conn, ECOMM); |
4661 | goto drop; | 4635 | goto drop; |
4662 | } | 4636 | } |
4663 | bh_unlock_sock(sk); | 4637 | release_sock(sk); |
4664 | } | 4638 | } |
4665 | 4639 | ||
4666 | /* Allocate skb for the complete frame (with header) */ | 4640 | /* Allocate skb for the complete frame (with header) */ |