Skip to content

fix:Unblock RPC/SDIO threads for graceful shutdown (EHM-194)#173

Open
Kevincoooool wants to merge 1 commit intoespressif:mainfrom
Kevincoooool:main
Open

fix:Unblock RPC/SDIO threads for graceful shutdown (EHM-194)#173
Kevincoooool wants to merge 1 commit intoespressif:mainfrom
Kevincoooool:main

Conversation

@Kevincoooool
Copy link
Copy Markdown

Unblock and allow orderly suspension of RPC and SDIO worker threads during deinit to avoid heap corruption and dangling waits. rpc_core: include FreeRTOS headers, post RPC/serial semaphores, call serial_post_read_semaphore and delay before cancelling threads so they can observe INACTIVE state. serial_drv: add serial_post_read_semaphore to wake the serial read semaphore. sdio_drv: add sdio_exit_requested flag, post SDIO-related semaphores on bus deinit, wait before cancelling threads, make tasks check the exit flag and call vTaskSuspend(NULL) instead of being abruptly deleted, use a timed wait for slave interrupt to allow periodic exit checks, reorder mempool/bus deinit and buffer free to avoid DMA writing to freed memory, and reset counters/flags on init/deinit. These changes make shutdowns safer and prevent buffer/heap races.

Description

Related

Testing


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Unblock and allow orderly suspension of RPC and SDIO worker threads during deinit to avoid heap corruption and dangling waits. rpc_core: include FreeRTOS headers, post RPC/serial semaphores, call serial_post_read_semaphore and delay before cancelling threads so they can observe INACTIVE state. serial_drv: add serial_post_read_semaphore to wake the serial read semaphore. sdio_drv: add sdio_exit_requested flag, post SDIO-related semaphores on bus deinit, wait before cancelling threads, make tasks check the exit flag and call vTaskSuspend(NULL) instead of being abruptly deleted, use a timed wait for slave interrupt to allow periodic exit checks, reorder mempool/bus deinit and buffer free to avoid DMA writing to freed memory, and reset counters/flags on init/deinit. These changes make shutdowns safer and prevent buffer/heap races.
@github-actions github-actions Bot changed the title fix:Unblock RPC/SDIO threads for graceful shutdown fix:Unblock RPC/SDIO threads for graceful shutdown (EHM-194) Mar 19, 2026
@espressif-bot espressif-bot added the Status: Opened Issue is new label Mar 19, 2026
@ThunderDai
Copy link
Copy Markdown

ThunderDai commented Mar 20, 2026

host_shuts_down_slave_to_power_save.zip
hosted_heap_issues.txt
hi, this is test project and log, please check, mainly enable HEAP_POISONING_COMPREHENSIVE

@mantriyogesh
Copy link
Copy Markdown
Collaborator

Thanks a lot @Kevincoooool , for your contribution and time.
We appreciate it much.

We will have a review and merge the changes.

@SohKamYung-Espressif Can you please review?

Some generic comments:

  1. Host side core code to be written agnostic of OS. Any port level stuff can go inside the port layer.
  2. Is the suspend mandatory, before deinit? Need to check how we can minimise the change.

@mantriyogesh
Copy link
Copy Markdown
Collaborator

@ThunderDai ,

#173 (comment)

Yes these would be really useful, for co-relating the case. thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Opened Issue is new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants