Skip to content

Boot chain: wait on hardware state instead of fixed delays, and fail closed on ignored errors - #479

Open
RyanTheTide wants to merge 41 commits into
mainfrom
prfix7/rtkit-stop-stack
Open

RyanTheTide wants to merge 41 commits into
mainfrom
prfix7/rtkit-stop-stack

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #441

Problem

Boot-chain fixes from a sweep for fixed waits, ignored errors and unnamed constants (first #368, then #416, then #441). Two review blockers from #441 were still open. rtkit_stop() treated CPU_STATUS.STOPPED alone as halted, which an idle IOP also reads. And after the rebase, the AOP fallback in dt_set_aop_firmware() could disable the node of an AOP that iBoot had already started, leaving it running from pages the OS treats as free.

Change

The same 29 commits on today's main (cec4a10), with no bot or unsigned commits, and these review fixes:

  • rtkit_stop() waits for STOPPED with IDLE clear (asc_cpu_halted()). An IOP still in its idle loop (STOPPED|IDLE, 0x22, RUN still set) gets the whole 1 ms window before the last drain, as before the series. "CPU not halted" is printed only for a CPU that is neither halted nor idle. This is folded into the rtkit commit (190da50).
  • dt_set_aop_firmware(): when the AOP's firmware segments cannot be reserved, the AOP's CPU_CONTROL.RUN is read first. A halted AOP is disabled as before. A running AOP, or one whose ASC cannot be read, refuses the handoff (40d0b3a). The AOP commit (c141a4c) is retitled and its text now covers what reaches this code on main: every AOP that is not a T8132 one, has segment-ranges and an unlocked DART, including T8112.
  • The J713/J604 comment sits above dt_set_t8132_aop() again.

The rest is unchanged. One-line summary of each commit:

  • rtkit: wait for the coprocessor's CPU to halt, not a fixed 1 ms
  • kboot: refuse a trial payload whose watchdog U-Boot would take over
  • kboot: disable the AOP when its firmware segments are not reserved; refuse the handoff when a running AOP's are not
  • sptm_virt: call AURA_TRAP_DELAY_NS a diagnostic
  • tps6598x: wait for the HPM firmware after a reset instead of fixed sleeps
  • usb: name the CDC schedule flags and the ATC USB2 PHY/PIPE fields
  • pcie: poll endpoint config readiness, PERST#/refclk timing from the ADT
  • pcie: stop the ANS power-off if a PHY clock does not drop
  • j873: poll for the eUSB2 PHY's UTMI clock
  • kboot: whole speaker amp group configuration or none
  • dptx-phy and dcp (T8152): fail closed on calibration, name the waits and IOReturn codes
  • tests/ci: fix the T6030 display host test and run the host tests that need no Mac files in CI

Testing

  • Host: full pytest (tests/python + T8122) 1091 passed, 27 skipped. New:
    • test_rtkit_stop.py runs the real rtkit_stop() on a fake ASC with 0x22 on the first read and a late message at 400 us, idle then halted, halted at once, and a CPU that never stops (4 cases). The first two fail on the old STOPPED-only check.
    • test_aop_segments_unreserved.py runs the real fallback: halted gives "fail" in place (or "disabled" without a status), running refuses, unknown CPU state refuses, a node that cannot be disabled refuses, and every unreserved-segment path goes through the CPU check (6 cases).
  • The 10 CI host scripts pass, including run-t6030-display.sh, which this series fixes. make format-check (clang-format 20.1.8) is clean. Stage 2 (RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1) and the default build both build with gcc. The Stage 2 is 3997696 bytes.
  • M1 Pro (T6000), aura-try Stage 2 one-shot of this head on the default kernel and command line. Enforcing, 0 failed units, 0 AVC denials, 0 kernel errors. AOP firmware segments reserved (the unlocked-DART path), and the AOP was ready with its four iio sensors as on production. s2idle 3/3. Restored afterwards.
  • The other lab rows in Boot chain: wait on hardware state instead of fixed delays, and fail closed on ignored errors #441 (M2, Neo, J616s) ran before the rebase. See Still to run.

Still to run

  • M2 (T8112): done, see Boot chain: wait on hardware state instead of fixed delays, and fail closed on ignored errors #479 (comment) (AOP segments reserved, AOP and 4 sensors bound, s2idle 3/3, 0 AVC/failed/kernel errors).
  • J616s (T6040) aura-try row on this head. It shows which AOP line ran (AOP firmware segments reserved or preserving firmware mappings in locked DART), the AOP bound and its sensors as on production, s2idle 3/3 on the J616s, and 0 AVC denials, 0 failed units, 0 new kernel errors.
  • Neo (J700) CDC transition, cold and warm, both cable orientations: tps6598x: application firmware ready N ms after reset with N > 0, then Gen1 enumeration. Someone has to be at the Mac to turn the cable.
  • Community rows for J813 (N1 PCIe), J775D (T6050 PCIe) and J873/J873g (USB2, USB-C display, HDMI).
  • The rtkit_stop and ANS power-off paths do not run on a normal boot of our lab Macs, so those boot rows show no regression rather than exercise them.
Review notes for this replacement
rtkit: wait for the coprocessor's CPU to halt, not a fixed 1 ms

Problem

rtkit_stop() clears RUN on a coprocessor that never acknowledged a power transition, then waits a fixed 1 ms before draining the mailbox. The ASC reports a halted CPU in CPU_STATUS (STOPPED with IDLE clear). An IOP waiting in its idle loop reads STOPPED|IDLE with RUN still set and can still send, so STOPPED alone is not enough.

Change

Poll for STOPPED with IDLE clear (asc_cpu_halted()) within the same 1 ms bound, now RTKIT_STOP_TIMEOUT_US, then drain. A CPU still idle at the bound got the whole window, as before. A CPU that is neither halted nor idle by then is reported with its status word. The caller's reset follows either way.

Testing

  • tests/python/test_rtkit_stop.py (4 cases, see above); tests/python/test_nvme_adoption.py passes.
Where this runs

Only the rare ANS sleep-timeout paths in nvme.c (M1-M3 shutdown after a sleep timeout, T8140 cold handoff). The worst case is still 1 ms. Status bits used: STOPPED bit 1, IDLE bit 5 (as asc_cpu_idle() reads them).

kboot: refuse a trial payload whose watchdog U-Boot would take over

Problem

On an aura-try trial, kboot marks the watchdog node u-boot,noautostart so U-Boot leaves the trial watchdog alone. If that property could not be set, kboot logged it and handed off anyway: U-Boot would take the watchdog over and feed it, and a trial that hangs in U-Boot would never reset back to the configured Stage 2.

Change

dt_set_trial_watchdog() returns an error when the property cannot be set, and kboot_prepare_dt() refuses the payload. The trial path then reboots into the configured Stage 2, as for any trial that cannot start its payload. Non-trial boots are unchanged.

Testing

  • Release build OK; clang-format clean; the kboot extraction tests pass.

Still to run

  • One aura-try trial on a lab Mac: the log still shows "U-Boot leaves the watchdog to the trial budget" and the trial boots.
Scope

Every chip, trial boots only, and only when the FDT write fails (e.g. no space left in the DT buffer).

kboot: disable a halted AOP whose firmware segments are not reserved, refuse a running one

Problem

dt_set_aop_firmware() reserves the DRAM segments the ADT lists for the AOP: external code and log on T6040/T6041, external code and data on T8112 27.2 firmware. It does this for every AOP that is not a T8132 one and whose DART is not locked. When that reservation failed, kboot logged it and left the AOP enabled, so those pages were free RAM to the OS.

Change

  • c141a4c: disable the AOP node instead, and refuse the handoff only if the node cannot be disabled.
  • 5f7cfcf: overwrite "okay" with "fail" in place when the DT is full.
  • 40d0b3a: before disabling, read the AOP's RUN bit. Disabling is only safe for an AOP the OS would start itself. A running AOP (iBoot started it) keeps using those pages whatever the tree says, so the handoff is refused; so is an AOP whose ASC cannot be read. A successful reservation is unchanged.

Testing

  • tests/python/test_aop_segments_unreserved.py (6 cases, see above).
Scope

Every non-T8132 AOP with ADT segment-ranges and an unlocked DART, and only when the reservation fails. Segments in the AOP's own SRAM are skipped on purpose and are not a failure. The T8132 path (dt_set_t8132_aop()) already refuses a running AOP.

sptm_virt: call AURA_TRAP_DELAY_NS a diagnostic

Problem

AURA_TRAP_DELAY_NS in sptm_virt_gl.c is described as "a workaround knob, not a fix". It is off by default, but nothing says what it is for or what it found, so it reads like a hidden fix.

Change

Comment and tool help text only: call it a diagnostic, record what the trap-delay bisection showed (only sysreg traps move the guest stall; the stall follows ISP power-up; hiding isp + dart-isp removes it), and point at the tracking issue (#342). The environment variable name is kept because existing run scripts use it. No behaviour change.

Testing

  • Release build OK; aura.bin unchanged in behaviour (default 0 delay).

Still to run

  • Nothing on hardware (comment-only). The knob is removed together with the real fix for the stall.
tps6598x: wait for the HPM firmware after a reset instead of fixed sleeps

Problem

On J700 the CDC transition resets HPM0 with Gaid and then sleeps a fixed 1000 ms. Gaid never completes like other commands: the controller resets (clearing CMD1) and boots its firmware. The fixed sleep is too long when the firmware is back quickly, and the code carries on even when it is not back. The debugusb path does the same with a fixed 20 ms.

Change

  • Add tps6598x_wait_ready() (with a host-testable core tps6598x_reset_wait_execute()): wait until CMD1 no longer reads Gaid (or the transport drops), then until MODE reads APP or APP1. On SPMI, wake the controller again after a transport error.
  • Bound: TPS6598X_RESET_READY_MS = 2000 (TI's reset-to-ready is 1000 ms, Linux TPS_SETUP_MS; Linux allows 2000 ms for its reset command). On timeout, log MODE and the elapsed time and fail the transition.
  • Use it after the CDC cold reset (replaces mdelay(1000)) and after the debugusb reset (replaces mdelay(20)).
  • MODE values and the !CMD reply become four-character tags.

Testing

  • 4 new host tests in tests/python/test_tps6598x_command.py; the existing tps/HPM/CDC tests pass (39 total). test_cdc_reconnect.py needs pyserial, not run.
  • Release build OK; clang-format clean.

Still to run

  • J700 CDC transition, cold and warm boot, both cable orientations, 3+ runs: record tps6598x: application firmware ready N ms after reset, Gen1 enumeration and the CDC ATC: lane= line.
  • Debug boot after a forced CMD1 error on one I2C Mac (M1/M2) and one SPMI Mac (M3+).
Detail

HPM0 is /arm-io/nub-spmi-a0/hpm0 (usbc,sn201202x,spmi). The wait runs in the same session as the Gaid write; SPMI register selection uses the 2 s budget so a stuck select cannot run past it. After success the session ends with the normal SPMI shutdown. The CDC path only runs on T8140 (J700) from the proxy window; the debugusb path runs on every SoC in debug/USE_DEBUG_USB builds, and only when the status check before LOCK fails.

usb: name the CDC schedule flags and the ATC USB2 PHY/PIPE fields

Problem

The CDC schedule flags, the recovery budget and the ATC USB2 PHY / PIPE register writes in the CDC paths were bare numbers.

Change

Name them: schedule flags and recovery budget in usb_cdc_state.h, and the ATC USB2 PHY and PIPE fields in a new src/usb_atc_regs.h (names as in Linux drivers/phy/apple/atc.c), used by the T6050, T8140 and T8152 paths. Values with no public name (lane mode, crossbar, PSD/AON/GATE power registers) stay raw. No functional change.

Testing

  • usb.o, usb_t8152.o and usb_cdc_atc.o disassemble identically before and after.
  • Release build OK; clang-format clean.

Still to run

  • Nothing on hardware (no code change).
pcie: poll endpoint config readiness, PERST#/refclk timing from the ADT

Problem

The J813 N1 and T6050 endpoint bring-ups slept bare 100 ms intervals and judged the endpoint by one config read. j813_n1.c also carried its own copy of the SMC function-reset release with the key hard-coded, a hard-coded PERST# pad and a fixed refclk time, all of which the ADT provides. Some comments named macOS driver internals.

Change

  • Release the N1 through smc_adt_function_reset() on pci-bridge0 (the 50 ms hold is named N1_RESET_SETTLE_MS, as on T6050).
  • Name the spec waits: PCIe CEM T_PVPERL (PCIE_CEM_T_PVPERL_MS) and PCIe Base 6.6.1 (taken from the bridge's ADT perst-to-config, spec value as the floor).
  • Replace the one-shot ID read with pcie_wait_config_ready(): polls past all-ones and Request Retry Status for up to 1.0 s (PCIE_RESET_READY_MS) and fails loudly.
  • Read PERST# and the refclk time from the ADT (function-perst, t-refclk-to-perst) through a shared pcie_adt_perst_gpio() moved from pcie_t6050.c into pcie.c.
  • Describe the steps in comments instead of naming macOS drivers.

Testing

  • Release build OK; clang-format clean.
  • ADT check (our own ADT dumps): the PERST# pad resolves to the old hard-coded address on J813; perst-to-config and t-refclk-to-perst are 100 on every apcie bridge in the J813, J873, J873s, J700 and J773s ADTs.

Still to run

  • J813 cold boot: j813-n1: link up ... endpoint 106b: and Wi-Fi in Linux.
  • J775D cold boot: port N up for ports 2, 3 and 0, plus one boot that adopts an already-up link.
  • Community rows requested for both (no lab J813/T6050).
What can change

On a healthy endpoint the register writes and delays are unchanged. New: if the J813 ADT lacks function-reset, function-perst or t-refclk-to-perst, N1 bring-up stops and the ECAM host is disabled (fail closed). A slow endpoint now gets up to 1 s to answer config space instead of being judged by one read. Remaining fixed waits without a known status bit are tracked in #344.

pcie: stop the ANS power-off if a PHY clock does not drop

Problem

The whole-block ANS power-off (post-M4 chips) cleared each PHY's clock requests and polled for the acks to drop, but ignored the poll results: if a clock never dropped, the ANS gates were cut anyway.

Change

Check both polls. On timeout, log the PHY control word and return -1 before any gate is touched; the caller reports "couldn't power ANS off".

Testing

  • Release build OK; clang-format clean.

Still to run

  • ANS power-cycle / chainload rows on the Neo (T8140) and J616s (T6040): pcie: Timeout dropping PHY never appears, NVMe comes up in U-Boot and Linux.
Scope

T8132, T8140, T6040, T6041 whole-block ANS power-off. Behaviour only changes when a clock ack does not drop within 50 ms; before, that case cut power with the PHY clock still running.

j873: poll for the eUSB2 PHY's UTMI clock

Problem

j873.c slept 1 ms after enabling the eUSB2 PHY and then checked the UTMI clock once.

Change

Poll the UTMI clock event counter within the same 1 ms bound and fail as before if it never runs; name the three other settle waits (EUSB2_POWER_SETTLE_MS, EUSB2_RESET_SETTLE_US, EUSB2_MODE_SETTLE_MS, tracked in #344).

Testing

  • Release build OK; clang-format clean.

Still to run

  • J873 (T8152) cold boot: both USB2 hosts reach host mode and enumerate a device. Community row requested.
kboot: whole speaker amp group configuration or none

Problem

kboot hands each speaker amp group's configuration (brownout prevention, DC blocker, per-amp speaker and sense slot rows) from the ADT to every amp of the group, and the file promises that the kernel gets either the whole group's configuration or none of it. A DT write that fails part way (no room left in the tree) broke that: the amps written before the failure kept the new properties and the rest did not, so the amps of one speaker group were set up differently.

Change

On a failed write, remove every one of these properties from all of the group's amps again (removing a property never needs room in the tree) and log it. A group written in full is unchanged; nothing here stops the boot, as before.

Testing

  • tests/run-kboot-audio.sh gains a sweep over the free space left in the tree (0..2048 bytes, step 16). Old code: 0 bytes free leaves a partial group (test fails). New code: each of 129 sizes gives the whole group (116) or none of it (13); all 28 scenarios pass.
  • Release build OK; clang-format clean.

Still to run

  • No behaviour change on a normal boot (the tree has room). aura-try rows on M1 Pro / M2 / J616s / Neo check kboot: audio: ... amp configuration for N amps is unchanged.
T8152 display: fail closed on calibration, name the waits

Problem

The T8152 HDMI PHY activation kept going after an impedance-calibration timeout and then programmed the termination from a register that holds no result until calibration completes. A missing PHY node silently skipped every tunable. The T8152 ATC and dptx-phy bring-up used bare delay literals (one duplicated), the DPTX port service 22 unnamed IOReturn literals, and some comments named another driver's internals.

Change

Still to run

  • J873g cold boot: USB-C (ATC3) display and HDMI second display modeset unchanged.
Host tests in CI

Nine tests/run-*.sh host tests were never run by CI; one (T6030 display) had stopped linking because kboot_atc.c gained libfdt address-cell and ADT compatible calls. Fixed the test, and run eight of them on the ubuntu-latest jobs (dtc + qemu-user installed; the start.S move gate on the LLVM job). run-smbios.sh needs a Mac's ADT/DTB and stays out.

Tracking issues for the waits that still lack a status bit: #342, #343, #344, #372.

rtkit_stop() clears RUN on an IOP that never acknowledged a power
transition, waited a fixed millisecond for messages still in flight,
and drained the mailbox.

The ASC reports a halted CPU in CPU_STATUS: STOPPED (bit 1) with IDLE
(bit 5) clear. STOPPED alone is not enough: an IOP waiting in its idle
loop reads STOPPED|IDLE (0x22) while RUN is still set, as
asc_cpu_idle() and the inherited-DCP check already treat it, and it
can still send its acknowledgement.

Poll for STOPPED with IDLE clear, with the same 1 ms bound named
RTKIT_STOP_TIMEOUT_US, then drain. A CPU that stays in its idle loop
gets the whole window, as before. A CPU that is neither halted nor
idle at the bound is reported with its status word. The caller's reset
follows either way, as before.

tests/python/test_rtkit_stop.py runs rtkit_stop() on a fake ASC: 0x22
on the first read with a late message, idle then halted, halted at
once, and a CPU that never stops.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
On an aura-try trial every aura stage arms the trial watchdog, and
kboot marks the watchdog node u-boot,noautostart so that U-Boot leaves
it alone; a U-Boot that waits forever then still resets into the
configured Stage 2. When that property could not be set, kboot logged
it and handed off anyway: U-Boot would take the watchdog over and feed
it, and a trial that hangs in U-Boot would never be reset, with nobody
at the Mac.

Fail closed instead: kboot_prepare_dt() refuses the payload, and the
trial path reboots into the configured Stage 2 as for any trial that
cannot start its payload. Non-trial boots are unchanged.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
dt_set_aop_firmware() reserves the DRAM segments the ADT lists for the
AOP (its external code and log on T6040/T6041, its external code and
data on T8112 27.2 firmware) for every AOP that is not a T8132 one and
whose DART is not locked. The OS maps those reservations in the AOP's
DART. When the reservation failed, kboot logged it and left the AOP
enabled: those pages, or the ones after a partial failure, were free
RAM to the OS, and the AOP would be started on code in pages the
kernel reuses.

Disable the AOP node instead, as the T8132 AOP handoff already does for
the same failure, and refuse the handoff only if the node cannot be
disabled. A successful reservation is unchanged. An AOP that is
already running when the reservation fails is handled by a later
commit.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The trap delay was described as a workaround knob. It is a default-off
bisection aid: sptm_virt_trap_delay_ns is 0 and only run_guest_sptm.py
writes it. Say so, and record what the bisection found since: only the
sysreg traps matter (t106-t110), SPTM's rare EL2 control writes alone
do not (t115), and the last guest writes before every stall power up
the camera ISP; with the ISP and its DART hidden the guest runs on
without a delay (t121, eb66562). The race itself stays open and is
tracked in its own issue.

No code change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The J700 CDC transition reset HPM0 with Gaid and then slept a fixed
second before talking to it again. Gaid never completes like other
commands: the controller resets, which clears CMD1, and then boots its
application firmware, which reports itself in the MODE register.

Wait on that instead. tps6598x_wait_ready() first sees CMD1 lose Gaid
(or the transport drop while the controller is in reset), so the old
firmware's MODE cannot pass as ready, then polls MODE until it reads
APP or APP1. Transport errors during the reset are expected; on SPMI
the controller is woken again before the next poll. The wait is
bounded by TPS6598X_RESET_READY_MS (2000 ms: TI's 1000 ms reset to
ready, Linux tipd TPS_SETUP_MS, inside the 2000 ms Linux allows the
reset command) and fails the transition, loudly, when the firmware does
not come back, instead of carrying on into a controller that is not
there.

Name the MODE values and the !CMD reply as four-character tags.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
When the port controller reports a failed command before the DebugUSB
LOCK, it is reset with Gaid and given 20 ms before LOCK. Gaid reboots
the controller's firmware, which TI allows up to 1000 ms; polling CMD1
for the reset to complete also fails as soon as the transport drops
during the reset.

Write Gaid without waiting for a reply and wait for the application
firmware with tps6598x_wait_ready(), as the CDC transition does, before
LOCK. The DebugUSB setup now fails, with the controller's MODE in the
log, when the firmware does not come back within
TPS6598X_RESET_READY_MS.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The CDC schedule flags were bare bits (BIT(0) lane swap, BIT(1) Gen1,
BIT(2) HPM cold reset) checked as 7u/2u masks, and the schedule window
and re-advertise budget were literals repeated in three places. Give
them names in usb_cdc_state.h and use them in usb_cdc.c, the state
machine and the Stage 1 proxy window. No change in behaviour.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T8140 CDC ATC path kept its own copy of the USB2 PHY and PIPE
handler offsets and wrote their bits as bare numbers, and the T8152 USB0
path used raw offsets for the USB2 PHY, the PIPE handler and the DWC3
core (0xc200, 0xc2c0, 0xc120, 0xc704). The T6050 path compared the PIPE
mux against 0x73/0x42/0x22.

Move the USB2 PHY, PIPE handler and USB2 event counter registers out of
usb.c into usb_atc_regs.h, named and laid out as in Linux
drivers/phy/apple/atc.c, add the per-generation MUX_CTRL field helpers,
and use them, and the existing DWC3 register names, in all three paths.
The PSD/AON power registers of the T8152 path have no public names and
stay as they are.

No functional change: usb.o, usb_t8152.o and usb_cdc_atc.o disassemble
identically before and after.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
j813_n1_reset() was a copy of smc_adt_function_reset() with the SMC key
and value of pci-bridge0's function-reset (pKW4 'gP13', 0x800000)
hard-coded. Use the helper on the bridge's ADT node instead, as the
T6050 and J873 N1 paths already do: same writes (level 0, then 1, 50 ms
each), but taken from the ADT, and a missing or non-SMC function-reset
now stops the bring-up instead of writing a key the board may not have.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The J813 N1 and T6050 GP bring-ups slept a bare 100 ms after the SMC
function-reset release and again after link-up, then read the
endpoint's ID once. Both waits are spec times, and the single read is
where a readiness poll belongs:

- After the function-reset release: PCIe CEM T_PVPERL, at least
  100 ms with the endpoint powered before PERST# is deasserted
  (PCIE_CEM_T_PVPERL_MS).
- After link-up: PCIe Base 6.6.1, at least 100 ms after link training
  before the first Configuration Request on a port faster than
  5 GT/s. Every apcie bridge in the ADT states this as perst-to-config
  (100 on J813, J873, J873s, J700, J773s); pcie_adt_perst_to_config_ms()
  takes the longer of it and the spec value.
- Then the endpoint has until 1.0 s after reset to complete config
  requests (Base 6.6.1). pcie_wait_config_ready() polls its vendor ID
  past all-ones and Request Retry Status for up to that long, and fails
  loudly if it never answers, instead of judging the endpoint by one
  early read.

No change to the time either path spends on a healthy endpoint.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
j813_n1.c drove PERST# through a hard-coded pad address (0x39a000300,
AP GPIO 192) and waited a fixed 1 ms for refclk-to-PERST#. pci-bridge0
gives both: function-perst = GPIO(0xc0) of /arm-io/gpio0 and
t-refclk-to-perst = 100 (us). pcie_t6050.c already resolved its pads
that way, inline.

Move that resolver to pcie.c as pcie_adt_perst_gpio() and use it from
both, and resolve J813's pad and refclk time before anything is
powered, so a board whose ADT lacks them stops cleanly. The 1 ms floor
both paths keep over the ADT's 100 us is named
APCIE_REFCLK_TO_PERST_MIN_US: it is what every bring-up has used, and
nothing shorter has been tried.

The J813 pad resolves to the same address (gpio0 0x18a000000 + arm-io
0x210000000 + 4 * 0xc0); no change in what is written.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
0bbd6f3 reworded two of j813_n1.c's comments; the file header and
five step comments still named macOS driver classes and methods, and
the T8142 ANS gate comment in pcie.c named the macOS driver. Say what
each step does instead. No code changes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
pcie_ans_power_off()'s whole-block path (post-M4 SoCs without a storage
gate table: T8132, T8140, T6040, T6041) drops each PHY's CLK1 and CLK0
requests and polls for the acknowledges to fall, but ignored the poll
result and powered the gates off regardless, the same way whether the
PHY let go of its clocks or not.

Check both polls. On a timeout, log the PHY control value and return
-1 before any gate is touched; nvme already treats a failed ANS
power-off as fatal for this boot ("stays down until a reboot") rather
than continuing on a half-stopped PHY.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
j873_usb_phy_host() slept 1 ms and then read the UTMI clock event
counter once to decide whether the PHY started. The counter is the
readiness signal: poll it for up to that same 1 ms and go on as soon
as it moves, failing as before if it never does.

The three remaining waits (10 ms power-up settle, 1 ms after the PHY
reset release, 5 ms before the mode switch) have no status bit we
know of; name them, with a pointer to the tracking issue, instead of
leaving bare numbers.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…fails part way

kboot_audio hands each SN012776 amp group's configuration (brownout
prevention, DC blocker, per-amp speaker and sense slot rows) to every
amp of the group, and documents that the kernel gets either the whole
group's configuration or none of it. That held for a group whose amps
could not be matched, but not for a DT write that failed part way (no
room left in the tree): the amps written before the failure kept the
new properties, the rest did not, and the amps of one speaker group
were set up differently.

On a failed write, remove every one of these properties from all of the
group's amps again (removing a property never needs room in the tree)
and say so. A group that is written in full is unchanged.

The host test gains a sweep over the free space left in the tree: with
the old code 0 bytes free leaves a partial group; now each of 129 sizes
gives either the whole group (116) or none of it (13).

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
kboot_atc.c now reads #address-cells/#size-cells through libfdt's
fdt_address_cells()/fdt_size_cells() and matches ADT compatibles with
adt_is_compatible(). The host test linked neither, so it no longer
built; nothing noticed because no CI job runs it.

Link libfdt's fdt_addresses.c and add an adt_is_compatible() stand-in
that matches any entry of the compatible list, as aura's ADT reader
does. All checks pass again with gcc and clang.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Eight tests/run-*.sh host tests (speaker amp configuration and
speaker ID, logo, payload profile, T6030 display facts, T8122 PMP,
full start and GPU diagnostics, and the M3 start.S move gate) were
never run by CI, and one of them had stopped building unnoticed.

Run them on the ubuntu-latest jobs, with dtc and qemu-user installed;
the start.S move gate runs on the LLVM job, which has clang and the
LLVM binutils. run-smbios.sh stays out: it needs a Mac's ADT and DTB.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T8152 HDMI phy activation logged an impedance calibration timeout and
then programmed the termination from 0x1c24 anyway, which holds no
calibration result until the completion bit is set. A missing phy node
likewise skipped every tunable and carried on.

Poll the completion bit with poll32() and a named 1 s bound (the old
loop's 100000 x 10 us), and return an error from both cases so
DPTX_APCALL_ACTIVATE reports kIOReturnError instead of training a link
on an uncalibrated phy.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The T8152 USB-C (ATC) and HDMI (dptx-phy) bring-up waits between control
steps with bare udelay()/mdelay() literals. None of these steps has a
known status bit; the ones that do (CFG status, crossbar acks, PSD, PLL
ack/lock, impedance calibration) are already polled.

Name each wait and say what it separates: ATC_STEP_DELAY_US for the
clamp/power/isolation/sleep steps, ATC_DPTX_DISABLE_SETTLE_US,
ATC_ALT_MODE_POLL_MS for the alternate-mode poll interval, and
ATC_ROUTE_SETTLE_MS and DPTX_T8152_POWER_SETTLE_MS, whose cause is not
known and which carry tracking references. The lane enable loop waited
twice in a row after the last step; that duplicate is dropped (2 us ->
1 us per lane). No other timing changes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The DPTX port service replies used 22 bare 0xe00002xx literals, only some
of them commented. Name the four codes after the public IOKit IOReturn.h
values and give apcall 26 an enum entry instead of a bare case label.
No functional change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Some comments in atc_phy.c and dptx_port_ep.c named another
driver's build, its internal tables and function names, and an
attribute field name. Describe what each step does instead. Comment
changes only.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…out helpers

test_pcie_sequence.py compiles src/pcie.c without its includes against
host stand-ins. pcie.c now names its reset waits in pcie.h and polls
config readiness with timeout_calculate()/timeout_expired(), so the
harness no longer built.

Take the PCIE_/APCIE_ defines from pcie.h itself (so they cannot drift)
and add max() and poll-counting timeout stand-ins.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
USB_CDC_FLAGS_ALL is too long to align with the flag definitions above
it, and clang-format 20 and 22 disagree about how to lay it out inside
that block. Give it its own comment and paragraph. No code change.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The config-readiness timeout message printed a u64 with %lx. On aura
u64 is unsigned long, but the PCIe sequence host test builds pcie.c
with the host's uint64_t, which is unsigned long long on macOS, and
-Werror=format stops it there. Cast the address to unsigned long. No
change on aura.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
qemu-user-static is only a virtual package on the current
ubuntu-latest image, so apt refused it. qemu-user ships the
qemu-aarch64 binary the start.S move gate looks for.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
tps6598x_reset_wait_execute() took any CMD1 value other than Gaid as the
reset having started, including !CMD, the controller's answer to a
command it refused. MODE then still reads APP from the firmware that never
reset, the wait returned 0, and the debugusb path went on to LOCK a
controller that was not reset. The old tps6598x_command() returned -1
there.

Return -1 when CMD1 reads !CMD. The host test answers Gaid with !CMD and
APP in MODE and expects -1 after the single CMD1 read.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
pcie_adt_perst_to_config_ms() raised the ADT bridge's perst-to-config to
the 100 ms minimum but passed any larger value through, straight into
mdelay() on the N1 and T6050 paths. A function completes configuration
requests within 1.0 s of a conventional reset (PCIe Base r6.0 6.6.1,
PCIE_RESET_READY_MS), so a longer value is bad data: use the bound and
say so in the log.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
When reserving the AOP's firmware segments or DAPF windows failed, the
loader grew the node's status to "disabled" and refused the whole boot
if that failed too. The reservation usually fails because the DT is
full, so growing the property is likely to fail the same way.

Overwrite "okay" in place with "fail" (same length, no new space; Linux
treats any status other than "okay" as unavailable), and grow the
property only when there is no "okay" to overwrite. The boot is refused
only if neither works. Both AOP paths (T8132 and the ADT-segment path)
share the helper.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
…reserved

dt_set_aop_firmware() reaches the segment reservation for every AOP
that is not a T8132 one, whose ADT lists firmware segments and whose
DART is not locked. When that reservation failed (or reserved only
some segments), it disabled the AOP node. That is safe only for an AOP
that has not been started: the OS would start it from those pages. An
AOP that iBoot already started runs from them now, and a disabled node
does not stop it, so the kernel would hand out pages the AOP still
uses.

Read the AOP's CPU_CONTROL.RUN first, as the T8132 path does. A halted
AOP is still disabled. A running one, or one whose ASC cannot be read,
refuses the handoff. A successful reservation is unchanged.

Also move the J713/J604 comment back above dt_set_t8132_aop(), which
it describes.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH, then merge at 8ca4213537a307059c0c02932dac6a7ca99d0c54

Blockers: GCC, Fedora and Nix checks are failing at this head. Show a green current-head run or link the same failures at the base and the prerequisite fix. An M1 Pro smoke row does not exercise the conflict-resolved T8142 endpoint reset and link path. Please post targeted T8142 boot/radio evidence for the resolved file.

Checked: Compared both parents of the resolution. It retains main's endpoint lookup and early failure handling while preserving the branch's timing change. The follow-up removes the duplicate host link input/stub and moves the AOP helper out of the runner's extraction interval without changing the helper body. This is a resolution review. The independent PR-wide gate still applies to the rest of the stack.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: HOLD at 8ca4213537a3

Blockers: Required CI and the targeted T8142 endpoint-reset and radio evidence from the prior review. Owner disposition remains needed for Stage 1.

Checked: The exact CI merge parent also fails GCC, Fedora and Nix. Fedora and Nix match the parent at 4,008 B and 3,152 B of Stage 1 release headroom, respectively. GCC secure headroom also matches. GCC release fails to link at this PR while the parent produces a below-floor measurement, so the parent failure alone does not explain the additional PR release-link failure.

Evidence

PR run 45950467960 built merge 8478547 with first parent 26c1a85. The exact parent push run is 45941698202. The prior resolution review at this head remains in place.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Stage 1 disposition: use hardware state for the readiness checks and keep the failure paths safe. If a live coprocessor cannot be handed off, reserve its pages or refuse the handoff before Linux can allocate them. Measure against the #551 baseline and fix the extra GCC release-link failure. Before landing, verify the authorized installed Stage 1 and exact T8142 endpoint-reset/radio and shared regression rows.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: HOLD at 21d28c03 — clean main forward-merge (MERGEABLE); awaiting queued CI (Stage 1 size / GCC link verification post-#551) and the targeted T8142 endpoint-reset and radio boot row.

Blockers:

  1. Queued CI at 21d28c03 (17 jobs, including GCC release link and Stage 1 headroom checks on current main) must complete green.
  2. Targeted T8142 boot/radio verification exercising the T8142 endpoint-reset and link path remains open from the prior 8ca42135 review (alongside Stage 1 owner disposition).

Checked: Clean main forward-merge commit 21d28c03 (MERGEABLE, overlap only in src/kboot.c), queued CI status, and open blockers carried from 8ca42135.

Evidence
  • 21d28c03 brings prfix7/rtkit-stop-stack up to current main (MERGEABLE) with 17 CI jobs queued.
  • Note: merge commit 21d28c03 has no Signed-off-by: trailer; confirm policy CI passes on the merge commit.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 29, 2026
@RyanTheTide

RyanTheTide commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Status at 21d28c03, going through the review App's findings from 8ca42135:

  1. The GCC, Fedora and Nix Stage 1 jobs were red. Fixed by aura-raw.ld: one read-execute region on 16 KiB steps #551 plus the main merge. At 21d28c03, gcc, fedora, nix and ESP stage 2 vital size all pass. The only red jobs are the four Pytest jobs that main itself fails (fixed by tests: fix the two host tests that went red on main (types.h typedefs, adt_gpio link) #570) and readiness. Once tests: fix the two host tests that went red on main (types.h typedefs, adt_gpio link) #570 lands, I'll update this branch with a merge commit and re-run CI.

  2. T8142 endpoint-reset and radio evidence. The lab has no T8142 (J813/J815), so this row can't be run here. Here is what changed in src/j813_n1.c against main:

    • The reset hold is a named constant (still 50 ms).
    • T_PVPERL uses PCIE_CEM_T_PVPERL_MS instead of a literal 100.
    • The refclk-to-PERST# delay now comes from the bridge's ADT t-refclk-to-perst, with APCIE_REFCLK_TO_PERST_MIN_US as a floor.
    • The perst-to-config delay comes from the ADT, and the code waits for config space to become readable (pcie_wait_config_ready()) instead of a fixed 100 ms.
    • The one new failure mode: a bridge without t-refclk-to-perst now refuses the link and leaves the N1 off. The boot still goes on, so this is not a safety case.

    Proposal: merge-then-fix. Once CI is green at the updated head, I'll file a known-gap issue for the exact-head J813/J815 radio row (with the j813-n1: link up line and a Wi-Fi scan) and ask an existing T8142 owner to run it.

  3. Stage 1 owner disposition. It was posted here on 11-29 at 12:08: readiness checks wait on hardware state, failure paths stay safe, and the release build is measured against the aura-raw.ld: one read-execute region on 16 KiB steps #551 baseline with its GCC link fixed. At this head the GCC release build links and its headroom is back above the floor.

@DjDeveloperr code-owner ping on the plan above. Please object here if the T8142 row has to come before the merge.

src/kboot.c: keep this branch's dt_disable_aop() (in-place "fail" on a full DT) and main's board-free dt_set_t8132_aop() comment from #418.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 29, 2026
Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: FINISH at bb2d013.

Checked: The kboot.c conflict resolution preserves dt_disable_aop and main's T8132 handoff contract. The #570 merge recreates cleanly. The existing Stage 1 owner disposition explicitly calls for authorized installed Stage 1 and exact T8142 endpoint-reset/radio and shared regression rows before landing. Please provide those receipts or a revised disposition from that owner, plus current hosted CI.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) and removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) labels Nov 29, 2026
Conflict resolutions (main's newer behaviour kept, this branch's intent
carried on top):

- src/dcp/dptx_port_ep.c: main's DPTX v2 behaviour as is (GET_DRIVE_SETTINGS,
  drive settings validation and echo, reply zeroing, T8103 link fault and
  tiled hint answers, unhandled-call log). This branch only named the raw
  IOReturn codes, so main's new returns use the same IORETURN_* names. No
  behaviour change against main.
- src/kboot.c: main's reset vector relay reservation stays, and the trial
  watchdog step keeps this branch's fail-closed check
  (dt_set_trial_watchdog() returns an error that stops the DT preparation
  instead of being ignored). The earlier AOP resolution is unchanged:
  dt_disable_aop() and main's board-free handoff contract.
- src/kboot_audio.c: main's amp family table (SN012776 and TAS5770L) as is.
  This branch's fix, that a group whose DT update fails part way has its
  properties removed from all of its amps, is ported onto the family
  structure: amp_group_clear() removes the family's properties and a failed
  lookup or write jumps to it instead of returning with a half-written group.
- src/uartproxy.c: main's T6040 DockChannel carrier branch kept; the T8140
  schedule call keeps this branch's named delay and flag constants.
- src/usb_cdc.c: main's USB2 full speed flag kept; the delay bounds use this
  branch's USB_CDC_SCHEDULE_MIN_MS/MAX_MS (1000/15000, same values).

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
The T6050 DPTX PHY harness needs the poll32() helper main's driver now
calls, and the T8132 AOP gate test expects dt_disable_aop()'s in-place
"fail" status instead of a rewritten "disabled" string.

Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row at head aafe8aa (code = 0596c0c; the head adds tests only): J616s M4 Pro (T6040), method-T Stage 1 chain, mode full: PASS. Stage 1 ring 1.0.0b17-g0596c0c6 + aura-trial, live ANS session handed on, Stage 2 g0596c0c6, Enforcing, 0 failed/AVC/kernel errors, DART 0, NVMe errors 0, AVE md5 = production, s2idle 3/3. Restored and verified.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 1, 2026
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Dec 1, 2026
@DjDeveloperr

Copy link
Copy Markdown
Contributor

Could you update aafe8aa0 to main dfe97a4b9783 or split the pieces already covered by main? The merge conflicts in PCIe, DPTX, kboot audio and its host test, and the CI workflow. The J616s boot shows no regression. It does not exercise the changed RTKit halt or ANS power-off refusal paths. Please keep those as explicit checks when the series is refreshed.

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

Labels

merge-conflict Conflicts with the base branch (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks required sections (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants