From 873a759f48816769be786ed4227e10fd4910a5c5 Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Wed, 23 Jun 2021 11:47:02 +0800 Subject: [PATCH] fix spp acceptor deadlock --- components/bt/bluedroid/hci/hci_hal_h4.c | 22 ++--------- .../bluedroid/stack/l2cap/include/l2c_int.h | 5 --- .../bt/bluedroid/stack/l2cap/l2c_utils.c | 38 ------------------- 3 files changed, 4 insertions(+), 61 deletions(-) diff --git a/components/bt/bluedroid/hci/hci_hal_h4.c b/components/bt/bluedroid/hci/hci_hal_h4.c index 742a448dbf..819a9a7551 100644 --- a/components/bt/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/bluedroid/hci/hci_hal_h4.c @@ -197,30 +197,16 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout) #if (C2H_FLOW_CONTROL_INCLUDED == TRUE) static void hci_packet_complete(BT_HDR *packet){ - uint8_t type, num_handle; + uint8_t type; uint16_t handle; - uint16_t handles[MAX_L2CAP_LINKS + 4]; - uint16_t num_packets[MAX_L2CAP_LINKS + 4]; + uint16_t num_packets = 1; uint8_t *stream = packet->data + packet->offset; - tL2C_LCB *p_lcb = NULL; STREAM_TO_UINT8(type, stream); if (type == DATA_TYPE_ACL/* || type == DATA_TYPE_SCO*/) { STREAM_TO_UINT16(handle, stream); handle = handle & HCI_DATA_HANDLE_MASK; - p_lcb = l2cu_find_lcb_by_handle(handle); - if (p_lcb) { - p_lcb->completed_packets++; - } - if (esp_vhci_host_check_send_available()){ - num_handle = l2cu_find_completed_packets(handles, num_packets); - if (num_handle > 0){ - btsnd_hcic_host_num_xmitted_pkts (num_handle, handles, num_packets); - } - } else { - //Send HCI_Host_Number_of_Completed_Packets next time. - } - + btsnd_hcic_host_num_xmitted_pkts(1, &handle, &num_packets); } } #endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE @@ -229,7 +215,7 @@ bool host_recv_adv_packet(BT_HDR *packet) { assert(packet); if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT) { - if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT + if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT #if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE) || packet->data[3] == HCI_BLE_ADV_DISCARD_REPORT_EVT #endif diff --git a/components/bt/bluedroid/stack/l2cap/include/l2c_int.h b/components/bt/bluedroid/stack/l2cap/include/l2c_int.h index 1a73cf8640..67099f35ac 100644 --- a/components/bt/bluedroid/stack/l2cap/include/l2c_int.h +++ b/components/bt/bluedroid/stack/l2cap/include/l2c_int.h @@ -380,7 +380,6 @@ typedef struct t_l2c_linkcb { TIMER_LIST_ENT timer_entry; /* Timer list entry for timeout evt */ UINT16 handle; /* The handle used with LM */ - UINT16 completed_packets; /* The number of conpleted packets */ tL2C_CCB_Q ccb_queue; /* Queue of CCBs on this LCB */ @@ -672,10 +671,6 @@ extern void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb); #endif -#if (C2H_FLOW_CONTROL_INCLUDED == TRUE) -extern UINT8 l2cu_find_completed_packets(UINT16 *handles, UINT16 *num_packets); -#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE - extern BOOLEAN l2cu_initialize_fixed_ccb (tL2C_LCB *p_lcb, UINT16 fixed_cid, tL2CAP_FCR_OPTS *p_fcr); extern void l2cu_no_dynamic_ccbs (tL2C_LCB *p_lcb); extern void l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb); diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 6349638063..8e2975217a 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -96,9 +96,6 @@ tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, BOOLEAN is_bonding, tBT_TRANSPOR l2c_link_adjust_allocation(); } p_lcb->link_xmit_data_q = list_new(NULL); -#if (C2H_FLOW_CONTROL_INCLUDED == TRUE) - p_lcb->completed_packets = 0; -#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE return (p_lcb); } } @@ -267,11 +264,6 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb) fixed_queue_free(p_lcb->le_sec_pending_q, NULL); p_lcb->le_sec_pending_q = NULL; } - -#if (C2H_FLOW_CONTROL_INCLUDED == TRUE) - p_lcb->completed_packets = 0; -#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE - } @@ -3171,36 +3163,6 @@ void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb) #endif /* BLE_INCLUDED == TRUE */ -#if (C2H_FLOW_CONTROL_INCLUDED == TRUE) -/******************************************************************************* -** -** Function l2cu_find_completed_packets -** -** Description Find the completed packets, -** Then set it to zero -** -** Returns The num of handles -** -*******************************************************************************/ -UINT8 l2cu_find_completed_packets(UINT16 *handles, UINT16 *num_packets) -{ - int xx; - UINT8 num = 0; - tL2C_LCB *p_lcb = &l2cb.lcb_pool[0]; - - for (xx = 0; xx < MAX_L2CAP_LINKS; xx++, p_lcb++) { - if ((p_lcb->in_use) && (p_lcb->completed_packets > 0)) { - *(handles++) = p_lcb->handle; - *(num_packets++) = p_lcb->completed_packets; - num++; - p_lcb->completed_packets = 0; - } - } - - return num; -} -#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE - /******************************************************************************* ** Functions used by both Full and Light Stack ********************************************************************************/