From acf68369d0c4fb66ce96b5c8ea9aabb585f2caf8 Mon Sep 17 00:00:00 2001 From: Abhishek Srivastava Date: Mon, 9 Apr 2018 18:29:49 +0530 Subject: 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 --- libwifi_hal/wifi_hal_common.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3