Repository navigation
iommu/apple-dart: keep a retained DART across s2idle and restore translations if its reset fails (Neo Wi-Fi/BT lost after sleep) - #336
Conversation
apple_dart_resume() resets every DART on resume, clearing its page table pointers and disabling translation before restoring the saved values. That is only correct when the DART lost power. A DART whose power domain stayed on still has its state, and may still be translating for a consumer that kept running through the sleep: dwc3-apple keeps its core up across system sleep as a syscore device, which holds the shared power domain on, and with xHCI now left running in suspend-to-idle the controller can write events or touch its scratchpad while the DART is resumed. A DMA that hits the reset window faults, and xHCI halts on a Host System Error. Compare the translation registers with the values saved at suspend. When they still match and at least one page table is valid, the DART did not lose power: leave it alone and only invalidate its TLBs. Otherwise reset and restore it as before. A powered-off DART reads back with no valid page table, so it always takes the reset path. The TLBs are flushed with one command per stream rather than one command for a map of all streams. Where the streams of a map are remapped onto its first stream, a map flush only reaches that first stream, which would leave stale entries of every other stream behind. Two consequences beyond the USB case: - The suspend and resume callbacks are shared by runtime PM and system sleep. Every runtime resume of an unlocked DART whose power domain stayed on now also skips the reset and only invalidates the TLBs. This applies to all DARTs the driver handles, on other Apple SoCs as well, including the t8110 ones. - "Retained" is judged only by TCR and TTBR matching the values saved at suspend. On that path the error status and the stream enables are no longer reset; they are left as the DART kept them. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
The resume path only treats a DART as having kept its state when a stream has a valid page table. A stream of an identity domain bypasses the DART without one, for example with iommu.passthrough=1 or where the default domain type is identity. Such a DART reads back exactly as it was saved, its consumer may still be doing DMA, and it was reset all the same, which disables DMA on every stream before the saved state is restored. Count a stream whose TCR still holds the bypass setting of its generation as live as well, on DARTs that support bypass. A DART that lost power reads back with neither, so it still takes the reset path. This completes "iommu/apple-dart: Do not reset a DART that kept its state across sleep". Test it for a T8103 and a T8110 DART; both tests fail without this change. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
…ails apple_dart_resume() returns as soon as apple_dart_hw_reset() fails. By then the reset has disabled translation on every stream and cleared the page table pointers, so the DART is left without any translation and every DMA of its consumers faults until something resets it again. On the J700 this happened to the DART of the PCIe radio: "TLB command 0x1 for stream 0 timed out" on resume, after which the Bluetooth function could not restore its transport and Wi-Fi lost its DMA until a reboot. The reset can only fail in its last steps, after the translation registers are cleared: the unlock of a T8110 v2.2 or later DART that locks on errors, and the TLB flush. Move those steps, with the error acknowledgment and unmasking around the unlock, into apple_dart_hw_finish_reset(). It leaves the translation registers alone and reports the step that failed. On resume, write the saved page table pointers and translation controls back whatever the reset returned. They still describe the page tables in use, and this path is only taken when the DART did not keep its state, so its TLBs hold nothing from before the sleep. Then, if the reset failed, repeat all of its last steps once, not only the flush. When the unlock fails, the reset returns before it unmasks the error interrupt and flushes the TLBs, and a flush that completes later says nothing about either. If they fail again, resume returns the error. After a failed system resume the PM core leaves the DART runtime suspended, with the restored registers matching the saved ones, so its next runtime resume would take the path for a DART that kept its state and only flush the TLBs. Have that resume repeat the last steps of the reset instead. The tests cover an unlock that times out while the command engine is busy, followed by stream flushes that complete, through a KUnit stub of the unlock, and an unlock that never gets through. They size the fake register space for the T8110 layout, whose exception records start at 16 KiB, and put a guard page after it. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
|
GREEN on d9fc214 Review at exact head 4718d69, branch w73/move-pmgr-misc-debugfs, one commit on asl/aurora-edge 139dfe6. Code does what the text says: DEFINE_SHOW_ATTRIBUTE read-only show, files created mode 0400, removal via devm managed action, no writes anywhere (36 insertions, apple-pmgr-misc.c only, plus two includes). Init runs only on successful probe. State line honest: built with clang, never booted, draft. No internal names, paths, or tooling in the body. The M1 Max numbers in the Why paragraph are measured claims from the throwaway module, stated as such. No findings. |
|
CHANGES on d9fc214 RETRACTED — misfiled verdict. The GREEN above names head 4718d69 (a pmgr-misc debugfs move from another tree) and describes that change; this PR 336 is the DART s2idle work at head d9fc214, closed. My review was for w73's unopened move PR, not this PR, and I supplied the wrong number. This verdict is void here; my apologies to the participants — nothing in that review describes your change. |
After an s2idle cycle, the MacBook Neo can lose Wi-Fi and Bluetooth until reboot, on the default kernel. It happened on the night of 2026-10-16: about 1 in 17 five-minute sleeps.
Cause
pcie0_dart, iommu@390000000) shares the power domainps_apcie_gpwith the PCIe host. The Wi-Fi awake path deliberately keeps that domain powered through s2idle.apple_dart_resume()nevertheless always reset this DART (TCR=0, TTBRs cleared, TLB flush) while the MT7932 was still running.TLB command 0x1 for stream 0 timed out→Failed to reset DART on resume), resume returned before restoring TTBR/TCR, so SIDs 1-2 were left untranslated.-EIO).Commits
82494bf5c6b0iommu/apple-dart: Do not reset a DART that kept its state across sleep.39bc76211b30iommu/apple-dart: Keep a retained DART in bypass from being reset.d9fc21447419iommu/apple-dart: Restore the translations when the reset on resume fails.apple_dart_hw_finish_reset(): acknowledge errors, the T8110 v2.2+ unlock,ERROR_MASK = 0, flush) once, names the stage that failed, and returns that error.reset_incompleteflag makes the next runtime resume finish the tail too.Testing
pcie0_dartstate was identical on all 24 before/after snapshots.The failure is intermittent, so the efficacy evidence is the KUnit model of the timeout case. The hardware runs are the no-regression gate; the reset-failure path never fired on hardware during them.
🤖 Generated with Claude Code