Repository navigation
ast10x0: lock the SCU after use with a nesting-safe unlock_and_lock_after - #666
Open
EnmanuelParache wants to merge 2 commits into
Open
EnmanuelParache wants to merge 2 commits into
EnmanuelParache wants to merge 2 commits into
Conversation
EnmanuelParache
marked this pull request as ready for review
November 5, 2026 18:43
EnmanuelParache
force-pushed
the
feat/scu_lock_after
branch
3 times, most recently
from
November 12, 2026 03:10
f04153b to
5a8e17e
Compare
…requires scu to be unlocked
unlock_and_lock_after now tracks a nesting depth so only the outermost call unlocks and re-locks the SCU. An inner call no longer re-locks the SCU under an enclosing closure. Now that the SCU is re-locked, writes that relied on it staying unlocked would be silently dropped, so: - gate/ungate_clock_mask, assert/deassert_reset_mask, apply_pinctrl_group and dcache_invd_all take the lock themselves. - The I3C reset/clock writes and the SGPIOM pin enable in spim_wiring go through ScuRegisters instead of raw PAC writes. - HACE only holds the SCU unlocked for its clock and reset writes. - pre_init re-locks the SCU after init_cache. Fix the unlock_and_lock_after documentation and the stale "call unlock_write_protection()" comments. Validated on the AST1060 EVB: 25/25 non-manual hardware tests pass (rebased on main). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
EnmanuelParache
force-pushed
the
feat/scu_lock_after
branch
from
November 18, 2026 18:36
5a8e17e to
5414c14
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
ScuRegisters::new_global_unlocked(), which left the SCU unlocked for the rest of runtime, withunlock_and_lock_after, which unlocks the SCU for the duration of a closure and re-locks it afterwards. Addresses #635.Changes
ScuRegisters::unlock_and_lock_after(|scu| ...)replacesnew_global_unlocked()and the inlineunlock_write_protection()calls.unlock_write_protectionis now private, so callers can't leave the SCU unlocked.set_spim_internal_muxinside the SPI transaction setup) locked the SCU under the enclosing closure and later writes were silently dropped.gate_clock_mask,ungate_clock_mask,assert_reset_mask,deassert_reset_mask,apply_pinctrl_groupanddcache_invd_all. Callers no longer need to remember to unlock first. These writes would otherwise silently fail now that the SCU is re-locked.ScuRegisters: the I3C per-bus reset and clock writes (i3c/registers.rs) and the SGPIOM pin enable inboard/src/spim_wiring.rs. The I3C ones were found by hardware testing (see below).pre_initre-locks the SCU afterinit_cache, so the SCU is no longer left unlocked from boot until the first later user. This closes the part of SCU left unlocked #635 that the first revision missed.main.tests/flashandtests/flash_service, added on main, were moved fromnew_global_unlocked()tonew_global().unlock_and_lock_afterdocumentation and example, and the stale "callunlock_write_protection()" comments inclock.rsandreset.rs.Testing
./pw presubmit: clippy, format, lockfile check and presubmit checks all pass.AST1060_EVB_PI_HOST=amd@rot-ast-ctrl,--config=k_ast1060_evb): 25 of 25 hardware tests pass with the test cache disabled, covering flash, GPIO, SGPIOM, HACE, I2C, I3C, OTP, SMC and SPI monitor.i3c/i3c_irqtimed out, because the I3C driver writes SCU reset and clock registers directly through the PAC and relied on the SCU staying unlocked. It passed on the pre-PR commit and passes again with the fix.mctp/server,spdm/auth(bothtimeout = "eternal"andmanual),spdm/vca(manual), andgpioj_loopback(manual, needs jumper wires).Not covered
peripherals/i2c/slave.rswrites SCUA54 and SCUA58 directly through the PAC. The I2C slave tests pass, so I left it alone, but it bypassesScuRegistersand should be checked.🤖 Generated with Claude Code