Skip to content

change(cache): split stop/start (suspend) from freeze/unfreeze#116

Draft
erhankur wants to merge 1 commit into
masterfrom
add_cache_suspend_resume
Draft

change(cache): split stop/start (suspend) from freeze/unfreeze#116
erhankur wants to merge 1 commit into
masterfrom
add_cache_suspend_resume

Conversation

@erhankur

@erhankur erhankur commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@erhankur erhankur marked this pull request as draft June 3, 2026 11:50
@erhankur erhankur requested review from Copilot and sobuch June 3, 2026 11:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR separates cache “stop/start” (suspend/resume semantics that may preserve/restore autoload state) from “freeze/unfreeze” (pipeline freeze semantics), and updates MMU mapping code to use freeze/unfreeze to avoid ROM freeze-disable hangs when the cache pipeline is still busy.

Changes:

  • Add new public/internal APIs: stub_*_cache_freeze() / stub_*_cache_unfreeze() with a weak fallback to stop/start.
  • Update several RISC-V targets (c2/c3/c5/c6/c61/h2/h21/h4) to use ROM Cache_Suspend_*/Cache_Resume_* for stop/start and to drain AUTOLOAD/PRELOAD before unfreezing.
  • Switch src/mmu.c to use freeze/unfreeze around temporary MMU remaps.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/target/esp32h4/src/cache.c Stop/start now uses ROM suspend/resume; adds explicit freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32h4/include/soc/cache_reg.h Adds AUTOLOAD_DONE and PRELOAD_* register/bit definitions used by the new drain logic.
src/target/esp32h21/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32h21/include/soc/cache_reg.h Adds AUTOLOAD_DONE/PRELOAD_DONE bit definitions for drain logic.
src/target/esp32h2/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32h2/include/soc/ext_mem_reg.h Adds EXTMEM preload/autoload DONE bits/register definitions for drain logic.
src/target/esp32c61/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32c61/include/soc/cache_reg.h Adds AUTOLOAD_DONE/PRELOAD_DONE definitions for drain logic.
src/target/esp32c6/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32c6/include/soc/ext_mem_reg.h Adds EXTMEM preload/autoload DONE bits/register definitions for drain logic.
src/target/esp32c5/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32c5/include/soc/cache_reg.h Adds AUTOLOAD_DONE/PRELOAD_DONE definitions for drain logic.
src/target/esp32c3/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze and drains autoload/preload before unfreeze.
src/target/esp32c3/include/soc/ext_mem_reg.h Adds ICACHE autoload/preload DONE definitions for drain logic.
src/target/esp32c2/src/cache.c Stop/start now uses ROM suspend/resume; adds freeze/unfreeze but skips autoload/preload drain.
src/target/common/src/cache.c Adds weak default implementations of freeze/unfreeze that fall back to stop/start.
src/target/base/include/target/cache.h Extends internal target cache API with freeze/unfreeze declarations.
src/mmu.c Uses cache freeze/unfreeze instead of stop/start during temporary MMU remaps.
src/cache.c Adds public wrappers stub_lib_cache_freeze/unfreeze().
include/esp-stub-lib/cache.h Adds public declarations/docs for stub_lib_cache_freeze/unfreeze().
example/stub_main.c Adds simple smoke calls for the new cache freeze/unfreeze API.

Comment thread src/target/esp32h4/src/cache.c
Comment thread src/target/esp32h21/src/cache.c
Comment thread src/target/esp32h2/src/cache.c
Comment thread src/target/esp32c61/src/cache.c
Comment thread src/target/esp32c6/src/cache.c
Comment thread src/target/esp32c5/src/cache.c
Comment thread src/target/esp32c3/src/cache.c
@sobuch

sobuch commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

seems like this can explain the random-looking issues we had with c5, thanks for figuring this out @erhankur !

Could you add a comment on when to use stop/start (suspend/resume) and when freeze/unfreeze instead?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated no new comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants