Repository navigation
thunderbolt: apple: avoid lock inversion during controller teardown - #51
Closed
DjDeveloperr wants to merge 1 commit into
Closed
DjDeveloperr wants to merge 1 commit into
DjDeveloperr wants to merge 1 commit into
Conversation
apple_cio_stop() holds pcie_tunnel_lock while destroying the NHI, whose domain removal acquires tb->lock and drains hotplug work. A concurrent unplug worker can hold tb->lock and wait for pcie_tunnel_lock through apple_nhi_pci_tunnel_deactivate(), creating an ABBA deadlock. Gate PCIe activation under pcie_tunnel_lock, drain pending activation work without that lock, and drop the lock before removing the NHI. Keep PCIe quiesce and final depopulation serialized. Reset the gate before bringing up the next NHI so a later cable attachment can activate normally. The gate also prevents a post-activation callback from requeueing the worker after shutdown has drained it. Normal tunnel bandwidth and workqueue concurrency are unchanged.
RyanTheTide
added a commit
that referenced
this pull request
Oct 8, 2026
…adlock thunderbolt: apple: avoid lock inversion during controller teardown Original contributor commits are preserved. Conflict resolutions retain the audited shared driver APIs and their integrated review fixes. Contributor credit; Signed-off-by outstanding: - 8153565: Dj <[email protected]> - 3075f55: DjDeveloperr <[email protected]> - a9aa605: DjDeveloperr <[email protected]> - 0cd936d: DjDeveloperr <[email protected]> - aff9d4e: DjDeveloperr <[email protected]> - a044eab: DjDeveloperr <[email protected]> - c5653cb: DjDeveloperr <[email protected]> - e9e52e6: Oliver Lukschander <[email protected]> - 0c16b38: Oliver Lukschander <[email protected]> - e83f46d: Oliver Lukschander <[email protected]> - 2b5254a: Oliver Lukschander <[email protected]> - cc895f2: Oliver Lukschander <[email protected]> - f8cec39: Oliver Lukschander <[email protected]> - 81eee7b: Oliver Lukschander <[email protected]> - 45c34d5: Oliver Lukschander <[email protected]> - 6f0468f: Oliver Lukschander <[email protected]> Ryan integrates these contributions under DCO (b); no author signature is forged. Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
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.
Summary
Fix a lock-order inversion between Apple USB4 controller shutdown and PCIe
tunnel hot-unplug handling. This is a single-commit follow-up to #46, targeting
fix/j414s-dual-dock-dp; retarget after that stack lands. It changes onlydrivers/thunderbolt/apple.c.Failure mechanism
Two paths take the same locks in opposite order:
If controller shutdown races a PCIe hot-unplug worker, both can wait forever.
The relevant call/lock ordering was checked in the source and in the binary
matching the loaded J414s driver.
The user reports hangs followed by resets when unplugging or powering off a
Winstars TB5 dock operating at TB4 speed, with a USB4 NVMe enclosure connected
to another controller. This defect is a plausible cause, not a confirmed
crash-time diagnosis: the recent journals end without a panic stack and
persistent crash storage is empty. The SSD's causal role is unknown.
Fix
pre-/post-activation callbacks.
pcie_tunnel_lock.controller start.
The gate prevents a late callback from queueing activation after shutdown
has drained the worker. No link-rate cap, bandwidth policy change, delay,
or reduction in normal transfer concurrency is introduced.
Validation
7.1.12-m2fix48configuration and verified live symbol providers..textbyte-identical to theinstalled driver, establishing a matching executable baseline.
against live kernel exports. No compiler diagnostics for the patched module.
and pass for the new unlocked removal, activation gate, and restart gate.
These are source-level checks, not hardware/concurrency tests.
checkpatch.pl --no-tree --no-signoffpasses with zero warnings/errors.tbstop1initramfs for the next boot, preserving theoriginal Image, initramfs, on-disk driver, and stage2. No runtime driver
reload, hotplug test, or reboot has been performed for this patch.
Hardware validation remains pending. In particular, verify dock removal
with the independent SSD active, dock reattachment, display/USB recovery,
and absence of hangs. This PR does not include the separate DPRX callback
reference leak, display bandwidth-allocation experiments, SEP, or AVD changes.