diff options
| author | Prerepa Viswanadham <dham@google.com> | 2015-05-28 15:41:19 -0700 |
|---|---|---|
| committer | Prerepa Viswanadham <dham@google.com> | 2015-06-01 17:57:17 +0000 |
| commit | 552a6ef12d4661234f3be5e8a47954b4b634560e (patch) | |
| tree | 43a9ba5f544536d1416fc2f9f0ea1757a2f92281 | |
| parent | fce658dae2749765552cbf12ce652338e20f583d (diff) | |
| download | android_hardware_broadcom_libbt-552a6ef12d4661234f3be5e8a47954b4b634560e.tar.gz android_hardware_broadcom_libbt-552a6ef12d4661234f3be5e8a47954b4b634560e.tar.bz2 android_hardware_broadcom_libbt-552a6ef12d4661234f3be5e8a47954b4b634560e.zip | |
Fix for bluedroid sometimes holding kernel wake lock inadvertendly
Two problems
- sometimes bluedroid will not issue upio_set to release kernel
wake lock. Timeout would fire but would not release lpm driver
cmd to release kernel wake lock
- lpm wake lock was not being extended as bluedroid would
constantly use the interface.
Bug: 21063567
Change-Id: I898508493bbf7b8c2ddb79d7c7398b6900ade12c
| -rw-r--r-- | src/upio.c | 63 |
1 files changed, 47 insertions, 16 deletions
@@ -195,9 +195,43 @@ static void proc_btwrite_timeout(union sigval arg) { UPIODBG("..%s..", __FUNCTION__); lpm_proc_cb.btwrite_active = FALSE; + /* drive LPM down; this timer should fire only when BT is awake; */ + upio_set(UPIO_BT_WAKE, UPIO_DEASSERT, 1); } #endif +/****************************************************************************** + ** + ** Function upio_start_stop_timer + ** + ** Description Arm user space timer in case lpm is left asserted + ** + ** Returns None + ** + *****************************************************************************/ +void upio_start_stop_timer(int action) { + struct itimerspec ts; + + if (action == UPIO_ASSERT) { + lpm_proc_cb.btwrite_active = TRUE; + if (lpm_proc_cb.timer_created == TRUE) { + ts.it_value.tv_sec = PROC_BTWRITE_TIMER_TIMEOUT_MS/1000; + ts.it_value.tv_nsec = 1000000*(PROC_BTWRITE_TIMER_TIMEOUT_MS%1000); + ts.it_interval.tv_sec = 0; + ts.it_interval.tv_nsec = 0; + } + } else { + /* unarm timer if writing 0 to lpm; reduce unnecessary user space wakeup */ + memset(&ts, 0, sizeof(ts)); + } + + if (timer_settime(lpm_proc_cb.timer_id, 0, &ts, 0) == 0) { + UPIODBG("%s : timer_settime success", __FUNCTION__); + } else { + UPIODBG("%s : timer_settime failed", __FUNCTION__); + } +} + /***************************************************************************** ** UPIO Interface Functions *****************************************************************************/ @@ -331,6 +365,8 @@ void upio_set(uint8_t pio, uint8_t action, uint8_t polarity) char buffer; #endif + UPIODBG("%s : pio %d action %d, polarity %d", __FUNCTION__, pio, action, polarity); + switch (pio) { case UPIO_LPM_MODE: @@ -410,7 +446,7 @@ void upio_set(uint8_t pio, uint8_t action, uint8_t polarity) UPIODBG("BT_WAKE is %s already", lpm_state[action]); #if (BT_WAKE_VIA_PROC == TRUE) - if (lpm_proc_cb.btwrite_active == TRUE) + if (lpm_proc_cb.btwrite_active == TRUE) { /* * The proc btwrite node could have not been updated for * certain time already due to heavy downstream path flow. @@ -420,8 +456,13 @@ void upio_set(uint8_t pio, uint8_t action, uint8_t polarity) * a 10sec internal in-activity timeout timer before it * attempts to deassert BT_WAKE line. */ -#endif + /* re-arm user space timer */ + upio_start_stop_timer(action); + return; + } +#else return; +#endif } upio_state[UPIO_BT_WAKE] = action; @@ -464,23 +505,13 @@ void upio_set(uint8_t pio, uint8_t action, uint8_t polarity) #if (PROC_BTWRITE_TIMER_TIMEOUT_MS != 0) else { - lpm_proc_cb.btwrite_active = TRUE; - - if (lpm_proc_cb.timer_created == TRUE) - { - struct itimerspec ts; - - ts.it_value.tv_sec = PROC_BTWRITE_TIMER_TIMEOUT_MS/1000; - ts.it_value.tv_nsec = 1000000*(PROC_BTWRITE_TIMER_TIMEOUT_MS%1000); - ts.it_interval.tv_sec = 0; - ts.it_interval.tv_nsec = 0; - - timer_settime(lpm_proc_cb.timer_id, 0, &ts, 0); - } + /* arm user space timer based on action */ + upio_start_stop_timer(action); } #endif - UPIODBG("proc btwrite assertion"); + UPIODBG("%s: proc btwrite assertion, buffer: %c, timer_armed %d %d", + __FUNCTION__, buffer, lpm_proc_cb.btwrite_active, lpm_proc_cb.timer_created); if (fd >= 0) close(fd); |
