mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-07-31 15:17:54 +00:00
nimble/ll: Fix race condition
This patch fixes race condition when g_ble_ll_data.ll_rfclk_state is out of sync with nrf52_clock_hfxo_refcnt in nrf52_clock.c It could happen when HCI Reset has been done while scanning/advertising etc. This patch also adds OS_ASSERT_CRITICAL() in places where ll_rfclk_state is changed.
This commit is contained in:
@@ -1303,8 +1303,10 @@ ble_ll_reset(void)
|
||||
ble_ll_state_set(BLE_LL_STATE_STANDBY);
|
||||
|
||||
#ifdef BLE_XCVR_RFCLK
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
/* Stops rf clock and rfclock timer */
|
||||
ble_ll_xcvr_rfclk_stop();
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
#endif
|
||||
|
||||
/* Reset our random address */
|
||||
|
||||
@@ -33,6 +33,7 @@ ble_ll_xcvr_rfclk_state(void)
|
||||
{
|
||||
uint32_t expiry;
|
||||
|
||||
OS_ASSERT_CRITICAL();
|
||||
if (g_ble_ll_data.ll_rfclk_state == BLE_RFCLK_STATE_ON) {
|
||||
expiry = g_ble_ll_data.ll_rfclk_start_time;
|
||||
if ((int32_t)(os_cputime_get32() - expiry) >
|
||||
@@ -46,6 +47,7 @@ ble_ll_xcvr_rfclk_state(void)
|
||||
void
|
||||
ble_ll_xcvr_rfclk_enable(void)
|
||||
{
|
||||
OS_ASSERT_CRITICAL();
|
||||
if (g_ble_ll_data.ll_rfclk_state == BLE_RFCLK_STATE_OFF) {
|
||||
g_ble_ll_data.ll_rfclk_state = BLE_RFCLK_STATE_ON;
|
||||
ble_phy_rfclk_enable();
|
||||
@@ -55,6 +57,7 @@ ble_ll_xcvr_rfclk_enable(void)
|
||||
void
|
||||
ble_ll_xcvr_rfclk_disable(void)
|
||||
{
|
||||
OS_ASSERT_CRITICAL();
|
||||
if (g_ble_ll_data.ll_rfclk_state != BLE_RFCLK_STATE_OFF) {
|
||||
ble_phy_rfclk_disable();
|
||||
g_ble_ll_data.ll_rfclk_state = BLE_RFCLK_STATE_OFF;
|
||||
|
||||
Reference in New Issue
Block a user