Skip to content

PCI: apple: radio: take the radio SIDs from apple,managed-sids and admit port 2 - #1962

Draft
IronsideXXVI wants to merge 5 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-pcie-radio-relink-sleep
Draft

IronsideXXVI wants to merge 5 commits into
aurora-silicon:mainfrom
IronsideXXVI:j604-pcie-radio-relink-sleep

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

What: The radio's managed sleep transaction now takes each function's SID from apple,managed-sids (T8132 hosts, 1 to 15 distinct SIDs) instead of a hard-coded 1 and 2. The host's other ports join the managed sleep with ordinary RID-to-SID routing. The J604 DT enables the SD card reader's port 2 and dart_apcie2. The managed firmware suspend itself stays J713-only, so on the J604 port 2 comes up at boot and its sleep path stays dormant until a J604 deep-sleep row exists.

Tested: No J604 or J713 hardware run on this revision (de49b80). Checked on top of integration/aurora 5b596e6: checkpatch --strict is clean on each commit, drivers/pci/controller/ and drivers/iommu/ build with W=1 (clang and gcc) with no warnings at the base, the first commit and the head, the Apple dtbs pass CHECK_DTBS with no new warnings, and every radio and bcm4377 host test passes.

Risk: two-way · the J713, the only host that registers the managed transaction (its SIDs now come from apple,managed-sids instead of the code), and the J604 (M4), where port 2 is now enabled at boot. On a host with only port 0, nothing changes.

Not yet: A J604 deep-sleep row on a unit kernel that lets the J604 through the gate: 10 firmware deep-sleep cycles with Wi-Fi, BT and SD read back after every wake. The gate stays as it is until that row passes. Also a J713 run on this revision.

Full description

Reworked after the second review. The J604 now describes the managed contract (apple,managed-sids, Bluetooth on SID 2), but the managed firmware suspend itself stays J713-only. No J604 deep-sleep row exists yet, so on the J604 the SD reader port added here comes up at boot, and its sleep path stays dormant until a row exists.

Five commits:

  • PCI: apple: radio: take the radio's SIDs from apple,managed-sids: the transaction takes each function's SID from apple,managed-sids in RID order, instead of having 1 and 2 written into the code. The probe accepts the property on a T8132 host with 1 to 15 distinct SIDs; it no longer requires <1 2> or checks the board list. apple_radio_register() keeps its apple,j713 gate (with a comment why), so the other T8132 boards still refuse a firmware suspend with -EBUSY. Every T8132 board in the tree presents <1 2> today, so nothing changes on real hardware.
  • tools/asahi: radio-sleep-snapshot-tests: follow the SIDs from apple,managed-sids: the host test's fixture follows the new field and checks SIDs other than 1 and 2.
  • PCI: apple: radio: admit the host's other ports into the managed sleep: the managed contract is per port (the port whose iommu-map DART carries apple,managed-sids). Other ports use ordinary RID-to-SID routing, and the transaction takes them down and brings them back after its own recovery, each DART behind its own port. The port bind is now lazy and all-or-none:
    • a port counts only after its device link and DART hook are both in place, and a partial bind is undone (device_link_remove(), the new apple_dart_clear_host_resumes(), put_device());
    • if a port's DART is not there yet (-EPROBE_DEFER), the radio stays bound and retries from a PM notifier at PM_SUSPEND_PREPARE, which runs before dpm_prepare(), so the device link still orders the sleep. While a port is still pending, prepare returns -EBUSY;
    • teardown unregisters the notifier and unbinds the ports.
  • arm64: dts: apple: t8132-j604: enable the SD card reader's port: port 2 and dart_apcie2 on, bus 2 mapped to SID 1 on dart_apcie2 (J604 ADT: pcie-sdreader under mapper-apcie2, reg 1). The radio's mapping is unchanged: <0x100 &dart_apcie0 1 2>, apple,managed-sids = <1 2>.
  • selftests: apple: bcm4377-radio-sids: follow the per-port managed flag: the test's fixture gets the port's managed flag that teardown now reads, and checks that a non-managed port of the same host (the SD reader's) masks its IRQ block on teardown.

Why managed on the J604: we found no hardware reason the managed transaction can't serve it. The J604's ADT maps Wi-Fi to SID 1 and Bluetooth to SID 2 on dart-apcie0, as the J713's does, with the SD reader on its own DART, and its radio is the same BCM4388 (14e4:4434, 14e4:5f72) the bind checks for. apple_t8132_managed_radio() still exists, but only for the radio's reg-on GPIO in gpio-macsmc and the DART's radio IRQ; it no longer decides which transaction runs.

Not run on the J604 yet. The next measurement is a J604 deep-sleep row on a unit kernel that lets the J604 through the gate: 10 firmware deep-sleep cycles with Wi-Fi, BT and SD read-back after every wake. Until that row passes, the gate stays as it is. One difference from boot that we see in the code: the transaction's port restore writes 0xffffffff at port offset 0x104, where aura writes 0xfffffff0 on T8132, and it does not zero 0x3000-0x303c as aura does. The J713 wakes with it; we'll compare on the J604 before calling it a problem.

The earlier unmanaged version (2 commits) stays on our fork as j604-pcie-radio-relink-sleep-unmanaged.

Checked on top of integration/aurora 5b596e6:

  • checkpatch --strict: 0 errors, 0 warnings, 0 checks on each commit;
  • drivers/pci/controller/ and drivers/iommu/ build with W=1, clang and gcc, with no warnings at the head, at the first commit and at the base;
  • the arm64 Apple dtbs pass CHECK_DTBS, with the same warnings at the base and at the head (none new, none on the PCIe nodes);
  • every radio and bcm4377 host test passes. The other host tests that failed here either fail the same way at the base or pass on rerun.

Not run: J604 or J713 hardware on this revision.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the draft, mainly to answer question 1 so the series can go one way or the other.

Question 1, managed or unmanaged. Aurora's J604 tree runs this host under the managed contract on purpose: t8132-apcie-port2.dtsi keeps port 2 and dart_apcie2 disabled "until it admits a second port and its stream". The direction our tree documents is therefore the managed transaction admitting port 2, not a second, unmanaged relink path next to it.

What stands in the way is that the managed transaction in pcie-apple-radio.c only runs for of_machine_is_compatible("apple,j713") with exactly SIDs 1 and 2. That's a board gate we wouldn't accept in new code either. Our preference would be:

  1. select the managed transaction by what the host node presents (apple,managed-sids, its ports and their DARTs), which gives the J604 deep sleep on the managed path;
  2. admit port 2 on top of that.

If you've found a hardware reason the managed transaction can't cover two ports, please write it up here, because that would change the answer. The same decision decides #1966 and #1998.

Question 2, the J713. Every T8132 board inherits apple,managed-sids from t8132-jxxx.dtsi, so nothing in our tree reaches the unmanaged branch today.

On the code itself, whichever way it goes: selecting by the host's own compatible (apple,t8132-pcie) is fine under our rules. Restoring each DART only once its own port is clocked again, matched by bus-range, is the right shape.

@IronsideXXVI
IronsideXXVI force-pushed the j604-pcie-radio-relink-sleep branch from 11b4286 to 758ded5 Compare November 21, 2026 01:27
@IronsideXXVI IronsideXXVI changed the title PCI: apple: bring an unmanaged T8132 host's ports and DARTs back after a deep sleep PCI: apple: radio: run the managed deep sleep on a T8132 host that presents it, then admit port 2 Nov 21, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks, that settles it: managed. Pushed 758ded5. The managed transaction now registers by what the host node presents (a T8132 host whose apple,managed-sids lists the radio's two functions, port 0 as its one port, and the MSI routing), takes the SIDs from apple,managed-sids instead of 1 and 2, and no longer checks for the J713. On the J713 nothing changes.

We found no hardware reason against the managed path. The J604's ADT has Wi-Fi on SID 1 and Bluetooth on SID 2 on dart-apcie0, with the same BCM4388, and what pushed us to unmanaged was all in our own device tree. Port 2 comes next on this branch, on top of it. The unmanaged version stays on our fork as j604-pcie-radio-relink-sleep-unmanaged. This hasn't run on the J604 yet; a deep sleep on the managed path is the next thing I measure.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Port 2 is on top now, head 1de6d08:

  • b2ea5ef fixes the host-tests failure on 758ded5. radio-sleep-snapshot-tests builds apple_radio_snapshot() against its own copy of the struct, and that copy had no sid[], so the test didn't compile. The fixture now has the field, plus a host whose apple,managed-sids is <3 5>: its admitted words pass, while a function routed to the other SID, or to a SID outside the list, fails.
  • 1a83ef6 decides the managed contract per port. A port is managed when the DART its bus maps to through the host's iommu-map carries apple,managed-sids. Any other port uses ordinary RID-to-SID routing in its own table. The radio transaction keeps port 0 and brings the other ports along:
    • Each other port's DART waits for the host after a wake (apple_dart_set_host_resumes()).
    • The port's interrupt is held with the radio port's, and its MSI and RID-to-SID routes are saved after the seal.
    • On a power-loss wake, once the radio's recovery is published, the port is brought up as probe does it, its routes are written and read back, and then its DART is restored.
    • A port that doesn't come back keeps its DART gated; the radio doesn't depend on it. On a host with only port 0, like the J713, nothing changes. The radio PM host test now checks that order.
  • 1de6d08 enables the J604's port 2 and dart_apcie2, and maps bus 2 as SID 1 on dart_apcie2 (from the J604 ADT: pcie-sdreader sits under mapper-apcie2, reg 1).

W=1 is clean, checkpatch --strict is clean, the J604 dtb passes CHECK_DTBS with nothing on these nodes, and the radio and PCIe host tests pass. None of this has run on the J604 yet; a deep sleep with the reader present is next. #1998 will rebase onto this.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

host-tests went red on 1de6d08 in apple/bcm4377-radio-sids: its fixture builds apple_pcie_port_teardown(), which now reads port->managed, and the fixture's port struct didn't have that field, so it didn't compile. The radio's mapping didn't change (<0x100 &dart_apcie0 1 2>, apple,managed-sids = <1 2> in the J604 dtb before and after), so I fixed the test: it marks the radio's port managed and adds a check that the SD reader's non-managed port masks its IRQ block on teardown. That's 915b146.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Blockers: 3.

  1. drivers/pci/controller/pcie-apple.c:5778 and :5781: the host probe still accepts apple,managed-sids only on the board list in apple_t8132_managed_radio() (include/linux/soc/apple/t8132.h, by machine compatible) and only when it is exactly <1 2>. So the transaction is still chosen by board and by fixed SIDs one layer up. The new s->sid[] path (pcie-apple-radio.c:922-923) and the <3 5> host-test fixture can never be reached on a real host. Drop the ids[0] != 1 || ids[1] != 2 check: apple_radio_bind() already checks each function's iommu-map SID against s->sid[] and the endpoints' IDs. Also decide the managed contract from the node's apple,managed-sids plus the bind checks, not from apple_t8132_managed_radio(). If the board list has to stay for now, say so in the commit message and drop the claim that the selection is by what the host presents.
  2. drivers/pci/controller/pcie-apple-radio.c:683 and :689: apple_radio_bind_ports() returns -EPROBE_DEFER when dart_apcie2 has no platform device yet or has not probed (apple_dart_set_host_resumes() with NULL drvdata). apple_radio_register() only logs it (:935) and never tries again. So with a probe order where the host binds before dart_apcie2, the J604 silently loses its firmware suspend for that boot: prepare returns -EBUSY. Propagate the deferral out of the host probe, or bind the other ports lazily at prepare time. On the same failure path, the DART is already marked host_resumes and the stateless device link from :690 is never removed (apple_radio_put_devices() at :832 only puts the device). Undo both when the bind fails and on teardown.
  3. pcie-apple-radio.c:914: removing the J713 check turns on the managed firmware suspend on every host that passes the probe gate: J715, J604, J623/J624 and J773g. Until now these refused a firmware suspend with -EBUSY. None of them has run the transaction, and the body lists open differences from the boot loader's sequence on T8132 (0x104 written as 0xffffffff vs 0xfffffff0, 0x3000-0x303c not zeroed). The J604 port 2 restore path (apple_radio_port_relink(), :765) has not run either. This needs a deep-sleep row on the J604 with port 2 up, and at least one desktop T8132, before the J713 check goes.

HW row: J604 on this head, default command line, SD card inserted: 10 firmware deep-sleep cycles; each wake logs "native radio power-loss recovery complete" and "dart ... restored after its host came back" for dart_apcie2, no "not back after the deep sleep"; Wi-Fi, BT and the SD card (read back a file) all work after every wake. Same 10 cycles on the J713 for no regression, and one boot plus 3 cycles on a J773g or J623/J624. 0 AVC, 0 failed units, no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

The managed radio transaction has the radio's functions on SIDs 1 and 2
written into the code, and the host probe accepts apple,managed-sids
only when it is exactly <1 2> and only on the boards that
apple_t8132_managed_radio() lists. So the SIDs are fixed one layer up,
and any other value can never reach the transaction.

Take the contract from the host node instead:
- the probe accepts apple,managed-sids on a T8132 host with 1 to 15
  distinct SIDs, whatever the board, and no longer requires <1 2>;
- the transaction takes each function's SID from apple,managed-sids, in
  RID order. The bind already checks them against the host's iommu-map
  and the endpoints' IDs, so a host whose node names other SIDs than its
  radio uses still fails the bind and refuses a firmware suspend.

The firmware suspend itself stays on the J713. It is the only T8132 host
that has run it; the other T8132 boards still refuse a firmware suspend
with -EBUSY until one of them has a deep-sleep row. Every T8132 board in
the tree presents <1 2> today, so nothing changes on real hardware.

Signed-off-by: Dylan Ironside <[email protected]>
…anaged-sids

The snapshot test compiles apple_radio_snapshot() from the driver
against its own struct apple_radio_sleep. The previous commit moved the
radio functions' SIDs into that struct (sid[], from the host's
apple,managed-sids), so the test no longer built and the host-tests job
failed on it.

Give the fixture the field, with SIDs 1 and 2 for the existing cases,
and add a host whose apple,managed-sids is <3 5>: its admitted words
pass, a function routed to the other admitted SID fails, and so does a
SID outside apple,managed-sids. The retained-link checks are unchanged.

Signed-off-by: Dylan Ironside <[email protected]>
The managed contract is the host's: every port of a host with
apple,managed-sids gets managed RID-to-SID admission, and the radio
transaction registers only on a host with a single port. The J604's
built-in host also has port 2, the SD card reader, behind a DART of its
own (dart-apcie2, which carries no apple,managed-sids), so the port
stays disabled and the reader with it.

Take the contract per port: a port is managed when the DART its bus
maps to through the host's iommu-map carries apple,managed-sids, as the
radio's does; any other port uses the ordinary RID-to-SID routing for
its own table. A port whose DART cannot be told stays managed.

The radio transaction keeps the host's one managed port, port 0, and
admits the others: each other port's DART waits for its host after a
wake (apple_dart_set_host_resumes(), linked to resume first), the port's
interrupt is held with the radio port's, and its link state, MSI and
RID-to-SID routes are saved once the transaction is sealed. On a
power-loss wake, after the radio's recovery is published, each port is
brought up as probe does it with those routes written back and read
back, then its DART is restored; a port that was down is only clocked
again, for its DART. A port that does not come back keeps its DART
gated and its interrupt off; the radio does not depend on it. A refused
or retained sleep only gives the interrupts back.

The other ports are admitted all or none. When another port's DART has
not probed yet as the host binds the radio, the radio stays bound and
the ports are admitted from a PM notifier at PM_SUSPEND_PREPARE, before
devices are prepared, so the device link orders that sleep; until then
prepare refuses a firmware suspend with -EBUSY. A failed admission, and
the radio's teardown, undo every admitted port: the device link is
removed, the DART's host_resumes is cleared through the new
apple_dart_clear_host_resumes(), and the reference is dropped.

On a host with only port 0, as on the J713, nothing changes. The
transaction still registers on the J713 only, so the port admission does
not run on a real host until another T8132 board is allowed the firmware
suspend. The radio PM host test checks the order: the other ports are
saved only after the seal, and restored only after the radio's recovery.

Signed-off-by: Dylan Ironside <[email protected]>
The built-in host now admits a port with ordinary routing next to the
managed radio port, so enable the J604's port 2 (the GL9755 SD card
reader) and its DART, and map the port's bus in the host's iommu-map:
the reader's stream is SID 1 on dart-apcie2 (ADT pcie-sdreader
iommu-parent mapper-apcie2, reg 1). dart-apcie2 carries no
apple,managed-sids, so the port uses ordinary RID-to-SID routing.

Update the port 2 include's note to say how a board uses it.

Signed-off-by: Dylan Ironside <[email protected]>
"PCI: apple: radio: admit the host's other ports into the managed
sleep" made apple_pcie_port_teardown() decide whether a port owns its
IRQ block from port->managed (its bus maps to the DART that carries
apple,managed-sids) instead of from the host's managed_sids. The test
builds that function into its fixture, whose struct apple_pcie_port has
no managed member, so the fixture no longer compiled:

  error: 'struct apple_pcie_port' has no member named 'managed'

The radio's SIDs are not what changed. The J604 device tree compiled
before and after "arm64: dts: apple: t8132-j604: enable the SD card
reader's port" maps the radio's bus the same way: iommu-map entry
<0x100 &dart_apcie0 1 2>, dart_apcie0 apple,managed-sids = <1 2>,
radio bus-range <1 1>. The only additions are <0x200 &dart_apcie2 1 1>
and port 2 with dart_apcie2 (no managed SIDs) enabled. So the test
follows the driver and the device tree stays as it is.

Give the fixture port the managed member and mark the radio's port
managed, so the busy-admission teardown is checked exactly as before:
no INTMSK write until a domain exists, one write after. Add the case
the new host has: another port of the same managed host whose DART
carries no managed SIDs (the SD reader's port 2) runs ordinary routing
and owns its IRQ block, so teardown masks it even before a domain
exists. With the old host-wide condition put back, that case fails.

The managed-SID admission, publication and quarantine checks of the
radio's SIDs 1 and 2 are unchanged.

Signed-off-by: Dylan Ironside <[email protected]>
@IronsideXXVI
IronsideXXVI force-pushed the j604-pcie-radio-relink-sleep branch from d5cd764 to de49b80 Compare November 21, 2026 16:56
@IronsideXXVI IronsideXXVI changed the title PCI: apple: radio: run the managed deep sleep on a T8132 host that presents it, then admit port 2 PCI: apple: radio: take the radio SIDs from apple,managed-sids and admit port 2 Nov 21, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks Ryan. All three are addressed in de49b80 (force-pushed, same five commits, reworked):

  1. Probe. The ids[0] != 1 || ids[1] != 2 check and the apple_t8132_managed_radio() check are both gone from the host probe. It now accepts apple,managed-sids on an apple,t8132-pcie host with 1 to 15 distinct SIDs, and apple_radio_bind() checks each function's iommu-map SID against s->sid[] and the endpoints, as you said. So the s->sid[] path and the <3 5> fixture can now be reached from the node. The board list is still there for two things that are not the transaction choice: the radio's reg-on GPIO in gpio-macsmc, and the radio IRQ in apple-dart. I reworded the commit message (now "take the radio's SIDs from apple,managed-sids") and the PR title and body, so none of them says the sleep is chosen by what the host presents anymore. That only becomes true once the J713 gate in 3 can go.

  2. Deferral and undo. The port bind is now all-or-none, and it can bind lazily:

    • __apple_radio_bind_ports() counts a port only once its device link and apple_dart_set_host_resumes() have both succeeded.
    • Any failure undoes what was done, in apple_radio_unbind_ports(): device_link_remove(), the new apple_dart_clear_host_resumes() (exported from apple-dart.c, with a stub in the header), then put_device().
    • On -EPROBE_DEFER the radio stays bound, ports_pending is set, and a PM notifier retries the bind at PM_SUSPEND_PREPARE. That runs before dpm_prepare(), so the device link still orders the sleep.
    • If the DART still isn't there, prepare returns -EBUSY, as before. The difference is that the bind is retried before every suspend, so a late dart_apcie2 only costs the suspends attempted before it probes, not the whole boot.
    • Teardown unregisters the notifier and unbinds the ports.

    I went with the lazy bind rather than deferring the host probe, because deferring the probe would hold up Wi-Fi and BT for the SD reader's DART.

  3. J713 gate. The of_machine_is_compatible("apple,j713") check in apple_radio_register() is back, with a comment saying why. The J715, J604, J623/J624 and J773g still refuse a firmware suspend with -EBUSY, as before. Your point stands: nothing but the J713 has run the transaction, and the port 2 restore has never run. The 0x104 / 0x3000-0x303c differences are also still open. On the J604 the series now brings port 2 up at boot, and its sleep path stays dormant until there is a row.

What I ran on de49b80 (on integration/aurora 5b596e6):

  • checkpatch --strict: 0/0/0 on each commit.
  • W=1 builds of drivers/pci/controller/ and drivers/iommu/, clang and gcc, at the head, at the first commit and at the base: no warnings.
  • CHECK_DTBS on the arm64 Apple dtbs: the same warnings at the base and at the head, none new.
  • Host tests: every radio and bcm4377 test passes, including bcm4377-radio-sids and radio-pm-tests. The other failures here either fail the same way at the base or pass on rerun.

Not run yet: any hardware on this revision. The J604 row you gave (10 deep-sleep cycles with the SD card in, both log lines for dart_apcie2, Wi-Fi/BT/SD read-back after every wake, 0 AVC, 0 failed units) is queued on our J604 with a unit kernel that lets the J604 through the gate. I'll post the result here. For the J713 10-cycle no-regression run and the J773g or J623/J624 boot plus 3 cycles, I'll ask in MacLab. Until those rows exist, the J713 check stays.

@RyanTheTide

Copy link
Copy Markdown
Contributor

None of this is on integration/aurora: the tip's host probe still accepts apple,managed-sids only on the board list and only as <1 2>. All five commits apply cleanly to 110861f. Head de49b80 reworks the three points from the last review and is waiting on a re-review. Still needed from hardware: the J604 row with port 2 up and an SD card inserted (deep-sleep cycles with Wi-Fi, Bluetooth and the card working after each wake), plus the J713 no-regression cycles.

Build check of 110861f plus this change (arm64, LLVM=1, Image, dtbs and every directory it touches, Fedora config plus asahi.config): builds, no warnings in the files it touches; CHECK_DTBS over every Apple DTB: no new warnings against the tip. Host tests (tools/asahi/run-host-tests.py --only) on 110861f plus this change: radio-pm-tests passes (1/1); radio-sleep-snapshot-tests passes (1/1).

@RyanTheTide

Copy link
Copy Markdown
Contributor

@IronsideXXVI checking open drafts today. To come out of draft, this still needs:

  • A test run at the current head on a Mac with the hardware it touches, then mark it ready for review.

If it's no longer needed, say so here and we'll close it. Otherwise it stays open as a draft until these are done.

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.

3 participants