Bluetooth: Use zero timeout for immediate scheduling
Subsystems (2)
PATCH 1/4 Bluetooth: Use zero timeout for immediate scheduling
From: Johan Hedberg <[email protected]>
There's no point in passing a "small" timeout to queue_delayed_work() to try to get the callback faster scheduled. Passing 0 is perfectly valid and will cause a shortcut to a direct queue_work().
--- include/net/bluetooth/hci_core.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/net/bluetooth/hci_core.h +2 -2
@@ -791,7 +791,7 @@ static inline void hci_conn_drop(struct hci_conn *conn)if (!conn->out) timeo *=2 ; }else { - timeo =msecs_to_jiffies (10 ); + timeo =0 ; }break ;
@@ -800,7 +800,7 @@ static inline void hci_conn_drop(struct hci_conn *conn)break ;default : - timeo =msecs_to_jiffies (10 ); + timeo =0 ;break ; }
Signature · 1 line
1.9.3
PATCH 2/4 Bluetooth: Fix hci_conn reference counting with hci_chan
From: Johan Hedberg <[email protected]>
The hci_chan_del() function was doing a hci_conn_drop() but there was no matching hci_conn_hold() in the hci_chan_create() function. Furthermore, as the hci_chan struct holds a pointer to the hci_conn there should be proper use of hci_conn_get/put. This patch fixes both issues so that hci_chan does correct reference counting of the hci_conn object.
--- net/bluetooth/hci_conn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/bluetooth/hci_conn.c +3 -1
@@ -1295,7 +1295,8 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn)if (!chan)return NULL ; - chan->conn = conn; + chan->conn =hci_conn_get (conn); +hci_conn_hold (conn);skb_queue_head_init (&chan->data_q); chan->state =BT_CONNECTED ;
@@ -1316,6 +1317,7 @@ void hci_chan_del(struct hci_chan *chan)synchronize_rcu ();hci_conn_drop (conn); +hci_conn_put (conn);skb_queue_purge (&chan->data_q);kfree (chan);
Signature · 1 line
1.9.3
PATCH 3/4 Bluetooth: Set disc_timeout to 0 when calling hci_chan_del
In reply to [email protected]From: Johan Hedberg <[email protected]>
The hci_chan_del() function is used in scenarios where we've decided we want to get rid of the underlying baseband link. It makes therefore sense to force the disc_timeout to 0 so that the disconnection routines are immediately scheduled.
--- net/bluetooth/hci_conn.c | 3 +++ 1 file changed, 3 insertions(+)
net/bluetooth/hci_conn.c +3 -0
@@ -1316,6 +1316,9 @@ void hci_chan_del(struct hci_chan *chan)synchronize_rcu (); +/* Force the connection to be immediately dropped */ + conn->disc_timeout =0 ; +hci_conn_drop (conn);hci_conn_put (conn);
Signature · 1 line
1.9.3
PATCH 4/4 Bluetooth: Ignore incoming data after initiating disconnection
In reply to [email protected]From: Johan Hedberg <[email protected]>
When hci_chan_del is called the disconnection routines get scheduled through a workqueue. If there's any incoming ACL data before the routines get executed there's a chance that a new hci_chan is created and the disconnection never happens. This patch adds a new hci_conn flag to indicate that we're in the process of driving the connection down. We set the flag in hci_chan_del and check for it in hci_chan_create so that no new channels are created for the same connection.
--- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_conn.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/net/bluetooth/hci_core.h +1 -0
@@ -553,6 +553,7 @@ enum {HCI_CONN_FIPS ,HCI_CONN_STK_ENCRYPT ,HCI_CONN_AUTH_INITIATOR , + HCI_CONN_DROP, };static inline bool hci_conn_ssp_enabled (struct hci_conn *conn)
net/bluetooth/hci_conn.c +6 -0
@@ -1291,6 +1291,11 @@ struct hci_chan *hci_chan_create(struct hci_conn *conn)BT_DBG ("%s hcon %p" , hdev->name, conn); +if (test_bit (HCI_CONN_DROP , &conn->flags)) { +BT_DBG ("Refusing to create new hci_chan" ); +return NULL ; + } + chan =kzalloc (sizeof (*chan),GFP_KERNEL );if (!chan)return NULL ;
@@ -1318,6 +1323,7 @@ void hci_chan_del(struct hci_chan *chan)/* Force the connection to be immediately dropped */ conn->disc_timeout =0 ; +set_bit (HCI_CONN_DROP , &conn->flags);hci_conn_drop (conn);hci_conn_put (conn);
Signature · 1 line
1.9.3
Marcel Holtmann
maintainerRe: [PATCH 4/4] Bluetooth: Ignore incoming data after initiating disconnection
Hi Johan,
Quoted 8 lines
When
hci_chan_delis called the disconnection routines get scheduled through a workqueue. If there's any incoming ACL data before the routines get executed there's a chance that a newhci_chanis created and the disconnection never happens. This patch adds a newhci_connflag to indicate that we're in the process of driving the connection down. We set the flag inhci_chan_deland check for it inhci_chan_createso that no new channels are created for the same connection.
Quoted 5 lines
Signed-off-by Johan Hedberg <[email protected]>---
include/net/bluetooth/hci_core.h| 1 +net/bluetooth/hci_conn.c| 6 ++++++2 files changed, 7 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Marcel Holtmann
maintainerRe: [PATCH 3/4] Bluetooth: Set disc_timeout to 0 when calling hci_chan_del
In reply to [email protected]Hi Johan,
Quoted 9 lines
The
hci_chan_del()function is used in scenarios where we've decided we want to get rid of the underlying baseband link. It makes therefore sense to force thedisc_timeoutto 0 so that the disconnection routines are immediately scheduled.Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/hci_conn.c| 3 +++1 file changed, 3 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Marcel Holtmann
maintainerHi Johan,
Quoted 8 lines
There's no point in passing a "small" timeout to
queue_delayed_work()to try to get the callback faster scheduled. Passing 0 is perfectly valid and will cause a shortcut to a directqueue_work().Signed-off-by Johan Hedberg <[email protected]>---
include/net/bluetooth/hci_core.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
Marcel Holtmann
maintainerRe: [PATCH 2/4] Bluetooth: Fix hci_conn reference counting with hci_chan
In reply to [email protected]Hi Johan,
Quoted 10 lines
The
hci_chan_del()function was doing ahci_conn_drop()but there was no matchinghci_conn_hold()in thehci_chan_create()function. Furthermore, as thehci_chanstruct holds a pointer to thehci_connthere should be proper use of hci_conn_get/put. This patch fixes both issues so thathci_chandoes correct reference counting of thehci_connobject.Signed-off-by Johan Hedberg <[email protected]>---
net/bluetooth/hci_conn.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel