From 041c84c3e6d4c19f765faea393d34bc88f0aeb47 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 29 Apr 2015 12:33:30 +0300 Subject: [PATCH] Bluetooth: Introduce dummy data type We're already sending 'dummy' buffers to wake up the connection fibers. The problem is that if we provide a real buffer type it may have unintended consequences. E.g. with BT_ACL_OUT when bt_buf_put() is called it may trigger an invalid HCI_Host_Num_Completed_Packets command. This patch creates a new BT_DUMMY buffer type to avoid this scenario. The new type is an alias for BT_CMD since the pool where these buffers come from is not quota-controlled and synced up with the controller. Change-Id: I42ac235811dc242345853f7858c10bfc43e4f07d Signed-off-by: Johan Hedberg --- include/bluetooth/buf.h | 9 +++++---- net/bluetooth/conn.c | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/bluetooth/buf.h b/include/bluetooth/buf.h index f92eb990749..54c9f830431 100644 --- a/include/bluetooth/buf.h +++ b/include/bluetooth/buf.h @@ -42,10 +42,11 @@ /* Type of data contained in this buffer */ enum bt_buf_type { - BT_CMD, /* HCI command */ - BT_EVT, /* HCI event */ - BT_ACL_OUT, /* Outgoing ACL data */ - BT_ACL_IN, /* Incoming ACL data */ + BT_CMD, /* HCI command */ + BT_EVT, /* HCI event */ + BT_ACL_OUT, /* Outgoing ACL data */ + BT_ACL_IN, /* Incoming ACL data */ + BT_DUMMY = BT_CMD, /* Only used for waking up fibers */ }; /* HCI command specific info */ diff --git a/net/bluetooth/conn.c b/net/bluetooth/conn.c index f2b99a0375d..b2fb6d7799b 100644 --- a/net/bluetooth/conn.c +++ b/net/bluetooth/conn.c @@ -257,8 +257,8 @@ void bt_conn_del(struct bt_conn *conn) conn->state = BT_CONN_DISCONNECTED; /* Send dummy buffers to wake up and kill the fibers */ - nano_fifo_put(&conn->tx_queue, bt_buf_get(BT_ACL_OUT, 0)); - nano_fifo_put(&conn->rx_queue, bt_buf_get(BT_ACL_IN, 0)); + nano_fifo_put(&conn->tx_queue, bt_buf_get(BT_DUMMY, 0)); + nano_fifo_put(&conn->rx_queue, bt_buf_get(BT_DUMMY, 0)); bt_conn_put(conn); }