[EXT_EP-11609] Critical Section order not optimal in ICall_leaveCSImpl & ICall_enterCSImpl functions Created: 20/Dec/23  Updated: 01/Apr/25  Resolved: 07/Mar/24

Status: Fixed
Project: Embedded Software & Tools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: High
Reporter: TI User Assignee: TI User
Resolution: Fixed Votes: 0
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Product: SimpleLink Lowpower SDK F3 BLE5 Stack
Internal ID: BLE_LOKI-1034
Found In Release: BLE Stack BLE5-3.2.2
Fix In Release: BLE Stack BLE5-3.3.1 RC1
BLE Stack BLE5-3.3.1
Affected Platform/Device: CC23XX

 Description   

In the ICall_leaveCSImpl(ICall_CSState key) and ICall_CSState ICall_enterCSImpl(void)

When we enter CS, we disable Swi first, but the hwi can still occur before we disable hwi. Most of the times, there is no issue.

However, in some use cases, it is possible that sometimes the radio runs right after Swi is disabled, which then can eventually causing the wrong keys being used when we exist CS causing Swi being disable forever.

The proposed fix is that to disable hwi first when entering CS to make sure nothing can run.
And to enable hwi last when exiting CS.

ICall_CSState ICall_enterCSImpl(void)
{

  ICall_CSStateUnion cu;
  cu.each.hwikey = (uint_least16_t) Hwi_disable();
  cu.each.swikey = (uint_least16_t) Swi_disable();
  return cu.state;
}
/* leave critical section implementation. See header file for comment */
void ICall_leaveCSImpl(ICall_CSState key)
{
  ICall_CSStateUnion *cu = (ICall_CSStateUnion *) &key;
  Swi_restore((uint32_t) cu->each.swikey);
  Hwi_restore((uint32_t) cu->each.hwikey);
}

Generated at Sat Apr 05 09:21:39 CDT 2025 using Jira 9.12.17#9120017-sha1:aba4002bcd633f188b6a4bb5dd8a0e1f20b79ee4.