• Home
Name Date Size #Lines LOC

..--

tests/03-May-2024-2,1871,595

Android.bpD03-May-20243 KiB108102

Android.mkD03-May-20246 KiB203172

OWNERSD03-May-202440 32

THREADING.READMED03-May-20241.9 KiB3632

android.hardware.wifi@1.0-service-lazy.rcD03-May-2024588 1514

android.hardware.wifi@1.0-service.rcD03-May-2024558 1312

android.hardware.wifi@1.0-service.xmlD03-May-2024313 1211

hidl_callback_util.hD03-May-20243.9 KiB12381

hidl_return_util.hD03-May-20244.7 KiB11977

hidl_struct_util.cppD03-May-2024138.4 KiB3,0082,766

hidl_struct_util.hD03-May-202411.7 KiB205165

hidl_sync_util.cppD03-May-20241.1 KiB4019

hidl_sync_util.hD03-May-20241.2 KiB3817

ringbuffer.cppD03-May-20242 KiB6541

ringbuffer.hD03-May-20241.6 KiB6333

service.cppD03-May-20242.6 KiB7245

wifi.cppD03-May-202411.1 KiB295234

wifi.hD03-May-20244.1 KiB10665

wifi_ap_iface.cppD03-May-20248.6 KiB205154

wifi_ap_iface.hD03-May-20243.4 KiB9056

wifi_chip.cppD03-May-202487.8 KiB2,0621,746

wifi_chip.hD03-May-202418.6 KiB318257

wifi_feature_flags.cppD03-May-202410.5 KiB248138

wifi_feature_flags.hD03-May-20241.7 KiB5930

wifi_iface_util.cppD03-May-20246.1 KiB177136

wifi_iface_util.hD03-May-20243.1 KiB8845

wifi_legacy_hal.cppD03-May-202474.5 KiB1,6361,369

wifi_legacy_hal.hD03-May-202431.4 KiB731571

wifi_legacy_hal_factory.cppD03-May-20248 KiB255195

wifi_legacy_hal_factory.hD03-May-20242 KiB6736

wifi_legacy_hal_stubs.cppD03-May-20248.3 KiB178156

wifi_legacy_hal_stubs.hD03-May-20241.1 KiB3817

wifi_mode_controller.cppD03-May-20242.5 KiB9063

wifi_mode_controller.hD03-May-20241.9 KiB6429

wifi_nan_iface.cppD03-May-202447.7 KiB1,017886

wifi_nan_iface.hD03-May-202412.8 KiB209168

wifi_p2p_iface.cppD03-May-20242.1 KiB7042

wifi_p2p_iface.hD03-May-20241.9 KiB6734

wifi_rtt_controller.cppD03-May-202418 KiB378303

wifi_rtt_controller.hD03-May-20247.4 KiB139106

wifi_sta_iface.cppD03-May-202427.9 KiB593500

wifi_sta_iface.hD03-May-20248.8 KiB158125

wifi_status_util.cppD03-May-20243.7 KiB10774

wifi_status_util.hD03-May-20241.4 KiB4522

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