Repository navigation
iommu/apple-dart: drain TLB flushes and fault IRQs when display DART goes dark - #3307
Merged
Merged
Conversation
…goes dark When a display DART is marked display_dark before its power domain is lowered at runtime, a TLB flush that already passed the display_dark check or a shared fault IRQ handler can still reach DART MMIO after the domain powers off. Track active display TLB flush writers and dark-mode page-table sync writers under managed_lock, gate apple_dart_irq() on display_dark, drain in-flight writers, map TCR readers, and fault IRQs before returning from apple_dart_power_dark(..., true) and apple_dart_display_streams(..., false, ...), and drain dark writers while flushing any stale TLB updates before clearing display_dark or re-enabling streams. On a failed or incomplete reopen drain/flush, preserve display_dark and display_tlb_stale and return the error. Return an error from apple_dart_power_dark() and propagate errors from apple_dart_power_dark() and apple_dart_display_streams(..., true, ...) in all apple-dcp callers so power domains are never lowered after a drain failure and firmware is never restarted with stale DART state. Signed-off-by: Erik Bourget <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
…king Update the standalone C harness stubs in apple-dart-range-tests.py, dart-sleep-writer-tests.py, and bcm4377-radio-sids.py for the managed_lock, display_writers, and display_dark_writers fields used by apple_dart_domain_flush_tlb_range(). Signed-off-by: Erik Bourget <[email protected]>
…ay-dark-drain # Conflicts: # drivers/gpu/drm/apple/dcp.c
Contributor
|
Hardware verification row on J813 (M5 MacBook Air 13-inch, T8142,
|
DjDeveloperr
approved these changes
Nov 27, 2026
DjDeveloperr
left a comment
Contributor
There was a problem hiding this comment.
Review at 9dd8b87b003c: approve, 0 blockers. Rows on a second generation are still owed before merge (see below).
- TLB flush writers:
display_darkis set and thedisplay_writers/display_dark_writerscounts are taken under the samemanaged_lock. So every flush is either counted, and drained byapple_dart_display_dark_enter(), or takes the memory-only dark path and marks the TLB stale.- Every exit from the lit path drops
display_writers: the gate path, the runtime-PM failure and the normal end. The only earlycontinuecomes before the count.
- Dark exit:
apple_dart_display_dark_exit()clearsdisplay_darkonly once there are no dark writers and no stale flag. It invalidates and loops when a dark writer raced in, so a memory-only write is always followed by an invalidation before the streams come back. Streams are re-enabled only after it succeeds:- T8020 disables the target streams right after
apple_dart_hw_reset(); - T8110 enables only after a successful dark exit.
- T8020 disables the target streams right after
- Other readers:
apple_dart_irq()checksdisplay_darkbefore and afterpm_runtime_resume_and_get(), andsynchronize_irq()waits out a handler already past the check.- The
dart->lockround trip waits out a map path readingDART_TCR.
- Error propagation (
dcp.c):apple_dart_power_dark()/apple_dart_display_streams()failures now abort before the domains go down, sinces2r_domains_uponly drops after a successful dark.- They also stop firmware start after a failed reopen.
- D572's DART result is serialized with
s2r_activeunders2r_dart_lockand checked by every waiter.
- Checks:
checkpatch.pl --strict0/0/0 on both commits. They are signed off, with no attribution, and the branch merges cleanly onto currentmain.- CI: 21/21 checks pass.
- Behaviour change to note:
dcp_t6041_stop_one()no longer skips anext_deadexternal pipe. On its first sleep that pipe now has its RUN bit cleared and its DART streams stopped while its domains are still up (the stop step runs before the power words), andt6041_ext_seenkeeps it skipped afterwards. That reads as safe, but the PR text doesn't mention it, and the T6041 sleep path has no row. - Not blocking:
apple_dart_irq()returnsIRQ_NONEwhile dark. A level-triggered fault that is already pending at dark entry could count as unhandled on a shared line. The window is short, but worth keeping in mind if "nobody cared" ever shows up. - Hardware: sithglan's J813 (T8142) row ran #3308's head
944b0ba788d2, which has this head as an ancestor: idle power-off plus two deep sleep cycles, 0 DART faults. The J713 run in the body is a combined trial build ateab8b5157340. - Owed before merge:
- A row at this head on a second generation (T8132 or a T8020-DART M1/M2), since this is shared DART code.
- A T6041 sleep row for the
dcp_t6041_stop_one()change.
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.
What: Drain in-flight display DART TLB flush writers, map TCR readers, and shared fault IRQ handlers before lowering display power domains at runtime, preserve
display_darkanddisplay_tlb_staleif reopen drain or TLB invalidation fails, and propagate dark/stream errors across allapple-dcpcallers.Tested: Built
drivers/iommu/apple-dart.oanddrivers/gpu/drm/apple/dcp.o(ARCH=arm64 LLVM=1 W=1, 0 warnings), strictcheckpatch.pl(0 errors, 0 warnings, 0 checks),tools/asahi/backlight-coldboot-tests.py,tools/asahi/apple-dart-range-tests.py,tools/asahi/dart-sleep-writer-tests.py,tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py, andtools/testing/selftests/drivers/gpu/apple-dcp/run.pyhost suite PASS ateab8b5157340. Hardware-verified on J713 (M4 MacBook Air, macOS 27.2 firmware, default cmdline) in a combined trial build mergingj713-dcpext/air-dcpext-272(7a8022a6d24d) with #3297 (2b1bab104938), #3300 (6a84c1d95460), #3307 (eab8b5157340), and #3308 (05d728d91d68): clean DART dark enter/exit and stream stop/restore across idle power-off andpm_test=devicesdeep suspend/resume for both external DCPs (0 errors/warnings).Risk: two-way door · Macs using runtime display power-down or S2R DART transitions (T8020, T8140, T8142, T6041, and T8132 v27).
Not yet: Full hardware S2R wake cycle on J713 and verification on T8020 / T8140 / T8142 / T6041 Macs.
Details
When a display DART is marked
display_darkbefore its power domain is lowered at runtime, an in-flight TLB flush that already passed thedisplay_darkcheck or a shared fault IRQ handler can still reach DART MMIO after the domain powers off. Conversely, clearingdisplay_darkafter a failed or incomplete TLB flush or before T8020 stream disable/restore completes can reopen DMA with stale translations.display_writers) and dark-mode page-table sync writers (display_dark_writers) undermanaged_lockinapple_dart_domain_flush_tlb_range().apple_dart_irq()ondisplay_dark, serialize withdart->lockfor map TCR readers, and callsynchronize_irq()inapple_dart_display_dark_enter().apple_dart_display_dark_exit()and preservedisplay_darkanddisplay_tlb_staleon drain timeout or TLB invalidation failure; disable T8020 target streams immediately afterapple_dart_hw_reset()and enable streams only afterapple_dart_display_dark_exit()succeeds.intfromapple_dart_power_dark()and propagate errors fromapple_dart_power_dark(),apple_dart_display_streams(), and D572dcp_s2r_dart_power()(serialized unders2r_dart_lock) acrossdcp_s2r_domains_off(),dcp_s2r_ext_domains_off(),dcp_s2r_ext_start(),dcp_s2r_warm_restart(),dcp_s2r_display_on(),dcp_s2r_light_running(),dcp_s2r_prewarm_work(),dcp_t6041_ext_darts_dark(),dcp_t6041_stop_one(), anddcp_t6041_start_one().eab8b5157340updates host-test harness stubs (apple-dart-range-tests.py,dart-sleep-writer-tests.py,bcm4377-radio-sids.py) formanaged_lock,display_writers, anddisplay_dark_writers.Evidence
make O=build/j713 ARCH=arm64 LLVM=1 W=1 M=drivers/iommu apple-dart.o— 0 errors, 0 warningsmake O=build/j713 ARCH=arm64 LLVM=1 W=1 M=drivers/gpu/drm/apple dcp.o— 0 errors, 0 warningsscripts/checkpatch.pl --strict --no-tree— 0 errors, 0 warnings, 0 checksbacklight-coldboot-tests.py,apple-dart-range-tests.py,dart-sleep-writer-tests.py,bcm4377-radio-sids.py) — all PASSj713-dcpext/air-dcpext-2727a8022a6d24d+ pmdomain: apple-pmc: resolve display interfaces via consumer-switched power-domains #32972b1bab104938+ drm/apple: toggle display pipe PMC interfaces across S2R domain transitions #33006a84c1d95460+ iommu/apple-dart: drain TLB flushes and fault IRQs when display DART goes dark #3307eab8b5157340+ drm/apple: power off idle firmware-27 external display processors #330805d728d91d68):DCP 0x800000,display 0x10001) succeeded cleanly for both286e00000.dcpand48ae00000.dcpacross initial idle power-off (1 ms),pm_test=devicesdeep suspend/resume (1 ms idle-wake, refused-sleep power-cycle recovery0), and automatic post-resume re-gate (1 ms) with 0 errors/warnings.