Skip to content

PCI: apple: T6050: wait for the radio's port with a wait queue - #2377

Draft
RyanTheTide wants to merge 1 commit into
mainfrom
sweep/delays-dmp-pci
Draft

RyanTheTide wants to merge 1 commit into
mainfrom
sweep/delays-dmp-pci

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

After a sleep, a parked T6050 port comes back only once the radio's port is up again, because the shared PHY and the root complex come back with it. The radio's driver may be taking that port down and up once more for its warm reset. The unpark polled t6050_down 40 times with msleep(50) (pcie-apple.c:5276, from 851aa85 "PCI: apple: T6050: the N1's link over a firmware sleep, and the SD reader's port"). Both ends of that state are in this driver, so a sleep loop is not needed.

Change

  • A wait queue is woken where apple_pcie_t6050_sleep_up() clears t6050_down (link up), where it sets t6050_lost (port given up), and where apple_pcie_t6050_sleep_down() clears t6050_down after a refused shutdown. The unpark waits on it with the same 2 s bound. The parked port follows the radio's port as soon as it is back, and a lost port ends the wait at once.
  • The 150 ms from the endpoint's power to its PERST# work in apple_pcie_t6050_cold_up() stays. A comment now gives the reason: Tpvperl is at least 100 ms (PCIe CEM r5.0 2.9.2), and 150 ms is what the boot bring-up gives this port.
  • The T8140 bootstrap's post-response slot watch (checks = answered ? 2 : 10, from d15e15e) is unchanged. A comment now explains why it is sampled. The engine's completion (status interrupt, command bit, drained FIFO) is already waited for before it. The watch looks for a late write into retained memory, and no status bit or interrupt reports that absence.

Only hosts with a t6050_port (apple,t6050-pcie, the adopt_link host) run the changed wait. Every other apple-pcie host initialises the queue but never sets t6050_down, so T8103, T6000, T8112, T6040 and T8140 behave as before.

Testing

  • W=1 build of drivers/pci/controller/pcie-apple.o and pcie-apple-t8140-bootstrap.o with the release config: no new warnings compared with the base.

Still to run

  • T6050: s2idle with the SD reader port parked. Expected: after the wake, "port N: link up again after the sleep" and "its functions found again". "stays parked: the radio's port is not back" must not appear.
  • Neo, J616s, M1 Pro, M2 (no T6050 host): boot plus one s2idle. Expected: PCIe Wi-Fi is back after the wake, as before (ip link shows wlan up, dmesg shows no apple-pcie errors).
Code credit

Diljit Singh wrote the T6050 sleep path and the T8140 slot watch.

After a sleep, a parked T6050 port is brought back only once the radio's
port is up again, because the shared PHY and the root complex come back
with it. The radio's driver may be taking that port down and up once
more for its warm reset (apple_pcie_t6050_port_recycle()), so the unpark
polled t6050_down 40 times with msleep(50).

Both ends of that state are in this driver: apple_pcie_t6050_sleep_up()
clears t6050_down when the link is up and sets t6050_lost when it gives
the port up, and apple_pcie_t6050_sleep_down() clears it again when the
shutdown is refused. Wake a wait queue at each of those three points and
wait on it with the same 2 s bound. The parked port now follows the
radio's port as soon as it is back, instead of up to 50 ms later, and a
lost port ends the wait at once.

Comment the two delays left in that path: the 150 ms from the endpoint's
power to its PERST# work (Tpvperl, PCIe CEM r5.0 2.9.2, with the boot
bring-up's value), and the T8140 bootstrap's post-response slot watch,
which samples for a late write into retained memory, an absence that no
status bit or interrupt reports; the engine's completion is already
waited for before it.

Fixes: 851aa85 ("PCI: apple: T6050: the N1's link over a firmware sleep, and the SD reader's port")
Suggested-by: Diljit Singh <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Looks good; approve once the T6050 s2idle row is on this head.

I checked every writer of t6050_down/t6050_lost in drivers/pci/controller/pcie-apple.c. Each transition the waiter at :5286 cares about now wakes the queue: the refused shutdown (:5486-5487), link up (:5548-5549) and the port given up (:5566-5567). The only other writer sets t6050_down true (:5482), which the waiter doesn't need to see. The condition is re-checked under wait_event_timeout(), and the post-wait check at :5289 keeps the old fallthrough, so a missed wake still ends at the same 2 s bound as before. init_waitqueue_head() runs for every host at probe (:5816), and non-T6050 hosts never set t6050_down. The two comment-only hunks don't change code. The branch merges cleanly into the current integration/aurora.

This is a resume-path change, though, and nothing has run it. The rows under "Still to run" haven't been done.

HW row: a T6050 Mac on this head with the SD reader port parked over s2idle, 3 cycles: "link up again after the sleep" and "its functions found again" each time, no "stays parked: the radio's port is not back", and the SD card readable after each wake. Plus one s2idle on J616s or Neo with Wi-Fi back. 0 AVC, 0 failed units, no new apple-pcie errors.

Assisted-by: LLM (Claude:Opus 5.5)

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