Shanks0224 opened a new pull request, #22611: URL: https://github.com/apache/nuttx/pull/22611
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary `spislave_bind()` initializes the controller with `spislave_initialize()`, which with `CONFIG_ESP32S3_SPI_DMA` also requests a GDMA channel, but `spislave_unbind()` only disabled the interrupts and the clocks and never released the channel. Every bind therefore took one more channel. The SPI slave character driver binds on each open, so after a few open/close cycles no channel was left and the bind failed. Call `spislave_deinitialize()` from `spislave_unbind()`, after the lock is released because releasing the channel takes a mutex, and release the channel only once, as `esp32s3_spislave_ctrlr_uninitialize()` also deinitializes the controller. The existing nxstyle error (missing blank line after declarations) in the file is fixed too. ## Impact ESP32-S3 SPI slave. A bound device no longer leaks a GDMA channel on each unbind. `spislave_deinitialize()` now also runs on unbind: besides releasing the channel it turns off the SPI and DMA clocks, which `spislave_unbind()` did before, and holds the SPI peripheral in reset until the next bind initializes it again. ## Testing ESP32-S3 on the Espressif QEMU (esp-develop-9.0.0-20240606), esp32s3-devkit:spislv + `CONFIG_ESP32S3_SPI_DMA=y CONFIG_ESP32S3_QEMU_IMAGE=y CONFIG_DEBUG_FEATURES=y CONFIG_DEBUG_ASSERTIONS=y`, xtensa-esp-elf 14.2.0. The test opens and closes `/dev/spislv2` 12 times, more often than there are GDMA channels. master: ``` R1 open/close 0 ok R1 open/close 1 ok R1 open/close 2 ok R1 open/close 3 ok R1 open/close 4 ok dump_assert_info: Assertion failed panic: at file: chip/esp32s3_spi_slave.c:1504 task: hello process: hello 0x42026944 ``` (`spislave_initialize()` fails in bind because no GDMA channel is left.) this PR: ``` R1 open/close 0 ok ... R1 open/close 11 ok TEST DONE ``` esp32s3-devkit:spislv with and without `CONFIG_ESP32S3_SPI_DMA` and with `CONFIG_ESP32S3_SPI_IO_QIO=y`, and esp32s3-devkit:nsh build; the QIO configuration has the same 19 `-Warray-bounds` warnings from `xtensa.h` as on master. Not tested on real hardware. -- 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]
