From 24ffcf46a02315e1db1daa269167480d4a0f3d9a Mon Sep 17 00:00:00 2001 From: Vinayak Kariappa Chettimada Date: Wed, 13 Sep 2023 12:37:29 +0530 Subject: [PATCH] Bluetooth: Controller: Fix some compiler instruction re-ordering 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 (cherry picked from commit f2069530ee9d73d2c5c3a65bd3b146b0631593fb) --- subsys/bluetooth/controller/ticker/ticker.c | 1 + subsys/bluetooth/controller/util/mayfly.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/subsys/bluetooth/controller/ticker/ticker.c b/subsys/bluetooth/controller/ticker/ticker.c index 5f3b69ee77d7af..722aac87b75a3d 100644 --- a/subsys/bluetooth/controller/ticker/ticker.c +++ b/subsys/bluetooth/controller/ticker/ticker.c @@ -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); diff --git a/subsys/bluetooth/controller/util/mayfly.c b/subsys/bluetooth/controller/util/mayfly.c index e8de3acfd80a65..d45569c6a359e3 100644 --- a/subsys/bluetooth/controller/util/mayfly.c +++ b/subsys/bluetooth/controller/util/mayfly.c @@ -6,8 +6,13 @@ */ #include + +#include #include #include + +#include "hal/cpu.h" + #include "memq.h" #include "mayfly.h" @@ -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__);