Repository navigation
Conversation
…able The device tree binding says a port marked "external-facing" leads out of the machine, and drivers/pci/of.c sets external_facing on such a port. Since commit 3b96b89 ("PCI: Detect and trust built-in Thunderbolt chips") the PCI core reads that flag only through arch_pci_dev_is_removable(), which exists for x86 with ACPI. On arm64 it is a stub that returns false, so no device behind an Apple PCIe-C (USB4 tunnel) root port was ever marked untrusted or removable. Every such root port in the Apple device trees has external-facing. Because of that, a device plugged into a Thunderbolt or USB4 port got the same IOMMU treatment as internal hardware: whatever default domain the command line or Kconfig chose (identity with iommu.passthrough=1), lazy TLB flushing, and no bounce buffering of sub-page buffers. On T6050, whose PCIe-C DART is not read as a tunnel DART, the DART driver did not force translation either. Mark a device untrusted and removable when its upstream bridge is external-facing and the flag came from the device tree (the bridge has an of_node). Deeper devices inherit it, as before. The port itself stays internal, as it has been since commit 99b50be ("PCI: Treat "external-facing" devices themselves as internal"). ACPI systems are unchanged: their external_facing still goes through arch_pci_dev_is_removable(). With the mark in place the IOMMU core forces a strict DMA domain for these devices, refuses a driver that asks for identity, disables ATS, and dma-iommu bounces buffers that do not fill whole IOVA pages through swiotlb. Verified with a host harness that runs the patched set_pcie_untrusted() and pci_set_removable() on a modelled DT topology (external-facing root port, dock bridge, endpoint): both functions below the port are marked, the port and an internal Wi-Fi function are not, and an ACPI-style external_facing without a DT node is left alone. The unpatched code marks nothing. A script that mirrors the device tree checks found external-facing on every enabled PCIe-C root port in all 138 Apple board trees (80 tunnel references). The kernel was not built here and no hardware was used. Expected cost: strict TLB invalidation, and bounce copies for small, unaligned buffers of tunnelled devices (16 KiB IOVA granule). Dock throughput (network and NVMe) on M1, M2 and M4 Pro, before and after, is needed before this is merged. 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, as its own PCI-core patch. Draft: it needs dock numbers.
Summary
set_pcie_untrusted() / pci_set_removable() parent->external_facing via arch_pci_dev_is_removable() # ACPI only; a stub on arm64 + || (parent is external_facing && parent has an of_node) # DT "external-facing"The PCI core then gives tunnelled devices strict DMA domains, swiotlb bouncing for sub-granule
buffers, and no ATS. On ACPI systems nothing changes.
t6040-usb4.dtsialready has its tunnelnodes with
external-facing(the #2755 text said they arrived with #2069; that was wrong).Evidence
modelled DT topology marks nothing.
Wi-Fi function, or an ACPI-style flag without a DT node. A script finds
external-facingonevery enabled PCIe-C root port in all 138 Apple trees. Build: passed, Apple build and KUnit.
one M4 Pro.
Merge Danger
Door: two-way
Blast Radius: USB4/Thunderbolt devices
Every tunnelled PCIe device on every USB4 Mac gets strict IOMMU handling. The cost is the open
question.
Assisted-by: LLM (Claude:Opus 5.5)