Skip to content

Commit

Permalink
Bluetooth: Controller: Fix some compiler instruction re-ordering
Browse files Browse the repository at this point in the history
Fix some compiler instruction re-ordering. Mayfly code with
cpu_dmb() help avoid stalled memq_ull_rx processing when
rx_demux is to be executed using mayfly.

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
(cherry picked from commit f206953)
  • Loading branch information
cvinayak authored and github-actions[bot] committed Sep 14, 2023
1 parent a042ba2 commit 24ffcf4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions subsys/bluetooth/controller/ticker/ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -2663,6 +2663,7 @@ void ticker_job(void *param)
instance->job_guard = 0U;

/* trigger worker if deferred */
cpu_dmb();
if (instance->worker_trigger || compare_trigger) {
instance->sched_cb(TICKER_CALL_ID_JOB, TICKER_CALL_ID_WORKER, 1,
instance);
Expand Down
7 changes: 7 additions & 0 deletions subsys/bluetooth/controller/util/mayfly.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
*/

#include <stddef.h>

#include <soc.h>
#include <zephyr/types.h>
#include <zephyr/sys/printk.h>

#include "hal/cpu.h"

#include "memq.h"
#include "mayfly.h"

Expand Down Expand Up @@ -154,10 +159,12 @@ static void dequeue(uint8_t callee_id, uint8_t caller_id, memq_link_t *link,
m->_link = link;

/* reset mayfly state to idle */
cpu_dmb();
ack = m->_ack;
m->_ack = req;

/* re-insert, if re-pended by interrupt */
cpu_dmb();
if (((m->_req - ack) & 0x03) == 1U) {
#if defined(MAYFLY_UT)
printk("%s: RACE\n", __func__);
Expand Down

0 comments on commit 24ffcf4

Please sign in to comment.