mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
BT Interface: fix hci cmd timeout
Add mutex in function Send() and OnTimeout() to do mutual exclusive access on lpm_wake_deasserted. If lpm_wake_deasserted is out of sync with the actual wake state, then platforms which use the lpm hint will break. Bug: 64299848 Test: run affected platform for a long period of time and find that hci commands do not time out Change-Id: I9f630d6f40f84b9c047c6488632cd44d6602bb14
This commit is contained in:
committed by
Myles Watson
parent
207e97c735
commit
424ffd0da5
@@ -49,6 +49,7 @@ uint32_t lpm_timeout_ms;
|
|||||||
bool recent_activity_flag;
|
bool recent_activity_flag;
|
||||||
|
|
||||||
VendorInterface* g_vendor_interface = nullptr;
|
VendorInterface* g_vendor_interface = nullptr;
|
||||||
|
std::mutex wakeup_mutex_;
|
||||||
|
|
||||||
HC_BT_HDR* WrapPacketAndCopy(uint16_t event, const hidl_vec<uint8_t>& data) {
|
HC_BT_HDR* WrapPacketAndCopy(uint16_t event, const hidl_vec<uint8_t>& data) {
|
||||||
size_t packet_size = data.size() + sizeof(HC_BT_HDR);
|
size_t packet_size = data.size() + sizeof(HC_BT_HDR);
|
||||||
@@ -308,6 +309,7 @@ void VendorInterface::Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t VendorInterface::Send(uint8_t type, const uint8_t* data, size_t length) {
|
size_t VendorInterface::Send(uint8_t type, const uint8_t* data, size_t length) {
|
||||||
|
std::unique_lock<std::mutex> lock(wakeup_mutex_);
|
||||||
recent_activity_flag = true;
|
recent_activity_flag = true;
|
||||||
|
|
||||||
if (lpm_wake_deasserted == true) {
|
if (lpm_wake_deasserted == true) {
|
||||||
@@ -350,6 +352,7 @@ void VendorInterface::OnFirmwareConfigured(uint8_t result) {
|
|||||||
|
|
||||||
void VendorInterface::OnTimeout() {
|
void VendorInterface::OnTimeout() {
|
||||||
ALOGV("%s", __func__);
|
ALOGV("%s", __func__);
|
||||||
|
std::unique_lock<std::mutex> lock(wakeup_mutex_);
|
||||||
if (recent_activity_flag == false) {
|
if (recent_activity_flag == false) {
|
||||||
lpm_wake_deasserted = true;
|
lpm_wake_deasserted = true;
|
||||||
bt_vendor_lpm_wake_state_t wakeState = BT_VND_LPM_WAKE_DEASSERT;
|
bt_vendor_lpm_wake_state_t wakeState = BT_VND_LPM_WAKE_DEASSERT;
|
||||||
|
|||||||
Reference in New Issue
Block a user