Repository navigation
PCI: apple: set the T8132 ports up again after a deep sleep (J773g wake reset) - #4176
Conversation
apple_dart_set_host_resumes() leaves a DART's restore after a deep sleep to the PCIe host that clocks it. A host that claimed one port's DART and then can't claim the next one's has to give the first one back, or nothing restores it: the DART's own resume skips it for good. Add the opposite call. Nothing uses it yet. Signed-off-by: DjDeveloperr <hey@djdev.me>
The managed radio's recovery has the T8132 port's reset values inside its own function. A host that sets its ports up itself after a deep sleep writes the same ones: move them out, in the same order and with the same values. No functional change. Signed-off-by: DjDeveloperr <hey@djdev.me>
A T8132 host without the managed radio contract, as the J773g's with its Wi-Fi/Bluetooth and Ethernet ports, has nothing that brings its ports back after a deep sleep. apple-sleep can stop them and knows about a host that owns them, but no host says so. The port DARTs, clocked by their ports, are then read by their own noirq resume without a clock: the J773g takes an SError in the resume of iommu@490000000, 15 ms into the wake, and resets. Take the ports over: save what only their registers hold in the noirq suspend, and in the noirq resume write the reset values, the loader's tunables and link limits, the clocks, the RID-to-SID and MSI routes, then the port's DART and the root port's config space, and train the link, each before anything that depends on it. The link's width and speed limits are the ones the loader left. apple-sleep learns about every port that is back, so that the next sleep stops only those. The host takes the ports over only once every port has what its recovery needs, and gives back what it claimed otherwise. A port that doesn't come back is lost until a restart: its endpoint goes back into reset, its functions are marked disconnected, its config space and interrupt stay closed, and the next sleeps neither save over the last good copy nor touch it. The other ports are not affected. Hosts with apple,managed-sids (J713, J715, J604) return from the new probe first and keep their own recovery. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J773g (Apple M4 Mac mini, Exact commits / DTB provenance on this boot (single J773g generation):
Verified results:
|
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J713 (MacBook Air 13" M4, T8132, firmware 27.2) exact-head row at Build: this head
The only failed unit, on both, is |
satchlj
left a comment
There was a problem hiding this comment.
Reviewed 40959794ea75:
- Shared
apple_pcie_t8132_port_regsmatches the previous 19 entries inpcie-apple-radio.cverbatim (offsets, values, order). apple_pcie_t8132_sleep_probe()cleanly gates ont8132_sleep && !managed_sids && !list_empty(&pcie->ports)with devres-grouped all-or-nothing rollback (includingapple_dart_clear_host_resumes()+device_link_remove()), leaving managed-radio T8132 boards and non-T8132 hosts untouched.apple_pcie_t8132_resume_noirq()sits ahead ofadopt_link, restores the port DART before releasingPERST#, handles refused sleeps cleanly, and isolates a failed port vialink_failedwithout clobbering saved state or other ports.apple-build,host-tests(includingt8132-apcie-sleep-tests.py),pr-text, andreadinessare green with 3/3 J773g deep-sleep verification at head.
|
Checked on the merge of
Rows at this head: J773g 3/3 deep, J713 boot + s2idle + 3/3 deep without a regression. The J713 row closes the "one J713 deep-sleep cycle" item under Not yet. Still not covered: Wi-Fi/Bluetooth working after a J773g wake, a J773g without The J773g's default stays s2idle after this merge: its PCIe sleep windows come with #4007, which lands last. |
#3809 is in main now, and #4176 added apple_dart_clear_host_resumes() and apple_dart_host_restart() to main. Both sides add the same apple_dart_clear_host_resumes(); keep one copy, and apple_dart_is_host_resumed() from this branch, in include/linux/soc/apple/dart.h and drivers/iommu/apple-dart.c. Signed-off-by: DjDeveloperr <hey@djdev.me>
What: The J773g (M4 Mac mini) resets on its first deep-sleep wake. Nothing sets its two APCIe ports up again, so the port DARTs' own resume reads them without a clock and takes an SError. The T8132 host without the managed radio now owns its ports across a deep sleep: it saves them in the noirq suspend and brings ports, DARTs and links back in the noirq resume. This is the driver half of the hooks #2763 added to
sleep.c.Tested: J773g (M4 Mac mini, 27.2) at
40959794: 3/3 deep sleeps, same boot, both ports and both port DARTs back after each, Ethernet link up at 1 Gb/s after each, no SError. Run as this head's driver change on the J773g test stack, see Evidence. Wi-Fi/Bluetooth were not driver-bound. Plus compile (W=1) and host tests.Risk: two-way · J773g (T8132 without
apple,managed-sids). The other T8132 Macs share one reset table with it, values unchanged.Not yet: the J773g's Wi-Fi/Bluetooth working after a wake (its test rootfs had no radio firmware, so only their config space was read); the J773g without
clkreq-gpios, as inmain's DT; one J713 deep-sleep cycle for the shared reset table; a wake on hardware where one port doesn't train.Details
The fault. On
mainthe wake gets 15 ms intodpm_resume_noirqand takesAsynchronous SError Interrupt(esr0xbe000000); the newest device callback is490000000.iommu, the radio port's DART.sleep.calready stops both ports before it lowers APCIe and hasapple_sleep_apcie_ports_owned()andapple_sleep_apcie_port_up()for a host that brings them back. No host called them.What the host does. Per port, in this order: PERST# asserted and CLKREQ# back to an input; the reset values; the loader's
apple,tunable-port; the port's clock and its two reference clock requests; ready; the clock gating it had before; the root port's tunables and link limits; RID-to-SID and MSI routes; the port's DART; the root port's config space; PERST# released; link training; interrupts. The DART is restored before anything behind the port can reach it.Where the values come from. The reset values are the ones the managed radio's recovery already writes (#3629), now shared instead of copied. The link's width and speed limits are the ones the loader programmed, read back in the suspend: the DT has neither
num-lanesnormax-link-speedfor these ports. Timeouts and delays are the existing ones of the same file,PCIE_T_PVPERL_MS,PCIE_RESET_CONFIG_WAIT_MS, and the 500 ms the managed radio's link gets.All ports or none. The probe first checks every port (PHY block, atomic PERST#, optional CLKREQ#, tunables), then claims the DARTs, then tells
apple-sleep. Any failure gives everything back and the host behaves as before. Giving a DART back needsapple_dart_clear_host_resumes(), the same helper #3809 adds (same text, so either order merges).A port that doesn't come back is lost until a restart: PERST# asserted, LTSSM stopped,
link_failedset, its functions marked disconnected, config space (also the root port's) and its interrupt closed.apple-sleepisn't told it's up, so the next sleep doesn't stop it. Later sleeps neither save over its last good copy nor touch it. It isn't retried: by then the functions' saved config space and their firmware are gone, so a retrained link would be no use to their drivers. The other ports come back normally.Other hosts. The new paths need
t8132_sleepin the host's data, which onlyapple,t8132-pciehas, and noapple,managed-sids. Every T8132 board includest8132-jxxx.dtsi, which sets that property, and onlyt8132-j773g.dtsdeletes it. J713, J715 and J604 leave the new probe at its first check.t8132_hwis otherwiset602x_hw, and nothing compares against the latter's address. The resume hook is keyed on a flag only the new suspend path sets, and comes before the adopted-link hosts' block; a host test checks that.With other changes
hib_*path fors2r_noirqhosts. Merges without conflicts, and neither path runs on the other's hosts.sleep.cthe shared clock and PHY windows ofpcie0, which it restores before any host resumes. Not needed to compile or probe this, but the J773g's deep sleep is run with it.main'st8132-j773g.dtshas noclkreq-gpios.Evidence
J773g, 27.2, kernel
7.3.0-j773g-ship1 #3: the J773g test stack (which also has #3809 and #4007) with exactly this head's change topcie-apple.candpcie-apple-radio.c, compared line by line. Without this change the same stack resets on its first wake.LnkStabefore, after 1, after 314e4:4434and14e4:5f72readable, no driver bound (no firmware on this rootfs)tg3: link up at 1000 Mb/s after each wakeapple,tunable-{port,rc,rc-gen3,rc-gen4},clkreq-gpiosBoot object resumes 0 -> 3,
suspend_stats3 success / 0 fail, sameboot_id, 0 SError/Call trace/BUG/WARNING.Host tests (
tools/asahi):t8132-apcie-sleep-tests.py, the production functions on two modelled ports: 3 good cycles; a refused sleep; either port failing at each of its five waits, followed by a second sleep; a DART that can't be restored; PERST# that can't be driven. Negative controls by hand, all caught: saving over the good copy, no PERST# on failure, nolink_failed, no DART restore, reporting a failed port as up, no reachable resume hook.radio-sleep-power(now reads the shared table),radio-sleep-snapshot,radio-sleep-fence,radio-pm,pcie-adopted-clkpm,pcie-apple-msi-slice,pciec-policy,dart-sleep-writer,dart-sleep-snapshot,dart-sleep-power,apple-dart-range,apple-dart-isp-host,apple-dart-dapf,apple-dart-attach-undo,apple-dart-tlb-stall: pass.Build:
pcie-apple.oW=1 clean (aarch64 gcc 16.2.0),apple-dart.oclean;sleep.ois not touched. A full Image of this change on the J773g's test stack links with every exported symbol of that kernel.The shared table's 19 entries were compared with the managed radio's old ones: same values, same order.
checkpatch.pl --strict: 0 errors on each commit; the driver commits 0/0/0, the test file 1 check and 3 warnings (its stub list macro, MAINTAINERS).