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

..--

tests/15-Dec-2024-2,6772,008

Android.bpD15-Dec-20246.2 KiB221209

THREADING.READMED14-Jan-20241.9 KiB3632

aidl_callback_util.hD14-Jan-20245.1 KiB153107

aidl_return_util.hD14-Jan-20243.2 KiB8650

aidl_struct_util.cppD15-Dec-2024174.4 KiB3,7613,492

aidl_struct_util.hD15-Dec-202414.3 KiB241202

aidl_sync_util.cppD14-Jan-20241 KiB3817

aidl_sync_util.hD14-Jan-20241.1 KiB3615

android.hardware.wifi-service-lazy.rcD14-Jan-2024254 98

android.hardware.wifi-service.rcD14-Jan-2024224 76

android.hardware.wifi-service.xmlD15-Dec-2024173 87

ringbuffer.cppD14-Jan-20241.9 KiB6339

ringbuffer.hD14-Jan-20241.6 KiB6131

service.cppD14-Jan-20242.8 KiB7445

wifi.cppD15-Dec-202416.1 KiB429353

wifi.hD14-Jan-20243.6 KiB9759

wifi_ap_iface.cppD14-Jan-20246.9 KiB173124

wifi_ap_iface.hD14-Jan-20242.8 KiB7845

wifi_chip.cppD15-Dec-202483 KiB1,9431,646

wifi_chip.hD15-Dec-202417.7 KiB311251

wifi_feature_flags.cppD15-Dec-20249.5 KiB230126

wifi_feature_flags.hD14-Jan-20241.6 KiB5728

wifi_iface_util.cppD14-Jan-20246 KiB175133

wifi_iface_util.hD14-Jan-20243.1 KiB8543

wifi_legacy_hal.cppD15-Dec-2024101.1 KiB2,1721,823

wifi_legacy_hal.hD15-Dec-202439.5 KiB890716

wifi_legacy_hal_factory.cppD14-Jan-20248 KiB257197

wifi_legacy_hal_factory.hD14-Jan-20242 KiB6534

wifi_legacy_hal_stubs.cppD15-Dec-20249.7 KiB201178

wifi_legacy_hal_stubs.hD14-Jan-20241 KiB3615

wifi_mode_controller.cppD14-Jan-20242.5 KiB8961

wifi_mode_controller.hD14-Jan-20241.8 KiB6026

wifi_nan_iface.cppD14-Jan-202447.7 KiB1,016903

wifi_nan_iface.hD14-Jan-20248.4 KiB157117

wifi_p2p_iface.cppD14-Jan-20241.7 KiB6033

wifi_p2p_iface.hD14-Jan-20241.7 KiB6229

wifi_rtt_controller.cppD15-Dec-202415.2 KiB326270

wifi_rtt_controller.hD14-Jan-20244.6 KiB10367

wifi_sta_iface.cppD15-Dec-202438.2 KiB815702

wifi_sta_iface.hD15-Dec-20249.3 KiB172135

wifi_status_util.cppD14-Jan-20243.9 KiB10774

wifi_status_util.hD14-Jan-20241.4 KiB4320

THREADING.README

1Vendor HAL Threading Model
2==========================
3The vendor HAL service has two threads:
41. AIDL thread: This is the main thread which processes all the incoming AIDL
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 functions 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 AIDL
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 AIDL methods will also acquire the global lock before processing
28(in aidl_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
34AIDL thread would have acquired the global lock which is needed by the
35synchronous callback executed on the legacy hal event loop thread.
36