zephyr/subsys
Johan Hedberg 9028e8e75b Bluetooth: ECC: Fix command status emission from wrong thread
HCI drivers are obliged to send HCI Command Status/Complete events
from a separate context than all other data, however the ECC wrapper
was violating this rule (sending everything from the same ECC thread).
This could lead to a deadlock if e.g. the ECC API user decides to
generate a DHKey from the same callback that it got notified of local
key-pair generation.

The obvious solution is to emit the Command Status directly from the
send function, before passing the command to be processed by the ECC
therad (through a k_fifo). However, this is not quite so simple since
bt_buf_get_cmd_complete() reuses the original command buffer, meaning
we'd loose the original parameters after sending a Command Status.

To work around this limitation with bt_buf_get_cmd_complete() we stop
passing the command buffer to the thread and instead store the
parameters in static variables and do the thread communication using
flags and a semaphore. One side effect is that only one command can be
pending at a time, however that works out fine for all of the users of
ECC.

A nice side effect of moving some things to static variables is that
we end up reducing call stack usage in the ECC thread, allowing it to
be shrunk by 180 bytes (verified to be sufficient for both ARM and
x86 boards).

Change-Id: Ic41f0316d3fe4d14b64fd3d0a549b221d168411a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-08 20:11:54 +03:00
..
bluetooth Bluetooth: ECC: Fix command status emission from wrong thread 2017-04-08 20:11:54 +03:00
console Revert "subsys/console: Yield on char availability." 2017-04-06 14:56:23 +03:00
debug subsys: gdb_server: Fix type mismatch 2017-03-01 14:26:16 +00:00
disk
fs fat: match type info expected by fat library for f_write 2017-01-30 12:01:50 +00:00
logging subsys/logging: sys_event_logger_get: Fix k_sem_take() success check. 2017-04-06 21:14:22 +00:00
net net: icmpv6: Print received packet type as string 2017-04-07 18:32:19 +03:00
shell
usb
Kconfig subsys: console: Add pull-style console API support. 2017-04-01 20:44:17 +00:00
Makefile subsys: console: Add pull-style console API support. 2017-04-01 20:44:17 +00:00