summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKausik Sinnaswamy <kausik@broadcom.com>2012-09-24 17:23:51 +0530
committerIliyan Malchev <malchev@google.com>2012-09-26 13:58:19 -0700
commitf8217980ebcc6a6800052d32f023ebd8f4fbf7fc (patch)
tree7a376aa6369b3d45a3595a2acc5220105fb1d603
parentbc08278001ea3bdf9e08c2f754b129db34b09eb6 (diff)
downloadexternal_bluetooth_bluedroid-f8217980ebcc6a6800052d32f023ebd8f4fbf7fc.zip
external_bluetooth_bluedroid-f8217980ebcc6a6800052d32f023ebd8f4fbf7fc.tar.gz
external_bluetooth_bluedroid-f8217980ebcc6a6800052d32f023ebd8f4fbf7fc.tar.bz2
Trigger restart on BT Controller H/W error
On a Bluetooth chip h/w error, trigger an event from the core stack to restart the Bluetooth process. This would ensure that any state is cleaned up and the process starts from scratch Bug: 7001800 Change-Id: I57b0b44276585e2ae3c22ddbcc9d80bd467135b2 Signed-off-by: Iliyan Malchev <malchev@google.com>
-rw-r--r--bta/dm/bta_dm_act.c11
-rw-r--r--bta/include/bta_api.h2
-rw-r--r--bta/sys/bta_sys_main.c30
-rw-r--r--btif/src/btif_dm.c10
-rw-r--r--btif/src/btif_util.c1
-rw-r--r--stack/btu/btu_hcif.c1
6 files changed, 27 insertions, 28 deletions
diff --git a/bta/dm/bta_dm_act.c b/bta/dm/bta_dm_act.c
index 8260847..29b4ec2 100644
--- a/bta/dm/bta_dm_act.c
+++ b/bta/dm/bta_dm_act.c
@@ -319,6 +319,12 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
#endif
APPL_TRACE_DEBUG1(" bta_dm_sys_hw_cback with event: %i" , status );
+ /* On H/W error evt, report to the registered DM application callback */
+ if (status == BTA_SYS_HW_ERROR_EVT) {
+ if( bta_dm_cb.p_sec_cback != NULL )
+ bta_dm_cb.p_sec_cback(BTA_DM_HW_ERROR_EVT, NULL);
+ return;
+ }
if( status == BTA_SYS_HW_OFF_EVT )
{
if( bta_dm_cb.p_sec_cback != NULL )
@@ -335,8 +341,9 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
else
if( status == BTA_SYS_HW_ON_EVT )
{
- /* make sure we unregister, so that we don't motified again if another module starts */
- bta_sys_hw_unregister( BTA_SYS_HW_BLUETOOTH);
+ /* FIXME: We should not unregister as the SYS shall invoke this callback on a H/W error.
+ * We need to revisit when this platform has more than one BLuetooth H/W chip */
+ //bta_sys_hw_unregister( BTA_SYS_HW_BLUETOOTH);
/* save security callback */
temp_cback = bta_dm_cb.p_sec_cback;
diff --git a/bta/include/bta_api.h b/bta/include/bta_api.h
index c5f0b99..81dff39 100644
--- a/bta/include/bta_api.h
+++ b/bta/include/bta_api.h
@@ -416,7 +416,7 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK;
#define BTA_DM_BLE_AUTH_CMPL_EVT 22 /* BLE Auth complete */
// btla-specific --
#define BTA_DM_DEV_UNPAIRED_EVT 23
-
+#define BTA_DM_HW_ERROR_EVT 24 /* BT Chip H/W error */
typedef UINT8 tBTA_DM_SEC_EVT;
/* Structure associated with BTA_DM_ENABLE_EVT */
diff --git a/bta/sys/bta_sys_main.c b/bta/sys/bta_sys_main.c
index f3d8cb6..c1554bb 100644
--- a/bta/sys/bta_sys_main.c
+++ b/bta/sys/bta_sys_main.c
@@ -298,42 +298,24 @@ void bta_sys_hw_error(tBTA_SYS_HW_MSG *p_sys_hw_msg)
UINT8 module_index;
- for (module_index = 0; module_index < BTA_SYS_MAX_HW_MODULES; module_index++)
- {
- if( bta_sys_cb.sys_hw_module_active & ((UINT32)1 << module_index ))
- switch( module_index)
- {
-
- case BTA_SYS_HW_BLUETOOTH:
- BTA_DisableBluetooth();
- break;
- default:
- /* not yet supported */
- break;
- }
- }
-
- /* turn everything OFF, then re-start the modules that were ON. Let the state machine handle all this... */
+ APPL_TRACE_DEBUG1("%s", __FUNCTION__);
for (module_index = 0; module_index < BTA_SYS_MAX_HW_MODULES; module_index++)
{
- if( bta_sys_cb.sys_hw_module_active & ((UINT32)1 << module_index ))
+ if( bta_sys_cb.sys_hw_module_active & ((UINT32)1 << module_index )) {
switch( module_index)
{
-
case BTA_SYS_HW_BLUETOOTH:
- BTA_EnableBluetooth(NULL);
+ /* Send BTA_SYS_HW_ERROR_EVT to DM */
+ if (bta_sys_cb.sys_hw_cback[module_index] != NULL)
+ bta_sys_cb.sys_hw_cback[module_index] (BTA_SYS_HW_ERROR_EVT);
break;
default:
/* not yet supported */
break;
}
}
-
-
-
-
-
+ }
}
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index 7ab03b4..ac46e87 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -40,6 +40,7 @@
#include "btif_util.h"
#include "btif_storage.h"
#include "btif_hh.h"
+#include "btif_config.h"
/******************************************************************************
** Constants & Macros
@@ -1227,6 +1228,15 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param)
&bd_addr, BT_ACL_STATE_DISCONNECTED);
break;
+ case BTA_DM_HW_ERROR_EVT:
+ BTIF_TRACE_ERROR0("Received H/W Error. ");
+ /* Flush storage data */
+ btif_config_flush();
+ usleep(100000); /* 100milliseconds */
+ /* Killing the process to force a restart as part of fault tolerance */
+ kill(getpid(), SIGKILL);
+ break;
+
case BTA_DM_AUTHORIZE_EVT:
case BTA_DM_SIG_STRENGTH_EVT:
case BTA_DM_SP_RMT_OOB_EVT:
diff --git a/btif/src/btif_util.c b/btif/src/btif_util.c
index da23361..5539c11 100644
--- a/btif/src/btif_util.c
+++ b/btif/src/btif_util.c
@@ -275,6 +275,7 @@ const char* dump_dm_event(UINT16 event)
CASE_RETURN_STR(BTA_DM_BLE_LOCAL_ER_EVT)
CASE_RETURN_STR(BTA_DM_BLE_AUTH_CMPL_EVT)
CASE_RETURN_STR(BTA_DM_DEV_UNPAIRED_EVT)
+ CASE_RETURN_STR(BTA_DM_HW_ERROR_EVT)
default:
return "UNKNOWN DM EVENT";
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c
index 205b628..8ca9d35 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.c
@@ -974,7 +974,6 @@ static void btu_hcif_esco_connection_chg_evt (UINT8 *p, UINT16 evt_len)
#endif
}
-
/*******************************************************************************
**
** Function btu_hcif_hdl_command_complete