diff options
author | Abhishek Srivastava <cabsriv@codeaurora.org> | 2018-04-09 18:29:49 +0530 |
---|---|---|
committer | Sunil Ravi <sunilravi@google.com> | 2019-02-07 15:51:06 -0800 |
commit | acf68369d0c4fb66ce96b5c8ea9aabb585f2caf8 (patch) | |
tree | 3a16d5b6f822e1e3f1f7ab85684401f4301705cf | |
parent | 6bd79980828fd0a6a58a0675a34c548fd5e15251 (diff) |
DLKM: Add recovery for driver state change failure
With DLKM (WIFI_DRIVER_MODULE_PATH) set, the driver state change for
WIFI_DRIVER_STATE_ON is checked after the insmod is done. If this
driver state is not set to WIFI_DRIVER_STATE_ON due to firmware not
ready, there is no recovery with the current implementation. This
leaves the driver loaded but not functional and moreover any further
attempts to load the driver fails as the driver is already loaded.
Address this scenario by removing the driver on the driver state
change failure for DLKM drivers.
Bug: 123007643
Test: Turn On/Turn Off Wi-Fi multiple times
Change-Id: I99e425dee0b1d59ae53e1722a137db3357f5d56e
CRs-Fixed: 2214027
-rw-r--r-- | libwifi_hal/wifi_hal_common.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libwifi_hal/wifi_hal_common.cpp b/libwifi_hal/wifi_hal_common.cpp index d4774bda7..f1eb3ab16 100644 --- a/libwifi_hal/wifi_hal_common.cpp +++ b/libwifi_hal/wifi_hal_common.cpp @@ -172,7 +172,19 @@ int wifi_load_driver() { return 0; } - if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0) return -1; + if (wifi_change_driver_state(WIFI_DRIVER_STATE_ON) < 0) { +#ifdef WIFI_DRIVER_MODULE_PATH + PLOG(WARNING) << "Driver unloading, err='fail to change driver state'"; + if (rmmod(DRIVER_MODULE_NAME) == 0) { + PLOG(DEBUG) << "Driver unloaded"; + } else { + // Set driver prop to "ok", expect HL to restart Wi-Fi. + PLOG(DEBUG) << "Driver unload failed! set driver prop to 'ok'."; + property_set(DRIVER_PROP_NAME, "ok"); + } +#endif + return -1; + } #endif is_driver_loaded = true; return 0; |