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 <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-06-30 14:44:21 +03:00 committed by Johan Hedberg
commit 2684775d0f

View file

@ -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;
}