• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

tests/22-Nov-2023-1,301901

Android.mkD22-Nov-20235.9 KiB199168

OWNERSD22-Nov-202340 32

THREADING.READMED22-Nov-20231.9 KiB3632

android.hardware.wifi@1.0-service-lazy.rcD22-Nov-2023533 1413

android.hardware.wifi@1.0-service.rcD22-Nov-2023503 1211

android.hardware.wifi@1.0-service.xmlD22-Nov-2023313 1211

hidl_callback_util.hD22-Nov-20233.8 KiB12583

hidl_return_util.hD22-Nov-20234.6 KiB12179

hidl_struct_util.cppD22-Nov-2023126.3 KiB3,0602,826

hidl_struct_util.hD22-Nov-202310.3 KiB228189

hidl_sync_util.cppD22-Nov-20231.1 KiB4019

hidl_sync_util.hD22-Nov-20231.2 KiB3817

ringbuffer.cppD22-Nov-20231.6 KiB6036

ringbuffer.hD22-Nov-20231.4 KiB5526

service.cppD22-Nov-20232.7 KiB8053

wifi.cppD22-Nov-202311.2 KiB305244

wifi.hD22-Nov-20233.9 KiB10870

wifi_ap_iface.cppD22-Nov-20238.8 KiB221170

wifi_ap_iface.hD22-Nov-20233.4 KiB9662

wifi_chip.cppD22-Nov-202381.5 KiB2,0661,765

wifi_chip.hD22-Nov-202316.8 KiB344286

wifi_feature_flags.cppD22-Nov-20239.3 KiB246138

wifi_feature_flags.hD22-Nov-20231.7 KiB6031

wifi_iface_util.cppD22-Nov-20235.8 KiB178138

wifi_iface_util.hD22-Nov-20233.2 KiB9249

wifi_legacy_hal.cppD22-Nov-202371.4 KiB1,7261,468

wifi_legacy_hal.hD22-Nov-202331.1 KiB764613

wifi_legacy_hal_factory.cppD22-Nov-20238.1 KiB264204

wifi_legacy_hal_factory.hD22-Nov-20232 KiB

wifi_legacy_hal_stubs.cppD22-Nov-20238 KiB172150

wifi_legacy_hal_stubs.hD22-Nov-20231.1 KiB3817

wifi_mode_controller.cppD22-Nov-20232.5 KiB9265

wifi_mode_controller.hD22-Nov-20231.9 KiB6429

wifi_nan_iface.cppD22-Nov-202342.2 KiB1,004885

wifi_nan_iface.hD22-Nov-20239.7 KiB213174

wifi_p2p_iface.cppD22-Nov-20232.1 KiB6739

wifi_p2p_iface.hD22-Nov-20231.9 KiB6734

wifi_rtt_controller.cppD22-Nov-202314.1 KiB352292

wifi_rtt_controller.hD22-Nov-20236 KiB13198

wifi_sta_iface.cppD22-Nov-202328.3 KiB676585

wifi_sta_iface.hD22-Nov-20238.5 KiB188155

wifi_status_util.cppD22-Nov-20233.9 KiB11380

wifi_status_util.hD22-Nov-20231.5 KiB4623

THREADING.README

1Vendor HAL Threading Model
2==========================
3The vendor HAL service has two threads:
41. HIDL thread: This is the main thread which processes all the incoming HIDL
5RPC's.
62. Legacy HAL event loop thread: This is the thread forked off for processing
7the legacy HAL event loop (wifi_event_loop()). This thread is used to process
8any asynchronous netlink events posted by the driver. Any asynchronous
9callbacks passed to the legacy HAL API's are invoked on this thread.
10
11Synchronization Concerns
12========================
13wifi_legacy_hal.cpp has a bunch of global "C" style functions to handle the
14legacy callbacks. Each of these "C" style function invokes a corresponding
15"std::function" version of the callback which does the actual processing.
16The variables holding these "std::function" callbacks are reset from the HIDL
17thread when they are no longer used. For example: stopGscan() will reset the
18corresponding "on_gscan_*" callback variables which were set when startGscan()
19was invoked. This is not thread safe since these callback variables are
20accesed from the legacy hal event loop thread as well.
21
22Synchronization Solution
23========================
24Adding a global lock seems to be the most trivial solution to the problem.
25a) All of the asynchronous "C" style callbacks will acquire the global lock
26before invoking the corresponding "std::function" callback variables.
27b) All of the HIDL methods will also acquire the global lock before processing
28(in hidl_return_util::validateAndCall()).
29
30Note: It's important that we only acquire the global lock for asynchronous
31callbacks, because there is no guarantee (or documentation to clarify) that the
32synchronous callbacks are invoked on the same invocation thread. If that is not
33the case in some implementation, we will end up deadlocking the system since the
34HIDL thread would have acquired the global lock which is needed by the
35synchronous callback executed on the legacy hal event loop thread.
36