ue,proc_ra_nr: add mutex to protect access from PHY and Stack

detected with TSAN
master
Andre Puschmann 3 years ago committed by Xavier Arteaga
parent cc2d71183e
commit 2248e63219

@ -64,6 +64,7 @@ private:
int ra_window_length = -1, ra_window_start = -1; int ra_window_length = -1, ra_window_start = -1;
uint16_t rar_rnti = SRSRAN_INVALID_RNTI; uint16_t rar_rnti = SRSRAN_INVALID_RNTI;
uint16_t temp_crnti = SRSRAN_INVALID_RNTI; uint16_t temp_crnti = SRSRAN_INVALID_RNTI;
std::mutex mutex;
srsran::rach_nr_cfg_t rach_cfg = {}; srsran::rach_nr_cfg_t rach_cfg = {};
bool configured = false; bool configured = false;

@ -114,11 +114,13 @@ bool proc_ra_nr::has_rar_rnti()
bool proc_ra_nr::has_temp_crnti() bool proc_ra_nr::has_temp_crnti()
{ {
std::lock_guard<std::mutex> lock(mutex);
return temp_crnti != SRSRAN_INVALID_RNTI; return temp_crnti != SRSRAN_INVALID_RNTI;
} }
uint16_t proc_ra_nr::get_temp_crnti() uint16_t proc_ra_nr::get_temp_crnti()
{ {
std::lock_guard<std::mutex> lock(mutex);
return temp_crnti; return temp_crnti;
} }
@ -180,6 +182,7 @@ void proc_ra_nr::ra_preamble_transmission()
// 5.1.4 Random Access Preamble transmission // 5.1.4 Random Access Preamble transmission
void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_result_t& tb) void proc_ra_nr::ra_response_reception(const mac_interface_phy_nr::tb_action_dl_result_t& tb)
{ {
std::lock_guard<std::mutex> lock(mutex);
if (state != WAITING_FOR_RESPONSE_RECEPTION) { if (state != WAITING_FOR_RESPONSE_RECEPTION) {
logger.warning( logger.warning(
"Wrong state for ra reponse reception %s (expected state %s)", "Wrong state for ra reponse reception %s (expected state %s)",
@ -265,6 +268,7 @@ void proc_ra_nr::ra_contention_resolution(uint64_t rx_contention_id)
void proc_ra_nr::ra_completion() void proc_ra_nr::ra_completion()
{ {
std::lock_guard<std::mutex> lock(mutex);
if (state != WAITING_FOR_COMPLETION) { if (state != WAITING_FOR_COMPLETION) {
logger.warning("Wrong state for ra completion by phy %s (expected state %s)", logger.warning("Wrong state for ra completion by phy %s (expected state %s)",
srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state), srsran::enum_to_text(state_str_nr, (uint32_t)ra_state_t::MAX_RA_STATES, state),
@ -279,6 +283,7 @@ void proc_ra_nr::ra_completion()
void proc_ra_nr::ra_error() void proc_ra_nr::ra_error()
{ {
std::lock_guard<std::mutex> lock(mutex);
temp_crnti = SRSRAN_INVALID_RNTI; temp_crnti = SRSRAN_INVALID_RNTI;
preamble_transmission_counter++; preamble_transmission_counter++;
contention_resolution_timer.stop(); contention_resolution_timer.stop();

Loading…
Cancel
Save