Add bt send to queue timeout abort

This commit is contained in:
gengyuchao
2020-04-09 11:36:13 +08:00
committed by maojianxin
parent 2f911d84db
commit bc6bd5155d
8 changed files with 84 additions and 9 deletions

View File

@ -571,7 +571,12 @@ void bta_sys_sendmsg(void *p_msg)
// there is a procedure in progress that can schedule a task via this
// message queue. This causes |btu_bta_msg_queue| to get cleaned up before
// it gets used here; hence we check for NULL before using it.
#ifdef TASK_MONITOR_MODE
if (btu_task_post(SIG_BTU_BTA_MSG, p_msg, TASK_POST_BLOCKING_WITH_TO) != TASK_POST_SUCCESS) {
#else
if (btu_task_post(SIG_BTU_BTA_MSG, p_msg, TASK_POST_BLOCKING) != TASK_POST_SUCCESS) {
#endif
osi_free(p_msg);
}
}
@ -590,8 +595,11 @@ void bta_alarm_cb(void *data)
{
assert(data != NULL);
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_BTA_ALARM, p_tle, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_BTA_ALARM, p_tle, TASK_POST_BLOCKING);
#endif
}
void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)

View File

@ -152,6 +152,10 @@ static bt_status_t btc_task_post(btc_msg_t *msg, task_post_t timeout)
if (xQueueSend(xBtcQueue, msg, timeout) != pdTRUE) {
BTC_TRACE_ERROR("Btc Post failed\n");
#ifdef TASK_MONITOR_MODE
ets_printf("!! Btc Post failed.Timeout Abort !!");
abort();
#endif
return BT_STATUS_BUSY;
}
@ -182,8 +186,12 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
} else {
lmsg.arg = NULL;
}
#ifdef TASK_MONITOR_MODE
return btc_task_post(&lmsg, TASK_POST_BLOCKING_WITH_TO);
#else
return btc_task_post(&lmsg, TASK_POST_BLOCKING);
#endif
}
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)

View File

@ -343,7 +343,11 @@ static void host_send_pkt_available_cb(void)
{
//Controller rx cache buffer is ready for receiving new host packet
//Just Call Host main thread task to process pending packets.
#ifdef TASK_MONITOR_MODE
hci_host_task_post(TASK_POST_BLOCKING_WITH_TO);
#else
hci_host_task_post(TASK_POST_BLOCKING);
#endif
}
static int host_recv_pkt_cb(uint8_t *data, uint16_t len)

View File

@ -141,6 +141,10 @@ task_post_status_t hci_host_task_post(task_post_t timeout)
evt.par = 0;
if (xQueueSend(xHciHostQueue, &evt, timeout) != pdTRUE) {
#ifdef TASK_MONITOR_MODE
ets_printf("!! HCI send fail.Timeout Abort !!");
abort();
#endif
HCI_TRACE_ERROR("xHciHostQueue failed\n");
return TASK_POST_FAIL;
}
@ -271,7 +275,12 @@ static void transmit_command(
BTTRC_DUMP_BUFFER(NULL, command->data + command->offset, command->len);
fixed_queue_enqueue(hci_host_env.command_queue, wait_entry);
#ifdef TASK_MONITOR_MODE
hci_host_task_post(TASK_POST_BLOCKING_WITH_TO);
#else
hci_host_task_post(TASK_POST_BLOCKING);
#endif
}
@ -292,7 +301,11 @@ static future_t *transmit_command_futured(BT_HDR *command)
command->event = MSG_STACK_TO_HC_HCI_CMD;
fixed_queue_enqueue(hci_host_env.command_queue, wait_entry);
#ifdef TASK_MONITOR_MODE
hci_host_task_post(TASK_POST_BLOCKING_WITH_TO);
#else
hci_host_task_post(TASK_POST_BLOCKING);
#endif
return future;
}
@ -305,7 +318,11 @@ static void transmit_downward(uint16_t type, void *data)
fixed_queue_enqueue(hci_host_env.packet_queue, data);
}
#ifdef TASK_MONITOR_MODE
hci_host_task_post(TASK_POST_BLOCKING_WITH_TO);
#else
hci_host_task_post(TASK_POST_BLOCKING);
#endif
}
@ -413,6 +430,7 @@ static void command_timed_out(void *context)
// If it's caused by a software bug, fix it. If it's a hardware bug, fix it.
{
HCI_TRACE_ERROR("%s hci layer timeout waiting for response to a command. opcode: 0x%x", __func__, wait_entry->opcode);
abort();
}
}
@ -479,7 +497,11 @@ intercepted:
/*Tell HCI Host Task to continue TX Pending commands*/
if (hci_host_env.command_credits &&
!fixed_queue_is_empty(hci_host_env.command_queue)) {
hci_host_task_post(TASK_POST_BLOCKING);
#ifdef TASK_MONITOR_MODE
hci_host_task_post(TASK_POST_BLOCKING_WITH_TO);
#else
hci_host_task_post(TASK_POST_BLOCKING);
#endif
}
if (wait_entry) {
@ -507,7 +529,11 @@ static void dispatch_reassembled(BT_HDR *packet)
{
// Events should already have been dispatched before this point
//Tell Up-layer received packet.
#ifdef TASK_MONITOR_MODE
if (btu_task_post(SIG_BTU_HCI_MSG, packet, TASK_POST_BLOCKING_WITH_TO) != TASK_POST_SUCCESS) {
#else
if (btu_task_post(SIG_BTU_HCI_MSG, packet, TASK_POST_BLOCKING) != TASK_POST_SUCCESS) {
#endif
osi_free(packet);
}
}

View File

@ -101,6 +101,10 @@ typedef enum {
#define TASK_POST_NON_BLOCKING (0)
#define TASK_POST_BLOCKING (portMAX_DELAY)
#define TASK_MONITOR_MODE TRUE
#ifdef TASK_MONITOR_MODE
#define TASK_POST_BLOCKING_WITH_TO (10000/portTICK_PERIOD_MS)
#endif
typedef uint32_t task_post_t; /* Timeout of task post return, unit TICK */
typedef enum {

View File

@ -1085,8 +1085,11 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context)
hack->context = context;
event->event = BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK;
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_HCI_MSG, event, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_HCI_MSG, event, TASK_POST_BLOCKING);
#endif
}
@ -1290,8 +1293,11 @@ static void btu_hcif_command_status_evt(uint8_t status, BT_HDR *command, void *c
hack->context = context;
event->event = BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK;
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_HCI_MSG, event, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_HCI_MSG, event, TASK_POST_BLOCKING);
#endif
}
/*******************************************************************************

View File

@ -204,8 +204,11 @@ void BTU_StartUp(void)
xTaskCreatePinnedToCore(btu_task_thread_handler, BTU_TASK_NAME, BTU_TASK_STACK_SIZE, NULL, BTU_TASK_PRIO, &xBtuTaskHandle, BTU_TASK_PINNED_TO_CORE);
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_START_UP, NULL, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_START_UP, NULL, TASK_POST_BLOCKING);
#endif
return;
error_exit:

View File

@ -264,6 +264,11 @@ task_post_status_t btu_task_post(uint32_t sig, void *param, task_post_t timeout)
if (xQueueSend(xBtuQueue, &evt, timeout) != pdTRUE) {
HCI_TRACE_ERROR("xBtuQueue failed\n");
#ifdef TASK_MONITOR_MODE
ets_printf("!! Btu Post failed.Timeout Abort !!");
abort();
#endif
return TASK_POST_FAIL;
}
@ -425,8 +430,12 @@ void btu_general_alarm_cb(void *data)
{
assert(data != NULL);
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_GENERAL_ALARM, p_tle, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_GENERAL_ALARM, p_tle, TASK_POST_BLOCKING);
#endif
}
void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec)
@ -539,8 +548,12 @@ static void btu_l2cap_alarm_cb(void *data)
{
assert(data != NULL);
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_L2CAP_ALARM, p_tle, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_L2CAP_ALARM, p_tle, TASK_POST_BLOCKING);
#endif
}
void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks)
@ -622,8 +635,11 @@ void btu_oneshot_alarm_cb(void *data)
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
btu_stop_timer_oneshot(p_tle);
#ifdef TASK_MONITOR_MODE
btu_task_post(SIG_BTU_ONESHOT_ALARM, p_tle, TASK_POST_BLOCKING_WITH_TO);
#else
btu_task_post(SIG_BTU_ONESHOT_ALARM, p_tle, TASK_POST_BLOCKING);
#endif
}
/*