diff options
author | Roshan Pius | 2017-11-27 18:08:27 -0600 |
---|---|---|
committer | Roshan Pius | 2017-12-13 12:35:50 -0600 |
commit | 8fc6d17071f1e5b8f42e68a1b7b441e942004051 (patch) | |
tree | 36542ff48384d8853f77214cd200abefd6f0a231 | |
parent | 8e3c7ef134e9af7c1531826fd7ae3331ca693085 (diff) | |
download | platform-hardware-interfaces-8fc6d17071f1e5b8f42e68a1b7b441e942004051.tar.gz platform-hardware-interfaces-8fc6d17071f1e5b8f42e68a1b7b441e942004051.tar.xz platform-hardware-interfaces-8fc6d17071f1e5b8f42e68a1b7b441e942004051.zip |
wifi(implementation): Load wifi driver on IWifi.start()
The current implementation loads the wifi driver only when the chip is
configured, but the HAL is initialized on IWifi.start(). This seems to
be wrong semantically. The driver needs to be loaded before the HAL is
initialized.
This may have worked previously because the driver was loaded in
init.rc, but may stop working when we move to proper DLKM model in 2018.
Bug: 65671875
Test: Device boots up and connects to wifi networks.
Change-Id: I017d3528bf0b42a6a59af43203ecc9d0d027f60d
-rw-r--r-- | wifi/1.2/default/tests/mock_wifi_mode_controller.h | 1 | ||||
-rw-r--r-- | wifi/1.2/default/wifi.cpp | 8 | ||||
-rw-r--r-- | wifi/1.2/default/wifi.h | 2 | ||||
-rw-r--r-- | wifi/1.2/default/wifi_mode_controller.cpp | 6 | ||||
-rw-r--r-- | wifi/1.2/default/wifi_mode_controller.h | 1 |
5 files changed, 14 insertions, 4 deletions
diff --git a/wifi/1.2/default/tests/mock_wifi_mode_controller.h b/wifi/1.2/default/tests/mock_wifi_mode_controller.h index 73ff5f09..50c3e35b 100644 --- a/wifi/1.2/default/tests/mock_wifi_mode_controller.h +++ b/wifi/1.2/default/tests/mock_wifi_mode_controller.h | |||
@@ -31,6 +31,7 @@ namespace mode_controller { | |||
31 | class MockWifiModeController : public WifiModeController { | 31 | class MockWifiModeController : public WifiModeController { |
32 | public: | 32 | public: |
33 | MockWifiModeController(); | 33 | MockWifiModeController(); |
34 | MOCK_METHOD0(initialize, bool()); | ||
34 | MOCK_METHOD1(changeFirmwareMode, bool(IfaceType)); | 35 | MOCK_METHOD1(changeFirmwareMode, bool(IfaceType)); |
35 | MOCK_METHOD1(isFirmwareModeChangeNeeded, bool(IfaceType)); | 36 | MOCK_METHOD1(isFirmwareModeChangeNeeded, bool(IfaceType)); |
36 | MOCK_METHOD0(deinitialize, bool()); | 37 | MOCK_METHOD0(deinitialize, bool()); |
diff --git a/wifi/1.2/default/wifi.cpp b/wifi/1.2/default/wifi.cpp index 5a8b66ec..06f50588 100644 --- a/wifi/1.2/default/wifi.cpp +++ b/wifi/1.2/default/wifi.cpp | |||
@@ -92,7 +92,7 @@ WifiStatus Wifi::startInternal() { | |||
92 | return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, | 92 | return createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE, |
93 | "HAL is stopping"); | 93 | "HAL is stopping"); |
94 | } | 94 | } |
95 | WifiStatus wifi_status = initializeLegacyHal(); | 95 | WifiStatus wifi_status = initializeModeControllerAndLegacyHal(); |
96 | if (wifi_status.code == WifiStatusCode::SUCCESS) { | 96 | if (wifi_status.code == WifiStatusCode::SUCCESS) { |
97 | // Create the chip instance once the HAL is started. | 97 | // Create the chip instance once the HAL is started. |
98 | chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_, | 98 | chip_ = new WifiChip(kChipId, legacy_hal_, mode_controller_, |
@@ -166,7 +166,11 @@ std::pair<WifiStatus, sp<IWifiChip>> Wifi::getChipInternal(ChipId chip_id) { | |||
166 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip_}; | 166 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip_}; |
167 | } | 167 | } |
168 | 168 | ||
169 | WifiStatus Wifi::initializeLegacyHal() { | 169 | WifiStatus Wifi::initializeModeControllerAndLegacyHal() { |
170 | if (!mode_controller_->initialize()) { | ||
171 | LOG(ERROR) << "Failed to initialize firmware mode controller"; | ||
172 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); | ||
173 | } | ||
170 | legacy_hal::wifi_error legacy_status = legacy_hal_->initialize(); | 174 | legacy_hal::wifi_error legacy_status = legacy_hal_->initialize(); |
171 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { | 175 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
172 | LOG(ERROR) << "Failed to initialize legacy HAL: " | 176 | LOG(ERROR) << "Failed to initialize legacy HAL: " |
diff --git a/wifi/1.2/default/wifi.h b/wifi/1.2/default/wifi.h index d76e9c93..440c3c79 100644 --- a/wifi/1.2/default/wifi.h +++ b/wifi/1.2/default/wifi.h | |||
@@ -68,7 +68,7 @@ class Wifi : public V1_2::IWifi { | |||
68 | std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal(); | 68 | std::pair<WifiStatus, std::vector<ChipId>> getChipIdsInternal(); |
69 | std::pair<WifiStatus, sp<IWifiChip>> getChipInternal(ChipId chip_id); | 69 | std::pair<WifiStatus, sp<IWifiChip>> getChipInternal(ChipId chip_id); |
70 | 70 | ||
71 | WifiStatus initializeLegacyHal(); | 71 | WifiStatus initializeModeControllerAndLegacyHal(); |
72 | WifiStatus stopLegacyHalAndDeinitializeModeController( | 72 | WifiStatus stopLegacyHalAndDeinitializeModeController( |
73 | std::unique_lock<std::recursive_mutex>* lock); | 73 | std::unique_lock<std::recursive_mutex>* lock); |
74 | 74 | ||
diff --git a/wifi/1.2/default/wifi_mode_controller.cpp b/wifi/1.2/default/wifi_mode_controller.cpp index 8a89e810..c286d243 100644 --- a/wifi/1.2/default/wifi_mode_controller.cpp +++ b/wifi/1.2/default/wifi_mode_controller.cpp | |||
@@ -59,11 +59,15 @@ bool WifiModeController::isFirmwareModeChangeNeeded(IfaceType type) { | |||
59 | convertIfaceTypeToFirmwareMode(type)); | 59 | convertIfaceTypeToFirmwareMode(type)); |
60 | } | 60 | } |
61 | 61 | ||
62 | bool WifiModeController::changeFirmwareMode(IfaceType type) { | 62 | bool WifiModeController::initialize() { |
63 | if (!driver_tool_->LoadDriver()) { | 63 | if (!driver_tool_->LoadDriver()) { |
64 | LOG(ERROR) << "Failed to load WiFi driver"; | 64 | LOG(ERROR) << "Failed to load WiFi driver"; |
65 | return false; | 65 | return false; |
66 | } | 66 | } |
67 | return true; | ||
68 | } | ||
69 | |||
70 | bool WifiModeController::changeFirmwareMode(IfaceType type) { | ||
67 | if (!driver_tool_->ChangeFirmwareMode( | 71 | if (!driver_tool_->ChangeFirmwareMode( |
68 | convertIfaceTypeToFirmwareMode(type))) { | 72 | convertIfaceTypeToFirmwareMode(type))) { |
69 | LOG(ERROR) << "Failed to change firmware mode"; | 73 | LOG(ERROR) << "Failed to change firmware mode"; |
diff --git a/wifi/1.2/default/wifi_mode_controller.h b/wifi/1.2/default/wifi_mode_controller.h index e54fa6e4..395aa5d9 100644 --- a/wifi/1.2/default/wifi_mode_controller.h +++ b/wifi/1.2/default/wifi_mode_controller.h | |||
@@ -42,6 +42,7 @@ class WifiModeController { | |||
42 | // Checks if a firmware mode change is necessary to support the specified | 42 | // Checks if a firmware mode change is necessary to support the specified |
43 | // iface type operations. | 43 | // iface type operations. |
44 | virtual bool isFirmwareModeChangeNeeded(IfaceType type); | 44 | virtual bool isFirmwareModeChangeNeeded(IfaceType type); |
45 | virtual bool initialize(); | ||
45 | // Change the firmware mode to support the specified iface type operations. | 46 | // Change the firmware mode to support the specified iface type operations. |
46 | virtual bool changeFirmwareMode(IfaceType type); | 47 | virtual bool changeFirmwareMode(IfaceType type); |
47 | // Unload the driver. This should be invoked whenever |IWifi.stop()| is | 48 | // Unload the driver. This should be invoked whenever |IWifi.stop()| is |