Skip to content

iommu/apple-dart: cio: release the clock protection of every removed port DART - #3962

Draft
themartiano wants to merge 1 commit into
aurora-silicon:mainfrom
themartiano:fix/apple-dart-cio-release
Draft

themartiano wants to merge 1 commit into
aurora-silicon:mainfrom
themartiano:fix/apple-dart-cio-release

Conversation

@themartiano

Copy link
Copy Markdown
Contributor

What: A wake sets the clock protection slice of each USB4 port DART again. apple_dart_cio_release() clears it before the port's ACIO drops the DART's power domain, but only on the J714s and J716c, picked by machine name. The J713's port DARTs have the same slices, set by the same apple_dart_cio_on(), and nothing clears them when the cable goes. The first unplug after a docked sleep then gates a guarded domain and the machine hangs. This drops the machine list: the DART's own apple,clock-protection property decides.

Overlaps #2441 (draft, open): it rewrites the same two machine-name lines in apple_dart_cio_atc_port() to a T6050 hardware check. This PR deletes that function, so the two conflict in apple-dart-cio.c, and #2441's hunk is no longer needed with this PR. #2441 alone would keep the release T6050-only, so the J713 would still hang. #2441's head already conflicts with main in six other files.

Tested: Host side at the head, on main 30c1870. KUnit apple-dart on arm64 QEMU with CONFIG_APPLE_DART_J713_DCP=y: 50/50, including the new apple_dart_test_cio_release. With main's apple-dart-cio.c under the same test, the new case fails (49/50). The suites CI picks, apple-dart and jpeg, pass as CI runs them (40/40 and 15/15), but CI's apple-dart.kunitconfig does not set CONFIG_APPLE_DART_J713_DCP, so it skips the new case together with the other J713 host DART cases. Host tests run-host-tests.py --only cio 5/5 and --only dart 24/24, the same as main. arm64 W=1 LLVM 20 build of drivers/iommu/: 0 warnings. checkpatch --strict: clean. Hardware, measured on an older tree, not at this head: J713 on 26.6.2, Thunderbolt display unplugged during a suspend (pm_test=platform): 5 of 5 hard hangs (no panic, watchdog reset) without a release; with the slices cleared (0x12 -> 0x2) it survived that, the same unplug in a real deep sleep, and an unplug after one. The two arms differ by more than this change; a no-fix A/B on one kernel was not run. This commit is in our 7.3.0 next4 test kernel (main ba12094 plus this and other open branches; the files it touches are the same on today's main). A row at this head is not yet run.

Risk: two-way · J713 (both USB4 ports). J714s and J716c: the same two DARTs as before, only the log text changes ("T6050:" becomes "CIO DART").

Other Macs: The release runs on every Mac when a DART is removed, but it returns at once for a DART without apple,clock-protection. On main that property is in exactly three trees. J713: the NHI and PCIe-C DARTs of both USB4 ports (slices 14, 15, 18, 19) are new here. Its DCP and display DARTs also have the property, but the driver cannot be unbound (suppress_bind_attrs) and nothing depopulates them, so they are never removed. J714s and J716c: only acio2_dart and apciec2_dart have it, the two the machine list already admitted, so nothing changes for them. No other tree has the property, so no other Mac runs the clearing. A Mac that gets slices in its tree later (the J715, for example) is covered without a code change.

Not yet: J713 rows at this head: an awake unplug before any sleep (both DARTs log nothing to clear); docked deep sleep, wake, unplug (PS_PROT slice 18/19 0x12 -> 0x2, machine stays up); unplug during a deep sleep; replug with display, USB and PCIe back. A J714s or J716c regression row (one docked sleep with an unplug after it).

Details
  • apple_dart_cio_atc_port() (machine names plus the parent's name or compatible) is deleted. apple_dart_cio_release() now runs for any DART with a clock-protection slice (dart->cio). Its place in apple_dart_remove() and the order (streams disabled and TLB flushed first, then the slice cleared, then the domain may go off) are unchanged.
  • The new KUnit case: a DART with no slice is left alone, one whose slice is off stays off, and one a wake turned on is cleared (0x12 -> 0x2). With main's machine check the case faults, as the test DART has no DT node, so it fails without this change.
  • Kept as its own PR, apart from thunderbolt: tb: stop waiting for a CIO peer that is gone #3959 and thunderbolt: tb: a router that leaves during the CIO wake is an unplug #3960 (the same dock-unplugged-in-sleep story, in tb-cio-sleep.c): this one stops a hang, those shorten a wait and handle a case not seen on hardware. They touch different files and each applies alone.
Evidence
  • Head 64e9420, parent 30c1870 (main). Cherry-picked from our branch without conflict; the files it touches are unchanged on main since ba12094, the base of the test kernel.
  • KUnit: tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/iommu/apple-dart.kunitconfig --kconfig_add CONFIG_APPLE_DART_J713_DCP=y 'apple-dart*' (clang 23.1.5): 50/50. The same with drivers/iommu/apple-dart-cio.c taken from main: apple_dart_test_cio_release fails, 49/50 (main's machine check faults on the test DART, which has no DT node).
  • scripts/ci/apple-kunit.py plan picks apple-dart jpeg; run: apple-dart 40/40, jpeg 15/15. That config leaves CONFIG_APPLE_DART_J713_DCP unset, so the new case is not in those 40.
  • tools/asahi/run-host-tests.py --only cio: 5/5 (atc-cio-sleep, cio-native, dart-cio-owner, dart-cio-power, tb-cio-sleep); --only dart: 24/24. Main: the same.
  • Build: make O=<dir> LLVM=/usr/lib/llvm20/bin/ ARCH=arm64 olddefconfig from our J713 test kernel's config (7.3.0-0.next3), then W=1 drivers/iommu/ (clang 20.1.8): 0 warnings; apple-dart.o built (it includes apple-dart-cio.c).
  • scripts/checkpatch.pl --strict -g main..HEAD: 0 errors, 0 warnings, 0 checks.
  • apple,clock-protection on main 30c1870: t6050-j714s-sleep-soc.dtsi (2 nodes), t6050-j716c-sleep-devices.dtsi (2), t8132-j713.dts (10: dcp_dart, disp0_dart, usb4_0/1_dart, usb4_0/1_pcie_dart, dcpext0/1_dart, dispext0/1_dart). No other tree.
  • T6050 sleep: select usb/phy/thunderbolt/pci/iommu/nvme handling by hardware, not board #2441 head 505912d: git merge-tree with this branch conflicts in apple-dart-cio.c (new) and in the six files where T6050 sleep: select usb/phy/thunderbolt/pci/iommu/nvme handling by hardware, not board #2441 already conflicts with main.

…port DART

A wake sets the clock protection slice of each USB4 port DART again.
apple_dart_cio_release() clears it before the port's ACIO drops the
DART's power domain, but only on the J714s and J716c. The J713's ports
have the same slices, set by the same apple_dart_cio_on(), and nothing
clears them when the cable goes.

Measured on an older tree without this release: a J713 hung hard in 5 of
5 runs (no panic, watchdog reset) when a Thunderbolt display was
unplugged during a suspend, right where ACIO removes its DARTs and drops
its domains. With the slices cleared there (0x12 -> 0x2) it survived
that, the same unplug in a real deep sleep, and an unplug after one.

Whether a DART has such a slice is what its apple,clock-protection
property says, so use that and drop the machine list. The driver cannot
be unbound, so the DARTs removed are the ones an ACIO host depopulates.
On the J713 that adds both ports' NHI and PCIe-C DARTs. On the J714s and
J716c only the two DARTs the list already admitted have the property. No
other device tree has it.

Signed-off-by: Eduardo <git@martiano.me>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant