Bluetooth: Remove the send_lock spinlock from ERTM

Using a lock to deal with the ERTM race condition - interruption with
new data from the hci layer - is wrong. We should use the native skb
backlog queue.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
Gustavo F. Padovan 2010-06-21 18:50:49 -03:00 committed by Marcel Holtmann
parent 8cb8e6f168
commit e0f66218b3
2 changed files with 1 additions and 28 deletions

View File

@ -358,7 +358,6 @@ struct l2cap_pinfo {
__le16 sport; __le16 sport;
spinlock_t send_lock;
struct timer_list retrans_timer; struct timer_list retrans_timer;
struct timer_list monitor_timer; struct timer_list monitor_timer;
struct timer_list ack_timer; struct timer_list ack_timer;

View File

@ -1562,16 +1562,11 @@ static int l2cap_retransmit_frames(struct sock *sk)
struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_pinfo *pi = l2cap_pi(sk);
int ret; int ret;
spin_lock_bh(&pi->send_lock);
if (!skb_queue_empty(TX_QUEUE(sk))) if (!skb_queue_empty(TX_QUEUE(sk)))
sk->sk_send_head = TX_QUEUE(sk)->next; sk->sk_send_head = TX_QUEUE(sk)->next;
pi->next_tx_seq = pi->expected_ack_seq; pi->next_tx_seq = pi->expected_ack_seq;
ret = l2cap_ertm_send(sk); ret = l2cap_ertm_send(sk);
spin_unlock_bh(&pi->send_lock);
return ret; return ret;
} }
@ -1579,7 +1574,6 @@ static void l2cap_send_ack(struct l2cap_pinfo *pi)
{ {
struct sock *sk = (struct sock *)pi; struct sock *sk = (struct sock *)pi;
u16 control = 0; u16 control = 0;
int nframes;
control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT; control |= pi->buffer_seq << L2CAP_CTRL_REQSEQ_SHIFT;
@ -1590,11 +1584,7 @@ static void l2cap_send_ack(struct l2cap_pinfo *pi)
return; return;
} }
spin_lock_bh(&pi->send_lock); if (l2cap_ertm_send(sk) > 0)
nframes = l2cap_ertm_send(sk);
spin_unlock_bh(&pi->send_lock);
if (nframes > 0)
return; return;
control |= L2CAP_SUPER_RCV_READY; control |= L2CAP_SUPER_RCV_READY;
@ -1789,10 +1779,8 @@ static inline int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, siz
size += buflen; size += buflen;
} }
skb_queue_splice_tail(&sar_queue, TX_QUEUE(sk)); skb_queue_splice_tail(&sar_queue, TX_QUEUE(sk));
spin_lock_bh(&pi->send_lock);
if (sk->sk_send_head == NULL) if (sk->sk_send_head == NULL)
sk->sk_send_head = sar_queue.next; sk->sk_send_head = sar_queue.next;
spin_unlock_bh(&pi->send_lock);
return size; return size;
} }
@ -1864,14 +1852,9 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
} }
__skb_queue_tail(TX_QUEUE(sk), skb); __skb_queue_tail(TX_QUEUE(sk), skb);
if (pi->mode == L2CAP_MODE_ERTM)
spin_lock_bh(&pi->send_lock);
if (sk->sk_send_head == NULL) if (sk->sk_send_head == NULL)
sk->sk_send_head = skb; sk->sk_send_head = skb;
if (pi->mode == L2CAP_MODE_ERTM)
spin_unlock_bh(&pi->send_lock);
} else { } else {
/* Segment SDU into multiples PDUs */ /* Segment SDU into multiples PDUs */
err = l2cap_sar_segment_sdu(sk, msg, len); err = l2cap_sar_segment_sdu(sk, msg, len);
@ -1887,9 +1870,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
err = len; err = len;
break; break;
} }
spin_lock_bh(&pi->send_lock);
err = l2cap_ertm_send(sk); err = l2cap_ertm_send(sk);
spin_unlock_bh(&pi->send_lock);
} }
if (err >= 0) if (err >= 0)
@ -2464,7 +2445,6 @@ static inline void l2cap_ertm_init(struct sock *sk)
__skb_queue_head_init(SREJ_QUEUE(sk)); __skb_queue_head_init(SREJ_QUEUE(sk));
__skb_queue_head_init(BUSY_QUEUE(sk)); __skb_queue_head_init(BUSY_QUEUE(sk));
spin_lock_init(&l2cap_pi(sk)->send_lock);
INIT_WORK(&l2cap_pi(sk)->busy_work, l2cap_busy_work); INIT_WORK(&l2cap_pi(sk)->busy_work, l2cap_busy_work);
} }
@ -3462,9 +3442,7 @@ static inline void l2cap_send_i_or_rr_or_rnr(struct sock *sk)
if (pi->conn_state & L2CAP_CONN_REMOTE_BUSY) if (pi->conn_state & L2CAP_CONN_REMOTE_BUSY)
l2cap_retransmit_frames(sk); l2cap_retransmit_frames(sk);
spin_lock_bh(&pi->send_lock);
l2cap_ertm_send(sk); l2cap_ertm_send(sk);
spin_unlock_bh(&pi->send_lock);
if (!(pi->conn_state & L2CAP_CONN_LOCAL_BUSY) && if (!(pi->conn_state & L2CAP_CONN_LOCAL_BUSY) &&
pi->frames_sent == 0) { pi->frames_sent == 0) {
@ -4066,9 +4044,7 @@ static inline void l2cap_data_channel_rrframe(struct sock *sk, u16 rx_control)
if (pi->conn_state & L2CAP_CONN_SREJ_SENT) { if (pi->conn_state & L2CAP_CONN_SREJ_SENT) {
l2cap_send_ack(pi); l2cap_send_ack(pi);
} else { } else {
spin_lock_bh(&pi->send_lock);
l2cap_ertm_send(sk); l2cap_ertm_send(sk);
spin_unlock_bh(&pi->send_lock);
} }
} }
} }
@ -4113,9 +4089,7 @@ static inline void l2cap_data_channel_srejframe(struct sock *sk, u16 rx_control)
pi->conn_state |= L2CAP_CONN_SEND_FBIT; pi->conn_state |= L2CAP_CONN_SEND_FBIT;
l2cap_retransmit_one_frame(sk, tx_seq); l2cap_retransmit_one_frame(sk, tx_seq);
spin_lock_bh(&pi->send_lock);
l2cap_ertm_send(sk); l2cap_ertm_send(sk);
spin_unlock_bh(&pi->send_lock);
if (pi->conn_state & L2CAP_CONN_WAIT_F) { if (pi->conn_state & L2CAP_CONN_WAIT_F) {
pi->srej_save_reqseq = tx_seq; pi->srej_save_reqseq = tx_seq;