Skip to content

Commit

Permalink
bluetooth: honor log panic mode in monitor
Browse files Browse the repository at this point in the history
Once panic mode is entered, the log write functions are called from an ISR,
so must not try to acquire locks.

Signed-off-by: Armin Brauns <[email protected]>
  • Loading branch information
arbrauns committed Aug 2, 2024
1 parent e503799 commit 2d3581c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions subsys/bluetooth/host/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum {
};

static atomic_t flags;
static bool panic_mode;

static struct {
atomic_t cmd;
Expand Down Expand Up @@ -123,10 +124,14 @@ static void monitor_send(const void *data, size_t len)
}

if (!drop) {
SEGGER_RTT_LOCK();
if (!panic_mode) {
SEGGER_RTT_LOCK();
}
cnt = SEGGER_RTT_WriteNoLock(CONFIG_BT_DEBUG_MONITOR_RTT_BUFFER,
rtt_buf, rtt_buf_offset);
SEGGER_RTT_UNLOCK();
if (!panic_mode) {
SEGGER_RTT_UNLOCK();
}
}

if (!cnt) {
Expand Down Expand Up @@ -350,6 +355,7 @@ static void monitor_log_process(const struct log_backend *const backend,

static void monitor_log_panic(const struct log_backend *const backend)
{
panic_mode = true;
}

static void monitor_log_init(const struct log_backend *const backend)
Expand Down

0 comments on commit 2d3581c

Please sign in to comment.