Repository navigation
Conversation
apple_dart_attach_dev_paging_unguarded() programs each of a device's stream maps in turn. If the second one failed (a TLB invalidate that times out, a refused cold ANE stream), the first kept pointing at the new domain's page tables. Only a managed DART was undone. The IOMMU core does not revert the device whose attach failed, because it expects that device unchanged, and it may free the new domain right after. On a first attach there is no old domain at all. The DART could then walk freed page tables. On failure, put the old domain back on every stream map the attach touched: bypass for the identity domain, the old tables for a paging domain of this driver, and blocked translation otherwise (no old domain, the blocked domain, a DCP domain) or when restoring fails. The error path also took the device's streams back out of the domain's stream maps only when the first DART was managed. For any other DART the streams stayed, so the domain went on flushing them, and freeing it unmapped the firmware root of a locked stream the attach never reached. Take the streams out for every DART, except a locked stream the attach reached: the domain's tables may have been in its firmware root, so apple_dart_domain_free() must still invalidate it before freeing them. A managed DART is still quarantined and its streams removed, as before. Verified with host harnesses that compile the patched functions unchanged against mocks of the hardware helpers, under ASan and UBSan. The undo: 11 cases (first attach, identity, blocked, paging and DCP old domains, a failing restore, locked and managed DARTs, an early failure and a success) leave each stream on the old domain or blocked, never on the failed one, with runtime PM balanced; the unpatched function fails 7 of them. The stream maps: 7 cases (plain, locked reached, locked not reached, locked failing, managed, managed and locked) drop exactly the failed device's streams and keep another device's. The kernel object was not built here and no hardware was used. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
pci_reenable_device() calls the host bridge's enable_device() hook again without a disable in between. The PCI core does that at a resume, for drivers that use it, and after a bridge's resources are resized. apple_pcie_enable_device() then allocated a second RID-to-SID slot for the same requester ID, and apple_pcie_disable_device() releases only the first match. Each cycle leaked a slot until the table was full and the next enable failed with -ENOSPC. On a port whose table is indexed by SID, the second enable failed at once with -EBUSY, which fails the resume. Look up the function's own valid entry first and reuse its slot. Managed (J713 radio) admission is unchanged and still refuses a second enable. The slot of another function that shares the SID is not reused. Verified with a host harness that compiles the patched enable and disable hooks unchanged against mocks of the port registers, under ASan and UBSan: 21 enables of one function take one slot and one disable frees it, an indexed port re-enables without -EBUSY, two functions sharing a SID keep one slot each on an allocated table and the second is still refused on an indexed one, and managed admission still returns -EBUSY. The unpatched hooks leak a slot per re-enable and fail at the 17th. The kernel object was not built here and no hardware was used. Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
Several working code paths and log lines were labelled "TEST" from
T6050 bring-up: the T6050 path sleep quirk, the 10 ms notification
timeout under QUIRK_CIO_MACOS_FRAMES (called a "placeholder"), the
PS_PROT readout after a CIO DART wake, and the T6050 PCIe-C sleep
order. The labels suggest temporary code.
Describe what each one does instead, and print the PS_PROT readout with
dev_dbg() so it stays available through dynamic debug.
Remove the sv6t9 PCIe-C sleep diagnostics. They ran only on J714s
(of_machine_is_compatible("apple,j714s")) and printed, at info level on
every sleep, the power state of each function behind the tunnel and the
PME_Turn_Off register as macOS reads it. Keep the register read that
follows PME_Turn_Off, since it is part of the access order traced from
macOS; only the print goes.
The J714s/J716c retimer scan skip in retimer.c is left as it is. It is
not a diagnostic: it stops a scan that makes the host router firmware
time out three times per dock enumeration, so removing it changes
behaviour on those machines and needs a hardware run.
Not built or run here; the change touches comments, log output, and
code that only logs.
Signed-off-by: Alyx-ML <256263590+Alyx-ML@users.noreply.github.com>
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.
Part of the #2755 split. Draft until it has a run on a Mac (the last Evidence line says which). The
apple_dart_def_domain_type()hunk is dropped: the IOMMU core alreadyforces a DMA domain for untrusted devices.
Summary
Evidence
Host harnesses compile the patched functions unchanged against mocks of the hardware helpers
(ASan, UBSan):
domain.
locked reached, locked not reached, locked failing, managed, managed and locked). Only the
failed device's streams are dropped; another device's stay.
sleep on a J714s (where the diagnostics were removed).
The J714s/J716c retimer scan skip is left as it is. It changes what the driver does, not only
what it logs, so removing it needs a hardware run.
Merge Danger
Door: two-way
Blast Radius: IOMMU error paths
Only failed attaches change. Fewer log lines on J714s sleep.
Assisted-by: LLM (Claude:Opus 5.5)