• Home
Name Date Size #Lines LOC

..--

tests/03-May-2024-2,0561,486

Android.mkD03-May-20245.1 KiB178147

OWNERSD03-May-202438 32

THREADING.READMED03-May-20241.9 KiB3632

android.hardware.wifi@1.0-service-lazy.rcD03-May-2024478 1312

android.hardware.wifi@1.0-service.rcD03-May-2024448 1110

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

hidl_callback_util.hD03-May-20243.8 KiB12583

hidl_return_util.hD03-May-20244.6 KiB12179

hidl_struct_util.cppD03-May-2024112.7 KiB2,7392,527

hidl_struct_util.hD03-May-20248.6 KiB199160

hidl_sync_util.cppD03-May-20241.1 KiB4019

hidl_sync_util.hD03-May-20241.2 KiB3817

ringbuffer.cppD03-May-20241.5 KiB5532

ringbuffer.hD03-May-20241.4 KiB5425

service.cppD03-May-20242.6 KiB7448

wifi.cppD03-May-20248.1 KiB221178

wifi.hD03-May-20243.5 KiB10163

wifi_ap_iface.cppD03-May-20245 KiB138103

wifi_ap_iface.hD03-May-20242.9 KiB8552

wifi_chip.cppD03-May-202465.3 KiB1,6621,418

wifi_chip.hD03-May-202413.8 KiB295236

wifi_feature_flags.cppD03-May-20246.1 KiB16785

wifi_feature_flags.hD03-May-20241.6 KiB5628

wifi_iface_util.cppD03-May-20244.3 KiB136104

wifi_iface_util.hD03-May-20242.6 KiB7840

wifi_legacy_hal.cppD03-May-202462.4 KiB1,5001,280

wifi_legacy_hal.hD03-May-202419.7 KiB416289

wifi_legacy_hal_stubs.cppD03-May-20247 KiB154132

wifi_legacy_hal_stubs.hD03-May-20241.1 KiB3717

wifi_mode_controller.cppD03-May-20242.5 KiB9265

wifi_mode_controller.hD03-May-20241.9 KiB6429

wifi_nan_iface.cppD03-May-202439.2 KiB934824

wifi_nan_iface.hD03-May-20248.3 KiB187149

wifi_p2p_iface.cppD03-May-20242.1 KiB6739

wifi_p2p_iface.hD03-May-20241.9 KiB6734

wifi_rtt_controller.cppD03-May-202414 KiB352292

wifi_rtt_controller.hD03-May-20245.9 KiB13198

wifi_sta_iface.cppD03-May-202427.1 KiB647561

wifi_sta_iface.hD03-May-20248.1 KiB181148

wifi_status_util.cppD03-May-20243.9 KiB11380

wifi_status_util.hD03-May-20241.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