From 2684775d0fbd62ce4ec1401d7acf78178d51ad81 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 30 Jun 2017 14:44:21 +0300 Subject: [PATCH] Bluetooth: monitor: Remove interrupt locking from monitor_console_out() Locking interrupts for a long duration is in general bad design, and is particularly bad for the controller which depends on low latency interrupts. Instead of using interrupt locking introduce a new flag to track the shared buffer usage and simply drop characters if the flag is set. Signed-off-by: Johan Hedberg --- subsys/bluetooth/host/monitor.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/subsys/bluetooth/host/monitor.c b/subsys/bluetooth/host/monitor.c index 6ea68b6417c..46f3284f3a8 100644 --- a/subsys/bluetooth/host/monitor.c +++ b/subsys/bluetooth/host/monitor.c @@ -33,6 +33,7 @@ static struct device *monitor_dev; enum { BT_LOG_BUSY, + BT_CONSOLE_BUSY, }; static atomic_t flags; @@ -211,13 +212,14 @@ static int monitor_console_out(int c) { static char buf[128]; static size_t len; - int key; - key = irq_lock(); + if (atomic_test_and_set_bit(&flags, BT_CONSOLE_BUSY)) { + return c; + } if (c != '\n' && len < sizeof(buf) - 1) { buf[len++] = c; - irq_unlock(key); + atomic_clear_bit(&flags, BT_CONSOLE_BUSY); return c; } @@ -226,7 +228,7 @@ static int monitor_console_out(int c) bt_monitor_send(BT_MONITOR_SYSTEM_NOTE, buf, len); len = 0; - irq_unlock(key); + atomic_clear_bit(&flags, BT_CONSOLE_BUSY); return c; }