Skip to content

T8140 camera after a DRAM-kept wake: restore the ISP DART at every power-up, as macOS does - #1393

Closed
DjDeveloperr wants to merge 2 commits into
fix/t8140-isp-sleep-macosfrom
fix/t8140-isp-dart-power-up
Closed

DjDeveloperr wants to merge 2 commits into
fix/t8140-isp-sleep-macosfrom
fix/t8140-isp-dart-power-up

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

The camera failed after every DRAM-kept (SLP_DDR) wake until the next deep sleep. The ISP firmware booted, its first command (PRINT_ENABLE) timed out, and dart-isp0 logged translation fault: SID:0 read fill region at 0x300704048. That address is the PMGR window in the first entry of the ISP DART's address filter (DAPF).

Cause: the ISP DART keeps Linux's TCR and TTBR through a DRAM-kept wake, so resume took the "state retained" path: a TLB flush only, no reset, no restore, and no DAPF write, because entry 0's range still read back. The filter only works again once it is written. After a deep wake the TTBR reads back changed, so resume did the full restore and the camera worked.

macOS does this in SPTM (sptm_t8110dart_powerup): at every power-up of the ISP DARTs it restores everything from its own copy without checking what survived: tunables, each stream's TCR and TTBR, a TLB invalidate, every DAPF entry (streams first, config word last), the error mask, the stream enables last.

Two commits on #1377:

  1. iommu: apple-dart: a DART marked apple,restore-on-power-up (dart-isp0 on T8140) always takes the full reset and restore at resume and rewrites its DAPF. Each DAPF entry's stream word is now written before its config word, as macOS does. Binding updated.
  2. media: apple: isp, soc: apple: sleep: drops t8140-sleep: take the deep path when an SLP_DDR wake would stall (camera ran, AOP crashed) #1358's rule that sent the sleep after an ISP start down the deep path, and apple_sleep_next_deep() with it. A wake that took the deep path now logs the deep path ran.

Tested on the J700 (Fedora 44 install, Fedora's kernel config plus the sleep symbols, kernel = #1374 + #1377 + this + the wake follow-ups PR, stage2-15, rig RAM boot):

  • 8 of 8 sleeps kept DRAM up, with the camera used right before 7 of them. After every wake the camera streamed 3 full frames (9.3 MB). There was no ISP failure and no DART fault in either boot.
  • Before this fix, on the same install: 3 of 3 rounds failed after a DRAM-kept wake, with the full restore forced (test_dart_full_resume) or with the tunable words written back, and with the same fault every time.

The static macOS analysis is in camera-dart-macos/README.md (the migration notes).

🤖 Generated with Claude Code

After a sleep that kept DRAM up, the camera failed to start until the next
deep sleep: the ISP firmware booted, its first command timed out, and the
ISP DART logged a fault on the firmware's read of 0x300704048, the PMGR
window of the first entry of its address filter (DAPF).

The ISP DART keeps Linux's values through such a wake, in which the sleep
engine runs the ISP through it. They read back as before the sleep, so
resume took the "state retained" path: a TLB flush, no reset, no restore,
and no DAPF write, since entry 0's range still matched. After a deep wake
its TTBR reads back as the engine's, so the same resume did the full reset
and restore, and the camera worked.

macOS's SPTM (its t8110dart powerup) restores the ISP's DARTs in full at
every power-up and never tests whether the values survived: tunables, then
each stream's TCR and TTBR, a TLB invalidate, every DAPF entry with its
streams before its config word, the error mask, and the stream enables last.

Do the same for a DART marked apple,restore-on-power-up: always take the
full reset and restore at resume, and write the DAPF back even where its
first range still reads back. Write each DAPF entry's stream word before its
config word, as macOS does, for every DART. Mark the ISP's first DART, the
one that keeps its state and holds the filter.

Signed-off-by: Diljit Singh <hey@djdev.me>
…rt again

The camera failed after a DRAM-kept (SLP_DDR) wake because Linux left the
ISP DART's address filter as the sleep had left it; the previous commit
restores the DART at every power-up as macOS does. So the sleep after an
ISP start no longer has to take the deep path, and the USB host's vote
for keeping DRAM up holds again whatever the camera did.

Drop apple_sleep_next_deep() and its readiness flag, which had no other
user.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Superseded by #1445 (merged as 2b05915); its changes are in integration/aurora. The ISP DART restore at power-up is apple_dart_dapf_replay() in drivers/iommu/apple-dart.c.

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.

1 participant