summaryrefslogtreecommitdiffstats
path: root/gki
diff options
context:
space:
mode:
authorjechao <jechao@broadcom.com>2012-03-13 18:32:24 -0700
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:13 -0700
commit5140bed9a19aadca962184ebc9ed823d5d7cb745 (patch)
tree13e18514ba8082f49480597c0bd340fdeabec03d /gki
parent0afef5f7d9b3fe739671c1caa0aa5f1245e0c31d (diff)
downloadexternal_bluetooth_bluedroid-5140bed9a19aadca962184ebc9ed823d5d7cb745.zip
external_bluetooth_bluedroid-5140bed9a19aadca962184ebc9ed823d5d7cb745.tar.gz
external_bluetooth_bluedroid-5140bed9a19aadca962184ebc9ed823d5d7cb745.tar.bz2
Revise on/off control process to address bdroid crashes seen in BT on/off stress tests.
Change-Id: I3c2ed587ddddb293f14c281ccdebb5ba4bf23a7e
Diffstat (limited to 'gki')
-rw-r--r--gki/common/gki.h1
-rw-r--r--gki/ulinux/gki_ulinux.c85
2 files changed, 86 insertions, 0 deletions
diff --git a/gki/common/gki.h b/gki/common/gki.h
index a3272d5..a1005dc 100644
--- a/gki/common/gki.h
+++ b/gki/common/gki.h
@@ -369,6 +369,7 @@ extern "C" {
*/
GKI_API extern UINT8 GKI_create_task (TASKPTR, UINT8, INT8 *, UINT16 *, UINT16);
GKI_API extern void GKI_destroy_task(UINT8 task_id);
+GKI_API extern void GKI_task_self_cleanup(UINT8 task_id);
GKI_API extern void GKI_exit_task(UINT8);
GKI_API extern UINT8 GKI_get_taskid(void);
GKI_API extern void GKI_init(void);
diff --git a/gki/ulinux/gki_ulinux.c b/gki/ulinux/gki_ulinux.c
index 8fdac95..c2838c1 100644
--- a/gki/ulinux/gki_ulinux.c
+++ b/gki/ulinux/gki_ulinux.c
@@ -363,6 +363,27 @@ void GKI_destroy_task(UINT8 task_id)
/* paranoi settings, make sure that we do not execute any mailbox events */
gki_cb.com.OSWaitEvt[task_id] &= ~(TASK_MBOX_0_EVT_MASK|TASK_MBOX_1_EVT_MASK|
TASK_MBOX_2_EVT_MASK|TASK_MBOX_3_EVT_MASK);
+
+#if (GKI_NUM_TIMERS > 0)
+ gki_cb.com.OSTaskTmr0R[task_id] = 0;
+ gki_cb.com.OSTaskTmr0 [task_id] = 0;
+#endif
+
+#if (GKI_NUM_TIMERS > 1)
+ gki_cb.com.OSTaskTmr1R[task_id] = 0;
+ gki_cb.com.OSTaskTmr1 [task_id] = 0;
+#endif
+
+#if (GKI_NUM_TIMERS > 2)
+ gki_cb.com.OSTaskTmr2R[task_id] = 0;
+ gki_cb.com.OSTaskTmr2 [task_id] = 0;
+#endif
+
+#if (GKI_NUM_TIMERS > 3)
+ gki_cb.com.OSTaskTmr3R[task_id] = 0;
+ gki_cb.com.OSTaskTmr3 [task_id] = 0;
+#endif
+
GKI_send_event(task_id, EVENT_MASK(GKI_SHUTDOWN_EVT));
#if ( FALSE == GKI_PTHREAD_JOINABLE )
@@ -386,6 +407,70 @@ void GKI_destroy_task(UINT8 task_id)
/*******************************************************************************
**
+** Function GKI_task_self_cleanup
+**
+** Description This function is used in the case when the calling thread
+** is exiting itself. The GKI_destroy_task function can not be
+** used in this case due to the pthread_join call. The function
+** cleans up GKI control block associated to the terminating
+** thread.
+**
+** Parameters: task_id - (input) Task id is used for sanity check to
+** make sure the calling thread is in the right
+** context.
+**
+** Returns None
+**
+*******************************************************************************/
+void GKI_task_self_cleanup(UINT8 task_id)
+{
+ UINT8 my_task_id = GKI_get_taskid();
+
+ if (task_id != my_task_id)
+ {
+ GKI_ERROR_LOG("%s: Wrong context - current task %d is not the given task id %d",\
+ __FUNCTION__, my_task_id, task_id);
+ return;
+ }
+
+ if (gki_cb.com.OSRdyTbl[task_id] != TASK_DEAD)
+ {
+ /* paranoi settings, make sure that we do not execute any mailbox events */
+ gki_cb.com.OSWaitEvt[task_id] &= ~(TASK_MBOX_0_EVT_MASK|TASK_MBOX_1_EVT_MASK|
+ TASK_MBOX_2_EVT_MASK|TASK_MBOX_3_EVT_MASK);
+
+#if (GKI_NUM_TIMERS > 0)
+ gki_cb.com.OSTaskTmr0R[task_id] = 0;
+ gki_cb.com.OSTaskTmr0 [task_id] = 0;
+#endif
+
+#if (GKI_NUM_TIMERS > 1)
+ gki_cb.com.OSTaskTmr1R[task_id] = 0;
+ gki_cb.com.OSTaskTmr1 [task_id] = 0;
+#endif
+
+#if (GKI_NUM_TIMERS > 2)
+ gki_cb.com.OSTaskTmr2R[task_id] = 0;
+ gki_cb.com.OSTaskTmr2 [task_id] = 0;
+#endif
+
+#if (GKI_NUM_TIMERS > 3)
+ gki_cb.com.OSTaskTmr3R[task_id] = 0;
+ gki_cb.com.OSTaskTmr3 [task_id] = 0;
+#endif
+
+ GKI_exit_task(task_id);
+
+ /* Calling pthread_detach here to mark the thread as detached.
+ Once the thread terminates, the system can reclaim its resources
+ without waiting for another thread to join with.
+ */
+ pthread_detach(gki_cb.os.thread_id[task_id]);
+ }
+}
+
+/*******************************************************************************
+**
** Function GKI_shutdown
**
** Description shutdowns the GKI tasks/threads in from max task id to 0 and frees