From 2d3581c6def074c3b4a0ec3c1cf0d1e5149daa19 Mon Sep 17 00:00:00 2001 From: Armin Brauns Date: Thu, 1 Aug 2024 11:01:34 +0000 Subject: [PATCH] bluetooth: honor log panic mode in monitor 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 --- subsys/bluetooth/host/monitor.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/subsys/bluetooth/host/monitor.c b/subsys/bluetooth/host/monitor.c index abc84a7837c1b82..c6106cccc9c2cc3 100644 --- a/subsys/bluetooth/host/monitor.c +++ b/subsys/bluetooth/host/monitor.c @@ -52,6 +52,7 @@ enum { }; static atomic_t flags; +static bool panic_mode; static struct { atomic_t cmd; @@ -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) { @@ -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)