Repository navigation
iommu/apple-dart: undo a paging attach that fails part way - #3227
DjDeveloperr wants to merge 5 commits into
Conversation
apple_dart_attach_dev_paging_unguarded() programs a device's stream maps one at a time. When one fails, for example on a TLB invalidate that times out after the new tables are installed, that stream map and the ones before it kept translating through the new domain's tables. Only a managed DART's streams were taken back out of the domain. The IOMMU core keeps a device whose attach failed on its old domain, and may free the new domain and its tables as soon as the attach returns. On failure, put each stream map the attach reached back on the old domain: bypass for the identity domain, the old tables for a paging domain of this driver. Block it when there is no old domain (a first attach), for the blocked or a DCP domain, and when putting the old domain back fails. Quarantine a managed DART. Take the device's streams out of the failed domain on every DART, except a locked stream the attach reached: apple_dart_domain_free() still has to unmap its firmware root before it frees the tables. tools/asahi/apple-dart-attach-undo-tests.py runs the production attach against a modelled DART, fails it at each stream map from every kind of old domain, and checks where each stream ends up; the previous code fails 11 of its 14 cases. The same undo was first proposed in #2991, together with other changes. Signed-off-by: DjDeveloperr <[email protected]>
|
Verdict at Blockers: none Checked
Evidence
|
|
J773g (M4 Mac mini) at How it was run: two guarded one-shots on the same Mac and boot chain, 7 minutes apart.
The USB device is a SanDisk Cruzer Blade, the only non-hub USB device on this Mac. Plug-out/plug-in is a software re-enumeration ( Both boots returned to the stock kernel, and the kits were removed from the Mac. |
|
J700 (MacBook Neo, second generation for the shared DART code) at
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 6d99e00e
Blockers:
host-testsCI failsapple/bcm4377-radio-sids(tools/asahi/apple-bcm4377-radio-sids.py):apple_dart_attach_dev_paging_unguarded()now callsapple_dart_attach_paging_undo()andapple_dart_attach_paging_drop_streams(), which that host test does not extract/stub, causing-Werror=implicit-function-declaration. Updatetools/asahi/apple-bcm4377-radio-sids.pyto include/stub the new helpers and verifyhost-testspasses cleanly.- Rerun the 18 cancelled CI checks once fixed.
Checked:
drivers/iommu/apple-dart.c: paging attach rollback logic (reachedtracking before touching each stream map, restoring previous domain or blocking on failure, dropping failed domain stream membership) is sound.- Verified exact-head (
6d99e00e825d) hardware rows on J773g (M4 mini) and J700 (Neo, including USB).
Evidence
host-testsCI log (run45797470485):FAIL apple/bcm4377-radio-sids:error: implicit declaration of function 'apple_dart_attach_paging_undo'and'apple_dart_attach_paging_drop_streams'.
apple_dart_attach_dev_paging_unguarded() now calls apple_dart_attach_paging_undo() and apple_dart_attach_paging_drop_streams(), which the harness did not extract, so host-tests failed with an implicit function declaration. Add both to the definition list, with the iommu_domain ops/type and apple_dart_domain finalized stub fields the undo helper reads. Signed-off-by: Ryan Murray <[email protected]>
|
Pushed d29e548: host-tests failed because bcm4377-radio-sids.py extracts apple_dart_attach_dev_paging_unguarded() without the two new helpers. The definition list now also extracts apple_dart_attach_paging_undo() and apple_dart_attach_paging_drop_streams(), and the harness stubs gain the iommu_domain ops/type and apple_dart_domain finalized fields the undo helper reads. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at d29e5482.
Blockers:
- Merge conflict with
main(mergeable: CONFLICTING,mergeStateStatus: DIRTY): Because the branch conflicts withmain, GitHub cannot create the merge ref and none of thepull_requestCI workflows (host-tests,apple-build, KUnit) have been triggered atd29e5482. Mergemaininto the branch (normal merge commit, no force push) so it isMERGEABLEand CI runs green.
Checked: Full 4-file diff (drivers/iommu/apple-dart.c, tools/asahi/apple-dart-attach-undo-tests.py, tools/asahi/run-host-tests.py, tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py), delta commit d29e548257, Signed-off-by lines on both commits, and live mergeability/CI status.
Evidence
- Prior
bcm4377-radio-sidsblocker resolved (d29e548257):tools/testing/selftests/drivers/apple/bcm4377-radio-sids.pynow extractsstatic void apple_dart_attach_paging_undo(andstatic void apple_dart_attach_paging_drop_streams(, and addsconst void *ops; int type;tostruct iommu_domainandbool finalized;tostruct apple_dart_domain(matching the fields read byapple_dart_attach_paging_undo()).drivers/iommu/apple-dart.cis untouched relative to6d99e00e(which already carries J773g and J700 PASS hardware rows); localapple/bcm4377-radio-sidsand18/18DART host tests are reported passing.
- Live GitHub state at
d29e5482:mergeable: CONFLICTING,mergeStateStatus: DIRTY, onlyreadiness / readiness (QUEUED)present — nohost-testsor build workflows triggered untilmainis merged in.
Resolve apple-dart.c: keep the attach undo helpers next to main's apple_dart_cfg_pm_get()/put(), and on a failed attach run the undo and drop the streams (which covers main's managed-DART stream removal) before apple_dart_cfg_pm_put(). The radio-sids harness extracts all four helpers; apple-dart-attach-undo-tests.py extracts the PM helpers too, as optional for older revisions. Signed-off-by: Ryan Murray <[email protected]>
|
Pushed 99b2c50, a forward merge of main (1957bb7) into this branch. No force push. |
There was a problem hiding this comment.
Verdict: HOLD — forward merge and attach-undo/PM integration clean, awaiting queued CI and exact-head attach smoke row at 99b2c50c0c27
Blockers:
- 19 CI checks at
99b2c50c0c27are still queued and must finish green. - Exact-head attach smoke row on J700 or J773g at
99b2c50c0c27remains open as noted on the PR (since the error path mergedapple_dart_cfg_pm_put()alongsideapple_dart_attach_paging_undo()/drop_streams()).
Checked:
- Forward merge
99b2c50c0c27ofmain(1957bb76) across all 4 files (MERGEABLEonmain):drivers/iommu/apple-dart.c:apple_dart_attach_dev_paging_unguarded()tracksreached = i + 1per stream map, runsapple_dart_attach_paging_undo(domain, cfg, reached, old)and (ifstreams_added)apple_dart_attach_paging_drop_streams(dart_domain, cfg, reached)beforeapple_dart_cfg_pm_put(cfg)on error; managed DARTs are quarantined and dropped while reached locked non-managed streams remain tracked soapple_dart_domain_free()unmaps them before freeing tables.- Host test harnesses (
apple-bcm4377-radio-sids.pyandapple-dart-attach-undo-tests.py) updated to extract both the undo helpers andapple_dart_cfg_pm_get()/put(), passing24/24--only darthost tests and cleanW=1arm64apple-dart.obuild.
Evidence
- Verified
apple_dart_attach_paging_drop_streams()handles managed DART stream removal (supersedingmain's managed-onlyapple_dart_mod_streams(..., false)on error) while preserving locked non-managed stream tracking for safe teardown. - No code blockers found at
99b2c50c0c27.
|
99b2c50 J700 (MacBook Neo, T8140) PASS: combined guarded one-shot |
Signed-off-by: Ryan Murray <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
|
I merged current |
There was a problem hiding this comment.
Verdict: MERGE at 797ec253b1e9
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: Compared the PR patch before and after the forward merge. The file set and added and removed lines match the reviewed revision. Keep hosted checks and attach smoke on J700 or J773g for the paging rollback integration.
Follow-ups (not blocking): hosted checks; J700 or J773g attach smoke
What: When a paging attach failed after programming some of a device's DART stream maps (for example on a TLB invalidate that times out after the new tables are installed), those streams kept translating through the new domain's tables. The IOMMU core may free that domain as soon as the attach returns. Now every stream map the attach reached goes back to the old domain, or is blocked when there is no old domain to go back to. The device's streams also leave the failed domain on every DART.
Tested: The new host test
tools/asahi/apple-dart-attach-undo-tests.pypasses all 14 cases at6d99e00e825d;mainfails 11 of them, and the runner records that as a kill. All host tests that readapple-dart.cpass (18 DART runs plus the MTP and crashlog tests).apple-dart.obuilds with W=1 on 16K pages. J773g (M4 mini) row PASS at6d99e00e825d: the same 16 IOMMU groups and device-to-group map as base, USB deauthorize/authorize ×3 with reads, Wi-Fi, s2idle, 0 DART faults, and the same error-level lines as base (#3227 (comment)).Risk: two-way · every Mac, since the DART driver is shared; only the failure path of a paging attach changes.
Not yet: The second-generation row on J700 (Neo). The failure path itself is covered by the host test only.
Details
apple_dart_attach_dev_paging_unguarded()records how many stream maps it reached, the failing one included, becauseapple_dart_setup_translation()installs the tables before the invalidate that can fail.apple_dart_attach_paging_undo()handles each reached stream map:apple_dart_attach_dev_identitysets it (a retained-MTP stream, which identity leaves alone, is blocked instead);apple_dart_setup_translation();apple_dart_attach_dev_blockeddoes;apple_dart_domain_free()unmaps and invalidates it before it frees the tables.apple_dart_attach_paging_drop_streams()takes the device's streams out of the failed domain's stream maps on every DART, so the domain's invalidations and its free stop counting them. The exception is a locked stream the attach reached. Before, only a managed DART's streams were removed. Another device's streams in the domain stay.Evidence
python3 tools/asahi/apple-dart-attach-undo-tests.py:14 paging attach undo cases PASS.python3 tools/asahi/apple-dart-attach-undo-tests.py --ref 255761f1d55f: fails, among others, "first attach, only stream fails: stream map 0 is on the failed domain, expected blocked" and "from a paging domain: stream map 0 is on the failed domain, expected the old domain". It passes only the managed-failure, not-finalized and success cases.tools/asahi/run-host-tests.py --only dart: 18/18;--only j613-mtp-s2idle-testsand--only rtkit-crashlog-map-tests: pass../linux-build/build kernel … -- -j4 W=1 drivers/iommu/apple-dart.owithCONFIG_ARM64_16K_PAGES=y,CONFIG_APPLE_DART=y: no warnings.scripts/checkpatch.pl --strict: 0 errors; one warning about MAINTAINERS for the new test file, which other tools/asahi tests share.main255761f1d55f.