Commit 0b1a566
src/cyw43_ctrl: Lock the bus across BT HCI read/write.
cyw43_bluetooth_hci_read() and cyw43_bluetooth_hci_write() call
cyw43_btbus_read()/cyw43_btbus_write() without holding the cyw43 bus
lock. The BT shared bus runs over the same gSPI/SDIO backplane as WiFi,
so a caller that does not already serialise against WiFi will interleave
WiFi and BT transfers on the bus.
The btstack HCI transport in pico-sdk already wraps these calls in
CYW43_THREAD_ENTER/EXIT, so it is unaffected. But any other consumer
that calls the BT HCI API directly (e.g. a non-btstack or multi-threaded
port) is left unprotected. Take CYW43_THREAD_ENTER across the whole
transfer so the functions are self-serialising. The lock is recursive,
so the existing wrapping in the btstack transport and the nested
cyw43_ensure_bt_up() continue to work unchanged.
Signed-off-by: Jonathan Beri <jmberi@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 055d642 commit 0b1a566
1 file changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
785 | 790 | | |
786 | 791 | | |
| 792 | + | |
787 | 793 | | |
788 | 794 | | |
789 | 795 | | |
790 | 796 | | |
791 | 797 | | |
792 | | - | |
793 | 798 | | |
794 | | - | |
| 799 | + | |
| 800 | + | |
795 | 801 | | |
796 | 802 | | |
797 | 803 | | |
798 | 804 | | |
799 | 805 | | |
| 806 | + | |
| 807 | + | |
800 | 808 | | |
801 | 809 | | |
| 810 | + | |
802 | 811 | | |
803 | 812 | | |
804 | 813 | | |
805 | 814 | | |
806 | 815 | | |
807 | | - | |
808 | 816 | | |
809 | | - | |
| 817 | + | |
| 818 | + | |
810 | 819 | | |
811 | 820 | | |
0 commit comments