yangsong8-a1 opened a new pull request, #21717:
URL: https://github.com/apache/nuttx/pull/21717
## Summary
- Replace the global critical section in the BT H4 UART pseudo device
(drivers/serial/uart_bth4.c) with a per-device spinlock that protects
the rx circular buffer and the poll waiter slots.
- uart_bth4_read() drops the lock while it waits on recvsem and takes it
again before it checks the buffer.
## Impact
Only /dev/ttyHCI-style devices registered with uart_bth4_register()
(including through uart_bth5 and bt_driver_register()). There is no API
change. On SMP, the driver no longer serializes against unrelated users of
the global critical section.
## Testing
Ubuntu 22.04, gcc 13.1, aarch64-none-elf-gcc.
- Builds with no warnings in uart_bth4.c: sim:btuart, sim:nsh, sim:smp,
qemu-armv8a:nsh and qemu-armv8a:nsh_smp (with DRIVERS_BLUETOOTH +
UART_BTH4).
- A test app registers a fake bt_driver_s as /dev/ttyHCIt with
uart_bth4_register(). It injects HCI events from a watchdog (interrupt
context) and checks write/reassembly, blocking and non-blocking read,
poll, buffer full (-ENOMEM) and a 3000-event stress test with a
concurrent poll thread. Results are the same on sim:nsh, sim:smp (4 CPUs)
and qemu-armv8a:nsh_smp (QEMU, -smp 2):
```
bth4: write cmd ret 4 type 0 len 3 PASS
bth4: split write sends 0/1 PASS
bth4: nonblock empty read 0, bad type receive -22 PASS
bth4: blocking read 9 h4 0x04 seq 0x1234 PASS
bth4: poll ret 1 revents 0x1 read 9 PASS
bth4: filled 899 events, drained 8091 bytes PASS
bth4: stress injected 3000 dropped 0 read 3000 bad 0 polls 200 PASS
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]