Bluetooth: Reintroduce ACL buffers semaphore
Since nano_sema is after all able to handle multiple waiters we can have a cleaner and more efficient implementation by using a single semaphore for all of the connection tx fibers. Change-Id: Iafb595ae556a2dd826502cf282b88548cb34f336 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
d51985e4ce
commit
1f5b1b83e0
3 changed files with 20 additions and 1 deletions
|
@ -233,9 +233,19 @@ static void conn_tx_fiber(int arg1, int arg2)
|
|||
BT_DBG("Started for handle %u\n", conn->handle);
|
||||
|
||||
while (conn->state == BT_CONN_CONNECTED) {
|
||||
/* Wait until the controller can accept ACL packets */
|
||||
nano_fiber_sem_take_wait(&dev->le_pkts_sem);
|
||||
|
||||
/* check for disconnection */
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
nano_fiber_sem_give(&dev->le_pkts_sem);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get next ACL packet for connection */
|
||||
buf = nano_fifo_get_wait(&conn->tx_queue);
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
nano_fiber_sem_give(&dev->le_pkts_sem);
|
||||
bt_buf_put(buf);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -326,6 +326,7 @@ static void hci_num_completed_packets(struct bt_buf *buf)
|
|||
BT_DBG("handle %u count %u\n", handle, count);
|
||||
|
||||
while (count--) {
|
||||
nano_fiber_sem_give(&dev.le_pkts_sem);
|
||||
buf = nano_fiber_fifo_get(&dev.acl_pend);
|
||||
if (!buf) {
|
||||
BT_ERR("Mismatch with pending ACL buffers\n");
|
||||
|
@ -530,7 +531,7 @@ static int hci_init(void)
|
|||
struct bt_hci_cp_set_event_mask *ev;
|
||||
struct bt_buf *buf, *rsp;
|
||||
uint8_t *enable;
|
||||
int err;
|
||||
int i, err;
|
||||
|
||||
/* Send HCI_RESET */
|
||||
bt_hci_cmd_send(BT_HCI_OP_RESET, NULL);
|
||||
|
@ -660,6 +661,13 @@ static int hci_init(void)
|
|||
dev.hci_revision, dev.manufacturer);
|
||||
BT_DBG("ACL buffers: pkts %u mtu %u\n", dev.le_pkts, dev.le_mtu);
|
||||
|
||||
/* Initialize & prime the semaphore for counting controller-side
|
||||
* available ACL packet buffers.
|
||||
*/
|
||||
nano_sem_init(&dev.le_pkts_sem);
|
||||
for (i = 0; i < dev.le_pkts; i++)
|
||||
nano_sem_give(&dev.le_pkts_sem);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ struct bt_dev {
|
|||
/* Controller buffer information */
|
||||
uint8_t le_pkts;
|
||||
uint16_t le_mtu;
|
||||
struct nano_sem le_pkts_sem;
|
||||
|
||||
/* Number of commands controller can accept */
|
||||
uint8_t ncmd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue