Skip to content

serial: apple-dockchannel: stop idle console drain timer, back off RX, and add sleep PM - #3335

Merged
DjDeveloperr merged 2 commits into
mainfrom
fix/dcuart-idle-drain-timer
Dec 1, 2026
Merged

DjDeveloperr merged 2 commits into
mainfrom
fix/dcuart-idle-drain-timer

Conversation

@erikwb

@erikwb erikwb commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

What: Stop the continuous dcuart_drain_timer polling loop when an apple,sw-drain console has no open tty and no queued TX, back off open-and-idle RX polling exponentially from 10 ms to 100 ms, add system sleep PM hooks to apple-dockchannel-uart, and guard IRQ-less serial_core ports on wakeup suspend/resume and console reopen.
Tested: Live hardware at 5dde1e7a4ffb on J716c (T6050), J713 (T8132), and J616c (T6041, IRQ-backed apple,s5l-uart boot smoke), plus local build/KUnit and CI checks (hashes, commands, and A/B tables in Evidence):

  • J716c (T6050, apple,sw-drain console) at 5dde1e7a4ffb in batched 3545ebecb76f (3/3 blob-identical, default cmdline with console=ttyDC0): boots cleanly, 6-item smoke pass (0 failed user units, 0 LSM denials, 0 Oops/BUG/fault; aurora-peripherals.service warm-reboot baseline failure also on default/control; no timer-expiry trace on this boot). Earlier J716c runs at 5dde1e7a4ffb (3e4078f656d5 and same-machine A/B, default cmdline with console=ttyDC0) confirmed dcuart_drain_timer drops 62.3 -> 0.0/s when /dev/ttyDC0 is closed, restarts at 10.0 Hz on raw open, returns to 0.0/s on close, and cuts DPMS-OFF arch_timer -50.6% / tick_nohz -58.4% / IPI -60.7%.
  • J713 (T8132, IRQ-mode DockChannel without apple,sw-drain) at 5dde1e7a4ffb — two distinct rows:
    • Batched 76649338a1bc (3/3 blob-identical, default cmdline + panic=10 with console=tty0): IRQ-mode ttyDC0 registration on IRQ 53, dockchannel-hid ready, 8-item smoke pass (0 failed units, 0 AppArmor denials; 1 one-off brcmfmac ring line on 76649338a1bc, 0 times in the preceding 8 boots, no recurrence over 5× wlan0 down/up + 5× s2idle; attribution remains open).
    • Earlier batched 90de523e9ed9 (3/3 blob-identical, default cmdline + panic=10 + console=ttyDC0, #issuecomment-7222412369): clean boot (0 failed units, 0 AppArmor denials), ttyDC0 on IRQ 53, /dev/ttyDC0 works, and s2idle resume + /dev/ttyDC0 reopen (agetty active) PASS (0 dcuart_drain_timer starts, as J713 has no apple,sw-drain).
  • J616c (T6041 M4 Max, apple,s5l-uart — no apple,dockchannel-uart node; IRQ-backed boot smoke row for the shared serial_core changes, not a test of the IRQ-less guard) at 5dde1e7a4ffb (@AxxzyWasTaken, #issuecomment-7296016172): combined battery batch atop main (fe9af4b604784, alongside #3359 and #3409): clean boot, 0 failed units, 0 serial/dockchannel errors in dmesg, settled battery idle 3.52–3.59 W (disp_bl=100, kbd_bl=64).
  • J313 (T8103 M1 Air, apple,s5l-uart — no apple,dockchannel-uart node; IRQ-backed serial_core boot smoke row, not a test of apple-dockchannel-uart or the IRQ-less guard) at 5dde1e7a4ffb: composite trial kernel (origin/main 429e7e15f122 + #3335, #3506, #3508, #3269, #3359, #3289; 2/2 serial_core.o and apple_dockchannel_uart.o .o/.text byte-identical vs single-PR merge on 429e7e15f122, default cmdline, docked TS5 + DP-2): ttySAC0 (IRQ 64) and ttySAC2 (IRQ 65) apple,s5l-uart IRQ-backed with wakeup=disabled and open ok, 0 failed units, 0 AVC denials, 5 err+ lines matching default boot (s2idle not run).
  • Local/CI checks at 5dde1e7a4ffb: local arm64 QEMU KUnit apple-dockchannel-uart 33/33 PASS, W=1 KCFLAGS=-Werror build (serial_core.o, apple_dockchannel_uart.o), checkpatch.pl --strict (0/0/0), clean git merge-tree against main (a171afd2123f, zero drivers/tty/serial/ commits on main since 8e2ee15f3ca3), and live gh pr checks 3335 (Host tests/host-tests, pr-text/pr-text, pr-readiness/readiness passing; 0 failing; scheduled pr-readiness/readiness pending).
    Risk: two-way door · all Apple Silicon Macs with apple,sw-drain or IRQ-mode DockChannel UARTs and shared serial_core IRQ-less wakeup suspend/resume and console reopen paths.
    Revert: git revert -m 1 <merge-sha> (all state is in-memory driver and timer state; no persistent on-disk, ESP, or firmware state is modified).
    Not yet: J716c (T6050) s2idle/deep sleep with console=ttyDC0 + post-wake /dev/ttyDC0 reopen/idle-timer check at 5dde1e7a4ffb (unattended RTC wake is blocked because apple,t6050-pmu-rtc in t6050-j716c-sleep.dtsi has no interrupts and rtc-apple-pmu.c has no generation-4 SPMI alarm IRQ yet; rtcwake -m no -s 5 leaves wakealarm set with alrm_pending: no); J713 (T8132) deep sleep with console=ttyDC0 (plain main fcb124279183 also resets J713 in deep sleep); J313 (T8103) s2idle (s2idle hard-resets J313 on baseline main and was not run); untested Mac families: M1 Pro/Max, M2, M3, M4 Pro (T6040), and M4 Max DockChannel boards (J575c; J616c uses apple,s5l-uart only; no non-T6050 apple,sw-drain console Mac in local lab); physical DebugUSB RX over KIS on an active /dev/ttyDC0 session (including a >2 KiB burst right after the 100 ms idle backoff; no DebugUSB/KIS host link locally).
Details

Problem

On Apple Silicon boards whose DockChannel UART uses apple,sw-drain with console=ttyDC0, early boot opens and closes /dev/console. Because tty_port_shutdown_locked() leaves console ports initialized after final close so kernel console output keeps working, dcuart_drain_timer() kept firing every 10 ms (62.5-100 Hz) indefinitely even when no userspace tty held /dev/ttyDC0 open, keeping CPUs and the CLPC idle timer waking across the system.

Changes

  1. serial: core: guard IRQ-less ports on wakeup suspend and console reopen (536b98ec72d6)
    • Keeps device_set_wakeup_capable(tty_dev, 1) at registration time so TIOCSSERIAL can still assign an IRQ dynamically, while guarding enable_irq_wake() / disable_irq_wake() in uart_suspend_port() / uart_resume_port() with uport->irq (plus null checks on tty_dev and irq_get_irq_data() on resume).
    • Calls uport->ops->start_rx(uport) under port->lock in uart_open() when reopening an already-initialized IRQ-less console port (!retval && was_initialized && port->console && !uport->irq && !uport->suspended); this applies generically to any IRQ-less console implementing start_rx.
  2. serial: apple-dockchannel: stop idle console polling, back off RX, and add sleep PM (5dde1e7a4ffb)
    • Stops drain_timer completely (0 Hz) and skips RX MMIO reads when a console port has no open tty (!dcuart_has_reader()) and no queued TX; dcuart_start_rx() restarts polling immediately on reopen.
    • Backs off open-and-idle sw_drain polling exponentially 10 -> 20 -> 40 -> 80 -> 100 ms (~1,152 bytes at 115200 8N1, below the 2 KiB FIFO), snapping back to 10 ms on RX arrival, TX start, or set_termios.
    • dcuart_arm_drain_timer_locked() never pushes an earlier pending timer deadline forward, preventing repeated opens or concurrent kicks from starving RX.
    • Serializes TX drain and timer re-arm under port->lock -> dcuart->lock with drain_kick_gen sampled before the reader check so an in-flight timer callback cannot overwrite a concurrent TX/termios/reopen kick.
    • Serializes dcuart_shutdown() / dcuart_remove() teardown with shutting_down under dcuart->lock before timer_delete_sync(), and tracks rx_stopped in stop_rx() / start_rx().
    • Wires uart_suspend_port() / uart_resume_port() via pm_sleep_ptr().
    • Adds 5 deterministic KUnit tests covering idle backoff, closed-console stop and reopen via start_rx(), shutdown re-arm suppression, TX deadline shortening, and earlier-deadline preservation.
Evidence

Local static, unit, & CI verification (5dde1e7a4ffb)

  • Local arm64 QEMU KUnit: ./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/tty/serial/apple_dockchannel_uart.kunitconfig --jobs="$(nproc)": 33/33 PASS (apple-dockchannel-uart).
  • make O=_build ARCH=arm64 LLVM=1 defconfig && ./scripts/kconfig/merge_config.sh -m -O _build _build/.config arch/arm64/configs/asahi.config && ./scripts/config --file _build/.config -d RUST && make O=_build ARCH=arm64 LLVM=1 olddefconfig && make O=_build ARCH=arm64 LLVM=1 W=1 KCFLAGS=-Werror -j"$(nproc)" drivers/tty/serial/serial_core.o drivers/tty/serial/apple_dockchannel_uart.o: 0 errors, 0 warnings.
  • git diff --check 66fbacc273c6..5dde1e7a4ffb: clean.
  • ./scripts/checkpatch.pl --strict --git 66fbacc273c6..HEAD: 0 errors, 0 warnings, 0 checks (536b98ec72d6: 44 lines; 5dde1e7a4ffb: 608 lines).
  • git merge-tree --write-tree a171afd2123f6486ad5b3a8ff46d4342c98337dc 5dde1e7a4ffb573944ea0cb8b24545db1673c863 (against main a171afd2123f): clean merge (767bdabe3b9e), zero drivers/tty/serial/ commits on main since 8e2ee15f3ca3.
  • Candidate byte-identity proof (3e4078f656d5 and 90de523e9ed9 both contain 5dde1e7a4ffb as an ancestor; git diff --quiet 5dde1e7a4ffb <cand> -- drivers/tty/serial/apple_dockchannel_uart.c drivers/tty/serial/apple_dockchannel_uart-test.c drivers/tty/serial/serial_core.c exits 0; matching git blobs 489930828156, 959732a7c576, 5424f6ceeb38).
  • Live CI at 5dde1e7a4ffb (gh pr checks 3335): Host tests/host-tests, pr-text/pr-text, and pr-readiness/readiness passing, 0 failing, 1 scheduled pr-readiness/readiness check pending (2 superseded Nov 27 runs cancelled in rollup); the hosted Apple build/KUnit workflow (apple-build-kunit.yml) does not run for these paths (paths: excludes drivers/tty/serial/**).

J716c (M5 Max) same-machine A/B (baseline vs 5dde1e7a4ffb)

Docked AC (eDP-1 3456x2234@120 + dual DP-1/DP-4 3840x2160@240 + 2.5GbE), default kernel cmdline (console=ttyDC0):

Metric (3 s DPMS-OFF sample unless noted) Baseline 5dde1e7a4ffb Delta
dcuart_drain_timer (closed /dev/ttyDC0) 187 (62.3/s) 0 (0.0/s) -100%
arch_timer 1341 (447/s) 663 (221/s) -50.6%
tick_nohz_handler 1196 (399/s) 498 (166/s) -58.4%
IPI 685 (228/s) 269 (90/s) -60.7%
apple_clpc_idle_timer_fn 598 (199/s) 328 (109/s) -45.2%
Docked DPMS-ON total (macsmc_hwmon, 6 s avg) 10.04 W 9.85 W -0.19 W
Docked DPMS-ON Heatpipe (macsmc_hwmon, 6 s avg) 3.32 W 3.23 W -0.09 W
Docked DPMS-OFF total / Heatpipe (6 s avg) 3.99 W / 1.58 W 3.99 W / 1.59 W noise floor

Console reopen & regression check on J716c (5dde1e7a4ffb)

  • Raw open("/dev/ttyDC0", O_RDWR | O_NONBLOCK) without tcsetattr or write: dcuart_drain_timer restarted immediately via uart_open() -> dcuart_start_rx() and settled at 20 fires in 2 s (10.0 Hz).
  • After close(): dcuart_drain_timer returned to 0 fires in 3 s.
  • /sys/class/tty/ttyDC0/power/wakeup: disabled.
  • Regression: all 3 displays + DPMS off/on cycle, wlan0/enP3p3s0, AppleJ716 audio, /dev/accel/accel0, GPU, isp-sys/ane-sys/fpwm0/atc0,1,3 off-0, 0 new kernel errors, 0 failed systemd units.
  • J716c (T6050) at 5dde1e7a4ffb in candidate 3e4078f656d5 (default command line with console=ttyDC0): tracefs timer_expire_entry filtered on dcuart_drain_timer: 0 expirations in 10 s (0.0/s) with /dev/ttyDC0 closed -> 96 in 10 s (9.6/s) while held open via raw open -> 0 in 10 s (0.0/s) after close; 0 new failed units, 0 LSM denials, 0 new kernel errors (rtcwake -m no -s 5 confirmed apple,t6050-pmu-rtc alarm IRQ never fires because t6050-j716c-sleep.dtsi has no interrupts on it, leaving unattended s2idle/deep wake in **Not yet:**).

J716c (M5 Max, T6050, firmware 27.2) smoke row at 5dde1e7a4ffb (2026-11-28)

  • Candidate: batched candidate 3545ebecb76f (origin/main b897ccb4e71c + 18 PRs, CONFIG_ARM_APPLE_SOC_CPUFREQ=m, AC power, default command line with console=ttyDC0); all 3/3 PR files (apple_dockchannel_uart.c, apple_dockchannel_uart-test.c, serial_core.c) are blob-identical to 5dde1e7a4ffb, which is an ancestor of the booted tree.
  • Hashes: Image.gz SHA-256 d56efde4c7232208bd29d5c4e5890319e0050595dd4f4b1c3844df6656a08312, t6050-j716c.dtb SHA-256 d2f0db7a5026ae9cc4e1cff61dca38b4d1b363d47e5bad696ef65c7d715517e0, modules SHA-256 9d5782bcf02ea60a225278c9319431f902b495f6beb485d79d127c0fb2fccc92, one-shot aura-try Stage 2 SHA-256 b7d99286395ddd7dadccc6d9593f4bd55391d9e787af97c18b45f58688d9885d (default Stage 2 21edee972e1ff1718c6f41c32b91ee151afdc58cbb69f16f2f6a4d8d4c722170, default kernel bf2582ab357573db64031f39e7bc9d617eb574c6b221364ff417810bbddf4c87, default DTB ffe7604c98ad23849b2aff19eb161bec712f8b367a9bc87339fabb6d7dc1276c unchanged).
  • Smoke: boots cleanly with console=ttyDC0 on the default command line; eDP-1 3456x2234@120 enabled, 4 input devices, wlan0 0% loss, AppleJ716 + AppleJ716HPAI enumerated (speakerguardd-v2 active), Borealis Apple M5 Max (G17C B1) + vkcube --c 180 OK, 0 failed user units, 0 LSM denials, 0 Oops/BUG/fault; 1 warm-reboot baseline failed unit (aurora-peripherals.service, also fails on control and restored default); 40 err+ lines all pre-existing vs 55-line default boot except PM: suspend debug notices and 3 DPMS a display-interface open failure syslog lines. (No timer-expiry trace was taken on this boot; timer-expiry behaviour was already verified in 3e4078f656d5 and the same-machine A/B above.)

J713 (M4 Air, T8132, 38812c000.serial, firmware 27.2) rows at 5dde1e7a4ffb

  • Row 1 — earlier console=ttyDC0 reopen & s2idle row (90de523e9ed9, default cmdline + panic=10 + console=ttyDC0, #issuecomment-7222412369): 3/3 PR files byte-identical to 5dde1e7a4ffb; clean boot (0 failed units, 0 AppArmor denials), ttyDC0 registers (IRQ 53 level), /dev/ttyDC0 works, and s2idle resume + /dev/ttyDC0 reopen (agetty active) PASS. J713's 38812c000.serial has no apple,sw-drain, so dcuart_drain_timer recorded 0 starts in 10 s across closed, open-idle, and after-close (timer path is not active on this board); RX requires a remote counterpart. Plain main (fcb124279183) also resets J713 in deep sleep.
  • Row 2 — 2026-11-28 IRQ-mode registration & full smoke row (76649338a1bc, default cmdline + panic=10 with console=tty0): batched candidate 76649338a1bc (J713 default kernel source 8dbfa2895b93 plus heads of #3491, #3291, #3397, #3289, #3085, #3223, #3329, #3495, #3546, #3548, with #3273, #3294, #3335 already included); 3/3 PR files blob-identical to 5dde1e7a4ffb.
    • Hashes: booted kernel image SHA-256 e8e9fd2813dd6347176d0e4a55a70d1c694bdab75817c3ab83c441c203140491, one-shot Stage 2 SHA-256 f7d4e2f7ebbfb423bd71f233f1aef7af0a39091b288a749d25f9250eb80adbfa (default Stage 2 and kernel untouched).
    • 38812c000.serial: ttyDC0 ... is a Apple DockChannel UART (irq = 53), /dev/ttyDC0 present, IRQ 53 level; dockchannel-hid keyboard and multi-touch interfaces ready. J713 has no apple,sw-drain, so the drain timer does not run on this board.
    • Smoke: display (eDP-1 2560x1664@60 enabled; no external monitor or dock attached), input (Apple MTP keyboard and trackpad devices enumerated, not exercised remotely), networking (wlan0 connected, gateway ping 0% loss), permitted audio sink (speakerguardd-v2 active, 1 s tone at -26 dB through the protected default sink, rc 0), GPU rendering (Borealis Apple M4 (G16G B0), Vulkan 1.4.363, glmark2 score 5,099), 0 failed units, 0 AppArmor denials (no SELinux on this userland).
    • err-level dmesg: the three baseline lines (apple-dcp 30ae00000.dcp: AFK[ep:20]: failed to extract init props: -2, unsupported DFB layout 2560x1664 format=0x62336138 compression=3 (-22), and apple_sep ... matching unavailable this boot notice) plus 1 one-off brcmfmac 0000:01:00.0: brcmf_pcie_ring_mb_update_rptr: ring 4: r_ptr 0 outside depth 0 at 9.2 s recorded on 76649338a1bc (0 times in the preceding 8 boots on J713, no recurrence across 5× wlan0 down/up and 5× s2idle; attribution remains open).
    • Redacted dmesg excerpt: [ 0.080976] 38812c000.serial: ttyDC0 MMIO32:0x000000038812c000 (irq = 53, base_baud = 0) is a Apple DockChannel UART, [ 0.850338] dockchannel-hid 394b28000.input: Interface keyboard is now ready, [ 2.891461] dockchannel-hid 394b28000.input: Interface multi-touch is now ready.

J616c (M4 Max, T6041, IRQ-backed apple,s5l-uart boot smoke) row at 5dde1e7a4ffb (2026-12-01, @AxxzyWasTaken)

  • Combined battery batch atop main (fe9af4b604784) with PR head 5dde1e7a4ffb alongside #3359 and #3409 (#issuecomment-7296016172).
  • arch/arm64/boot/dts/apple/t6041-j616c.dts (via t6041-j614c-j616c.dtsi) defines serial0 on apple,s5l-uart with no apple,dockchannel-uart node (&mtp_dockchannel is apple,dockchannel-hid), so this is an IRQ-backed boot smoke of the shared drivers/tty/serial/serial_core.c changes rather than a test of apple-dockchannel-uart or of the IRQ-less wakeup guard.
  • Result: clean boot, 0 failed units, 0 serial/dockchannel errors in dmesg, settled battery idle 3.52–3.59 W (disp_bl=100, kbd_bl=64).

J313 (M1 Air, T8103, IRQ-backed apple,s5l-uart boot smoke) row at 5dde1e7a4ffb

  • Composite trial kernel (origin/main 429e7e15f122 + #3335, #3506, #3508, #3269, #3359, #3289; 2/2 serial_core.o and apple_dockchannel_uart.o .o/.text byte-identical vs single-PR merge on 429e7e15f122, GRUB one-shot, default cmdline, docked CalDigit TS5 + DP-2 3840x2160@120, AC 100%).
  • T8103 uses apple,s5l-uart (no apple,dockchannel-uart node), so this is an IRQ-backed serial_core check rather than a test of apple-dockchannel-uart or the IRQ-less guard.
  • Result: ttySAC0 (IRQ 64) and ttySAC2 (IRQ 65) apple,s5l-uart IRQ-backed with wakeup=disabled, open ok; 0 failed units, 0 AVC denials, 5 err+ lines matching default boot (s2idle was not run).

Polled UARTs leave uport->irq at 0 while keeping the tty device
wakeup-capable (so TIOCSSERIAL can assign an IRQ later). If wakeup is
enabled while uport->irq is still 0, uart_suspend_port() ignores the
failed enable_irq_wake(0) and skips suspend, and uart_resume_port()
then passes NULL from irq_get_irq_data(0) to irqd_is_wakeup_set().

In addition, tty_port_shutdown_locked() leaves console ports initialized
after close so kernel console output keeps working, causing subsequent
uart_open() calls to skip startup(). Polled console drivers that stop
their RX polling timer while no tty holds the port open therefore need
a start_rx() callback when an already-initialized IRQ-less console is
reopened.

Guard the suspend and resume IRQ-wake paths with uport->irq (plus null
checks on tty_dev and irq_get_irq_data() on resume), and invoke
uport->ops->start_rx() under port->lock when reopening an
already-initialized IRQ-less console port.

Signed-off-by: Erik Bourget <[email protected]>
…d add sleep PM

On Apple Silicon boards with apple,sw-drain and console=ttyDC0, early
boot opens and closes /dev/console. Because tty_port_shutdown_locked()
leaves console ports initialized after close, dcuart_drain_timer()
previously kept polling at 10 ms (62.5-100 Hz) forever even when no tty
held the port open, waking idle CPUs across the system continuously.

Reduce idle wakeups and tighten drain-timer lifecycle:
- When a console port has no open tty and no queued TX, skip RX MMIO
  reads and stop drain_timer completely instead of polling at 10 ms.
  Implement dcuart_start_rx() so reopening the console restarts polling
  immediately at 10 ms without pushing an earlier pending deadline
  forward on repeated opens.
- Back off open-and-idle sw-drain RX polling exponentially from 10 ms
  to 100 ms (~1152 bytes at 115200 baud, below the 2 KiB FIFO),
  snapping back to 10 ms on RX arrival, TX start, or termios updates.
- Never push an earlier pending timer deadline forward, and serialize
  TX drain and timer re-arm under port->lock -> dcuart->lock with
  drain_kick_gen sampled before the reader check so an in-flight
  callback cannot overwrite a concurrent TX, termios, or reopen kick.
- Serialize drain_timer teardown against dcuart_shutdown() and
  dcuart_remove() with shutting_down under dcuart->lock before
  timer_delete_sync(), and track rx_stopped in stop_rx()/start_rx().
- Wire uart_suspend_port() / uart_resume_port() via pm_sleep_ptr() so
  system sleep stops the drain timer and restores port thresholds on
  resume.
- Add KUnit coverage for idle backoff, closed-console stop/reopen via
  start_rx(), earlier-deadline preservation on repeated start_rx() and
  pre-snapshot kicks, shutdown re-arm suppression, and TX shortening.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team as code owners November 27, 2026 01:00
@erikwb
erikwb requested review from LiamRay11 and malik-na November 27, 2026 01:00
@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Merge readiness at 5dde1e7a: ready to merge

Check Detail
CI at head ok 6 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 5dde1e7a
Conflicts ok none
PR text ok Risk: two-way · all Apple Silicon Macs with apple,sw-drain or IRQ-mode DockChannel UARTs and shared serialcore IRQ-less wakeup suspend/resume and console reopen paths. Revert: git revert -m 1 <merge-sha> (all state is in-memory driver and timer state; no persistent on-disk, ESP, or firmware state is modified).

Areas: none matched in CODEOWNERS
Merge: gh pr merge 3335 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@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.

Verdict at 5dde1e7a4ffb: no code blockers found. It isn't ready to merge yet: CI and the cross-Mac rows are still owed (see below).

Checked

  • Lock order.
    • Every new path takes port->lock before dcuart->lock: the drain timer's re-arm block, start_tx, start_rx and stop_rx (all called with the port lock held), and set_termios.
    • dcuart_has_reader() takes only tport->lock, and from timer context with nothing else held.
    • Nothing takes dcuart->lock and then the port lock.
  • Timer lifetime.
    • shutting_down is set under dcuart->lock before timer_delete_sync() in both dcuart_shutdown() and dcuart_remove(). dcuart_arm_drain_timer_locked() checks it, so a callback already running can't re-arm after teardown.
    • stop_rx uses the non-sync timer_delete() under the lock, which is safe, and the callback re-checks rx_stopped.
    • Earlier deadlines are never pushed back, and drain_kick_gen is sampled before the reader check, so a reopen or a TX/termios kick that races the callback isn't lost.
  • Idle stop and reopen.
    • sw_drain ports never get port.irq (probe requests it only without apple,sw-drain), so the new uart_open() branch is what restarts RX on a console reopen. It requires was_initialized, port->console, !irq and !suspended, runs under uart_port_ref_lock(), and lands in dcuart_start_rx().
    • IRQ-mode channels are unchanged. With never_wait, the timer still runs while TX is pending.
  • serial_core hunks.
    • Skipping enable_irq_wake()/disable_irq_wake() for irq == 0 is correct. The old code called them on IRQ 0, and on resume it dereferenced a possibly NULL tty_dev. An IRQ-less port with wakeup enabled now suspends normally; the old early return 0 left it running.
    • put_device() still covers the fall-through.
  • PM.
    • DEFINE_SIMPLE_DEV_PM_OPS calls uart_suspend_port() and uart_resume_port(). For an initialized port, shutdown() stops the timer and startup() re-arms it.
    • A console without a reader stops again after its first tick, and no_console_suspend keeps the existing behaviour.
  • Tests and commits.
    • checkpatch --strict gives 0/0/0 on both commits, which are signed off with no attribution.
    • The new KUnit cases cover the backoff, the closed-console stop and the reopen, shutdown blocking a re-arm, and deadline handling.
    • I didn't build or run them here: that needs a kernel build, and the host takes light tests only.

Not blocking

  • Idle poll versus FIFO size. The 100 ms idle poll is sized for 115200 baud, about 1152 bytes per tick against the 2 KiB FIFO. A DockChannel producer such as KIS over DebugUSB may write faster than that. The KIS row below should paste more than 2 KiB right after the port has backed off to 100 ms, and check that nothing is lost.
  • Generic uart_open() change. It applies to every IRQ-less console that implements start_rx, not only DockChannel. It's correct for that contract, and worth a line in the commit message.

Before merge

  1. CI. Only host-tests, pr-text and readiness ran at this head, with no Apple build or KUnit job. They need to run green.
  2. Rows. The only row is the J716c (T6050). This changes shared serial_core and a driver used on every Apple Silicon Mac, so it needs:
    • one non-T6050 Mac with an apple,sw-drain console (for example M1 or M2) and one Mac with an IRQ-mode DockChannel: boot, console reopen, s2idle/deep with ttyDC0 as console, and clean logs;
    • the KIS DebugUSB RX test on an open /dev/ttyDC0, which is already under Not yet, including the burst above.

@erikwb

erikwb commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Verified at 5dde1e7a4ffb and updated the PR body with the local build/KUnit details, hardware rows, and cleaned labels.

  • CI (apple-build-kunit): .github/workflows/apple-build-kunit.yml did not trigger on this PR because its on.pull_request.paths filter omits drivers/tty/serial/** (and its KUnit matrix does not list apple_dockchannel_uart.kunitconfig). Locally at 5dde1e7a4ffb: kunit.py on drivers/tty/serial/apple_dockchannel_uart.kunitconfig passed 33/33, make ARCH=arm64 LLVM=1 W=1 KCFLAGS=-Werror drivers/tty/serial/serial_core.o drivers/tty/serial/apple_dockchannel_uart.o (under aurora_defconfig + asahi.config, with CONFIG_RUST=n for C-only object verification) passed with 0 warnings, and checkpatch.pl --strict --git 8e2ee15f3ca3..HEAD passed 0/0/0. host-tests, pr-text, and readiness are green on GitHub.
  • IRQ-mode DockChannel (J713, T8132) and J716c (T6050) rows: On J716c at 5dde1e7a4ffb in candidate 3e4078f656d5 (default command line with console=ttyDC0), tracefs timer_expire_entry on dcuart_drain_timer verified 0.0/s (closed) -> 9.6/s (96 in 10 s, raw open) -> 0.0/s (closed), with 0 new failed units, 0 LSM denials, and 0 new kernel errors. J716c s2idle/deep sleep with console=ttyDC0 + post-wake reopen did not complete (the s2idle test did not wake via RTC alarm), and the J713 (38812c000.serial, IRQ-mode DockChannel) console=ttyDC0 boot/reopen/sleep run did not start before J713 halted on its control boot; both remain listed under **Not yet:**.
  • Non-T6050 apple,sw-drain Mac and DebugUSB KIS RX: neither a non-T6050 apple,sw-drain Mac (our local M1 J313 uses apple,s5l-uart with an IRQ, not DockChannel/sw-drain) nor a physical DebugUSB/KIS host link is present in our local lab, so both remain under **Not yet:** (with the >2 KiB burst after the 100 ms backoff noted for the KIS run).
  • uart_open() commit note: 536b98ec72d6 already states the start_rx() reopen contract generically for polled IRQ-less console drivers, so I kept the commits as-is to avoid rewriting 5dde1e7a4ffb and invalidating the existing J716c hardware row, and clarified the generic scope in the PR body.

@erikwb

erikwb commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR body with the J713 (M4 Air, 38812c000.serial, 27.2 firmware) console=ttyDC0 run at 5dde1e7a4ffb in candidate 90de523e9ed9 (default cmdline + panic=10 + console=ttyDC0):

  • Clean boot (0 failed units, 0 AppArmor denials), ttyDC0 registers (IRQ 53 level), /dev/ttyDC0 works, and s2idle resume + /dev/ttyDC0 reopen (agetty active) PASS.
  • J713's 38812c000.serial has no apple,sw-drain, so dcuart_drain_timer stays 0 across closed/open/after-close (timer path is not exercised on this board); RX check requires a counterpart on the other end.
  • J716c unattended s2idle/deep wake remains in Not yet because apple,t6050-pmu-rtc has no interrupts in t6050-j716c-sleep.dtsi / rtc-apple-pmu.c (rtcwake -m no -s 5 leaves wakealarm set with alrm_pending: no), and plain main (fcb124279183) also resets J713 in deep sleep.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 27, 2026
@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Re-verified 5dde1e7a4ffb cleanly against main (18058ea228e2) and updated the PR body (**Revert:**, tightened **Tested:**, separated J713 rows by kernel command line, and accurate CI status):

  • Merge & local checks at 5dde1e7a4ffb: git merge-tree --write-tree origin/main 5dde1e7a4ffb merges cleanly with zero conflicts and no drivers/tty/serial/ commits on main since 66fbacc273c6; local arm64 QEMU KUnit (./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=drivers/tty/serial/apple_dockchannel_uart.kunitconfig) passed 33/33 (note: the hosted Apple build/KUnit workflow did not run for these paths because its paths: filter excludes drivers/tty/serial/**); make O=_build ARCH=arm64 LLVM=1 defconfig + asahi.config (CONFIG_RUST=n) + W=1 KCFLAGS=-Werror on drivers/tty/serial/serial_core.o and drivers/tty/serial/apple_dockchannel_uart.o passed with 0 errors, 0 warnings; ./scripts/checkpatch.pl --strict --git 66fbacc273c6..HEAD passed 0/0/0.
  • Candidate byte-identity: 3e4078f656d5 (J716c), 90de523e9ed9 (J713 console=ttyDC0), 3545ebecb76f (J716c), and 76649338a1bc (J713 console=tty0) all contain 5dde1e7a4ffb as an ancestor with byte-identical blobs for apple_dockchannel_uart.c, apple_dockchannel_uart-test.c, and serial_core.c.
  • Live CI status (gh pr checks 3335): 3 passing (Host tests/host-tests, pr-text / pr-text, latest readiness / readiness), 1 cancelled (superseded readiness / readiness run), and 0 failing (apple-build/kunit did not trigger for drivers/tty/serial/**; the ci-failing label remains on the PR).
  • J716c (T6050, apple,sw-drain) at 5dde1e7a4ffb (2026-11-28): batched candidate 3545ebecb76f (3/3 blob-identical, Image.gz d56efde4c7232208bd29d5c4e5890319e0050595dd4f4b1c3844df6656a08312, Stage 2 b7d99286395ddd7dadccc6d9593f4bd55391d9e787af97c18b45f58688d9885d, default cmdline with console=ttyDC0) boots cleanly with 6-item smoke pass (0 failed user units, 0 LSM denials, aurora-peripherals.service warm-reboot baseline failure also on default/control; timer-expiry trace was verified earlier in 3e4078f656d5 and the same-machine A/B).
  • J713 (T8132, IRQ-mode DockChannel without apple,sw-drain) at 5dde1e7a4ffb — two distinct rows:
    • 90de523e9ed9 (default cmdline + panic=10 + console=ttyDC0, #issuecomment-7222412369): clean boot (0 failed units, 0 AppArmor denials), ttyDC0 on IRQ 53, /dev/ttyDC0 works, and s2idle resume + /dev/ttyDC0 reopen (agetty active) PASS (0 dcuart_drain_timer starts, as J713 has no apple,sw-drain).
    • 76649338a1bc (2026-11-28, default cmdline + panic=10 with console=tty0, kernel e8e9fd2813dd6347176d0e4a55a70d1c694bdab75817c3ab83c441c203140491, Stage 2 f7d4e2f7ebbfb423bd71f233f1aef7af0a39091b288a749d25f9250eb80adbfa): IRQ-mode ttyDC0 registration on IRQ 53, dockchannel-hid ready, 8-item smoke pass (0 failed units, 0 AppArmor denials; 1 one-off brcmfmac ring line recorded on 76649338a1bc, 0 times in the preceding 8 boots, no recurrence over 5× wlan0 down/up + 5× s2idle; attribution remains open).

Remaining under **Not yet:**: non-T6050 apple,sw-drain console Macs (M1 Pro/Max, M2, M3, M4 Pro/Max; no non-T6050 apple,sw-drain console Mac in local lab; M1/T8103 uses apple,s5l-uart only), physical DebugUSB RX over KIS on an active /dev/ttyDC0 session (including a >2 KiB burst right after the 100 ms idle backoff; no DebugUSB/KIS host link locally), J716c s2idle/deep sleep with console=ttyDC0 + post-wake /dev/ttyDC0 reopen/idle-timer check (unattended RTC wake blocked on missing apple,t6050-pmu-rtc alarm IRQ), and J713 deep sleep with console=ttyDC0 (main fcb124279183 also resets J713 in deep sleep).

@AxxzyWasTaken

Copy link
Copy Markdown
Contributor

Tested on M4 Max (J616C / T6041) in a combined battery batch atop main (fe9af4b604784, with PR head 5dde1e7a4ffb5, alongside #3359 and #3409):

  • Clean boot, 0 failed units, 0 serial/dockchannel errors in dmesg.
  • Settled battery idle: 3.52–3.59 W (disp_bl=100, kbd_bl=64).

@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Recorded the M4 Max (J616c / T6041) row from #issuecomment-7296016172 and re-verified 5dde1e7a4ffb against main (a171afd2123f):

  • J616c (T6041 M4 Max) scope: t6041-j616c.dts (t6041-j614c-j616c.dtsi) uses apple,s5l-uart on serial0 and has no apple,dockchannel-uart node, so the combined batch run (fe9af4b604784 + 5dde1e7a4ffb alongside #3359 and #3409) provides an IRQ-backed boot smoke row for the shared serial_core.c changes (0 failed units, 0 serial/dockchannel errors, 3.52–3.59 W settled battery idle). Non-T6050 apple,sw-drain DockChannel consoles (M1 Pro/Max, M2, M3, M4 Pro T6040, and M4 Max J575c) remain under **Not yet:**.
  • J313 (T8103 M1 Air) composite serial check at 5dde1e7a4ffb: in the composite trial kernel on origin/main 429e7e15f122 (serial_core.o and apple_dockchannel_uart.o 2/2 .o/.text byte-identical vs single-PR merge), ttySAC0 (IRQ 64) and ttySAC2 (IRQ 65) apple,s5l-uart IRQ-backed ports reported wakeup=disabled and opened cleanly (0 failed units, 0 AVC denials, 5 err+ lines matching default boot; T8103 has no apple,dockchannel-uart node, and s2idle remains in **Not yet:**).
  • Clean merge & CI at 5dde1e7a4ffb: git merge-tree --write-tree a171afd2123f6486ad5b3a8ff46d4342c98337dc 5dde1e7a4ffb573944ea0cb8b24545db1673c863 merges cleanly (767bdabe3b9e, zero drivers/tty/serial/ commits on main since 8e2ee15f3ca3). Host tests/host-tests, pr-text/pr-text, and pr-readiness/readiness are passing with zero failing checks (pr-readiness scheduled run queued).

@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.

The earlier review found no code blocker in the timer teardown, IRQ guard or console reopen paths. The exact-head J716c polled-console row, J713 IRQ-console row, shared serial-core boot smoke and host CI now cover the reviewed change.

@github-actions github-actions Bot removed the needs-review No approving review from Core or Omarchy Mac yet (bot) label Dec 1, 2026
@github-actions github-actions Bot added the ready-to-merge Meets the merge policy: merge it (bot) label Dec 1, 2026
@DjDeveloperr
DjDeveloperr merged commit 6f3b2a3 into main Dec 1, 2026
12 of 15 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/dcuart-idle-drain-timer branch December 1, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants