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:
parent
803eab08ec
commit
2684775d0f
1 changed files with 6 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue