Repository navigation
iommu/apple-dart-apif: park a released device off its domain, so re-added devices don't freeze the machine - #841
Conversation
The driver provided neither a release_domain nor a translation change in release_device(), so a removed device left its SIDs enabled on the domain that the core frees next. When the same device came back, as the N1 Wi-Fi and Bluetooth functions do after a firmware reset removes and rescans them, its new domain was attached over that stale state, and the first DMA through it froze the machine. Provide a blocking release_domain. Its attach takes the released device's SIDs out of the domain it leaves the same way an attach unwind does: disable each SID, undo the domain's mappings on it and clear it from the domain. Retained SIDs keep their current handling. Developed with Claude Code. Signed-off-by: Erik Bourget <erik@ebourget.net>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approved on static review. The bare-metal M5 Pro uses the raw-MMIO apple-dart, not the APIF backend, so this path doesn't run on our rig.
Review:
release_attachtakes the prior domain's mutex, thenstreams_lockwith IRQs off, then each DART'sbatch_lock, the same order asattach_dev.- For each non-retained SID it disables the SID, undoes the domain's replayed mappings and clears the stream bit, as
attach_dev's unwind does. - Retained SIDs are left alone, and a failed DISABLE is logged without stopping the release.
Builds W=1-clean with APPLE_DART_APIF=y on a tree that merges this head. It also merges cleanly into current integration/aurora.
|
Retested before merging on the M5 Pro (J714sAP, bare metal, SSD boot), kernel 7.3.0-m5-merge: the M5's integration kernel with this round's rebased heads in place of the old ones (every PR's own patch identical to what is merged; logs in work/m5-pr-merge-20261109). CI green. Before merging, this round (these 14 PRs, #1323 and the rebased #1254/#1306/#938/#1316/#1199) was test-merged in order onto integration/aurora f9cf6f9 with no conflicts:
🤖 Generated with Claude Code |
|
Heads-up: shortly after this was merged, the owner asked for all APIF code (the old SPTM-support path: 🤖 Generated with Claude Code |
On T6050 (M5 Pro and M5 Max), removing a PCI device behind an APIF DART and adding it back can hard-freeze the machine at that device's first DMA.
apple-dart-apifprovides neither arelease_domainnor a translation change inrelease_device(), which only frees the master. The IOMMU core requires one of the two. Without either, a removed device leaves its SIDs enabled on the domain the core frees next:domain_freedoesn't touch the hardware for non-retained domains. When the same device comes back, its new domain is attached over that stale state.This adds a blocking
release_domain. Its attach takes the released device's SIDs out of the domain it's leaving, the same wayattach_dev's unwind path does:It takes the same locks in the same order as
attach_dev. Retained SIDs keep their current handling.Where it shows up
The N1 Wi-Fi/Bluetooth driver's firmware recovery removes the Wi-Fi and Bluetooth functions, resets the chip and rescans. Before this change, the first Wi-Fi DMA after the rescan froze the machine. That's about 250 ms after the Wi-Fi function's doorbell, once both IPC handshakes had already succeeded.
Testing (J716c, M5 Max)
This commit was run on the J716c daily kernel, together with the N1 recovery that removes and rescans the functions.
Checks: checkpatch
--strictis clean, anddrivers/iommu/apple-dart-apif.obuilds with W=1 and no warnings on this base.Created with Claude Opus 5.5 in Claude Code.