Repository navigation
dmaengine/ASoC: apple: enable runtime PM for SIO and MCA audio domains - #3359
Conversation
sio_probe() released its runtime PM reference while sio_suspend() was a no-op stub, leaving sio_mbox active and risking ps_sio_cpu powering off under live SIO firmware whenever no other consumer pinned sio_dart. Implement sio_suspend() and sio_resume() for controllers that are not deferred to the sleep commit boundary (!commit_stop && !stop_at_commit): - Stop idle SIO firmware in sio_suspend() with apple_rtkit_sleep_stop() once all channels are quiet and no mailbox tags are outstanding, using a 500 ms autosuspend delay so back-to-back calls do not thrash it. - Restart SIO in sio_resume() via apple_rtkit_power_cycled_return(), falling back to apple_sleep_engine_reset() when a sibling domain kept the shared SIO power switch on across runtime suspend. - Hold runtime PM across sio_device_config(), sio_terminate_work(), sio_stop_quiet(), and active idle transfers (sio_set_idle() through sio_clear_idle()). - Keep commit_stop and stop_at_commit controllers active at runtime and through system suspend so commit-time stops run untouched; avoid double-stopping or waking an already runtime-suspended SIO across system sleep. - Allow apple_sleep_engine_reset() to fall back to reg index 0 when reg-names is absent and to map apple,pmgr directly when apple_sleep is not bound, so the engine-reset recovery works on every board with standard apple,pmgr-pwrstate domains. Signed-off-by: Erik Bourget <erik@ebourget.net>
…nnels on open apple_mca_probe() pinned the audio_p power domain via mca->pd_link (DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE) without enabling runtime PM on mca->dev, and mca_pcm_new() held ADMAC channels for the lifetime of the card, pinning ps_sio_adma, sio_dart, and the SIO power-domain hierarchy permanently on even when no audio stream is open. Enable runtime PM on MCA and allocate ADMAC channels lazily on open: - Cache DAI BCLK polarity and TX/RX bitstart in mca_fe_set_fmt() and program them in mca_fe_hw_params() / mca_configure_serdes() so ps_audio_p can safely power off between streams. - Enable runtime PM on mca->dev with a 200 ms autosuspend delay in apple_mca_probe(), holding a reference across mca_pcm_open()/mca_close() and mca_be_startup()/mca_be_shutdown(), and skip MMIO in apple_mca_suspend_late()/apple_mca_resume_early() when already runtime-suspended. - Format DMA channel names in a stack buffer in mca_request_dma_channel() instead of devm_kasprintf() to avoid leaking memory across open/close cycles. - Request ADMAC channels briefly in mca_pcm_new() to validate presence and configure managed PCM buffers, then allocate them in mca_pcm_open() and release them in mca_close() via snd_dmaengine_pcm_close_release_chan(). Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: Changes requested at a8d2f37caf89.
The configuration path holds a temporary runtime PM reference, then drops it. A DMA client can configure a channel and issue a descriptor after that autosuspend window. sio_issue_pending() still calls sio_update_current_tx_locked() and fills the ring under the channel spinlock without obtaining a live firmware reference or deferring to a resume worker. Prevent descriptor publication while firmware is suspended or suspending. Cover a configured channel issuing after autosuspend, with the PM reference held until it is safe to stop. The current undocked sleep and cross-generation rows remain open.
FPWM0..2 sit behind the SIO fabric on T8103, matching t600x, t8112, t602x, t6030, t6040, and t8140. Without power-domains = <&ps_sio>, letting ps_sio power down at runtime idle allows pwm_apple (for example during led_pwm_shutdown() on reboot) to write FPWM MMIO registers with the SIO fabric powered off, triggering an asynchronous SError in apple_pwm_apply(). Parent ps_fpwm0, ps_fpwm1, and ps_fpwm2 under ps_sio so active PWM users hold ps_sio up while idle PWM (duty cycle 0) lets ps_fpwm* and ps_sio suspend together. Signed-off-by: Erik Bourget <erik@ebourget.net>
sio_device_config() drops its temporary runtime PM reference on return, so a client calling sio_issue_pending() after the 500 ms autosuspend delay could publish descriptors while SIO firmware is stopped or mid-suspend. Track a per-channel transfer runtime PM reference (tx_rpm_held) held while current_tx is active: - Acquire it in atomic context via pm_runtime_get_if_active() when SIO is active; otherwise keep the descriptor on vc.desc_issued and defer activation to sio_issue_work(), which calls pm_runtime_resume_and_get() before publishing. - Guard sio_fill_in_old_locked() and sio_fill_in_ring_locked() against rpm_stopped, mark channels with tx_rpm_held or queued vc.desc_issued entries busy in sio_chan_busy(), and flush issue_wq before terminate_wq in sio_synchronize(). - Release tx_rpm_held when current_tx clears without a queued successor (in ring-to-idle handover and sio_terminate_work()). - Add KUnit coverage for issuing after autosuspend, draining deferred descriptors, busy accounting, and ring handover PM release. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Addressed in
|
There was a problem hiding this comment.
Verdict: FINISH, then merge.
Blocker: In sio_issue_work(), a failed pm_runtime_resume_and_get() logs and returns while the accepted descriptor remains on desc_issued. issue_pending() has already returned and no retry is scheduled. A client waiting for completion can hang until it explicitly terminates the channel. Please define a bounded retry or report a terminal DMA error to the client, and cover runtime resume failure and recovery in KUnit.
Checked: The issue paths now acquire a runtime PM reference before publishing, and both refill paths check the stopped state. The new KUnit test demonstrates that a stopped engine stays unpublished and terminate/synchronize drains the descriptor. It does not cover progress or client-visible failure after the worker's resume fails. The J313 row covers a successful autosuspend/wake. Broader hardware and hosted checks still apply.
… and error reporting Harden the apple-sio transfer runtime PM lifecycle, teardown ordering, and aborted-descriptor reporting on top of the active-transfer reference tracking: - Gate descriptor publication on firmware being active (!rpm_stopped && !asleep) via sio_firmware_active(), and release tx_rpm_held across all quiet paths (issue ACK, report processing, stop_quiet, clear_idle, terminate_all, and terminate_work) once current_tx, non-idle ring state, retired list, and pending ACKs are clear. - Check READ_ONCE(sio->removing) under vc.lock before vchan_issue_pending() in sio_issue_pending() and in sio_prep_dma_cyclic() so late issue calls after teardown admission closes neither move submitted descriptors to desc_issued nor invoke vchan_cookie_complete() to rearm vc.task. - In sio_remove(), close admission under vc.lock, cancel issue_wq, flush terminate_wq before and after unregistering the DMA provider, refuse new runtime suspends and quiesce runtime PM via pm_runtime_dont_use_autosuspend() + pm_runtime_barrier(), and shut down/disable RTKit mailbox RX (apple_rtkit_shutdown() when sio->arrays is present, plus apple_rtkit_mailbox_off()) before the final drain and tasklet_kill(). - Abort deferred vc.desc_issued descriptors with DMA_TRANS_ABORTED on resume/RPM failure or teardown instead of stranding them, and record each aborted cookie with its exact u32 residue in a bounded 16-entry FIFO ring (siochan->error_cookies) preserved across subsequent healthy transfers until cookie reuse or channel resource release. Signed-off-by: Erik Bourget <erik@ebourget.net>
Extract the apple-sio.c runtime PM, descriptor issue, terminate, ring handover, error ring, and remove paths into a host model registered in tools/asahi/run-host-tests.py. Covers issuing after autosuspend and mid-suspend (both desc_issued refusal and concurrent sleep_stop race), cancel before issue_wq runs, ring/idle handover with clear_idle(), commit_stop and asleep guards, per-cookie DMA_ERROR residues across subsequent healthy transfers, late issue_pending() after remove admission closes, and active sio_remove() quiescing apple_rtkit_shutdown() -> apple_rtkit_mailbox_off() before final tasklet_kill(), plus 10 targeted mutations and pre-fix regression baseline a8d2f37. Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Reconciled on top of the live PR head In
Verified locally after
Hardware at
Still under |
There was a problem hiding this comment.
The deferred-resume failure now completes queued descriptors with DMA_TRANS_ABORTED and retains per-cookie residue in the error history. That addresses my previous stranded-descriptor finding. A real configured stream issued after autosuspend, capture, and J713 commit-stop transfer evidence are still missing. Please post those rows and exercise provider teardown with an active stream at this head before landing.
|
Added exact-head (
Still under
|
|
Tested on M4 Max (
|
main ended SIO transfers differently (#3195): an ended transfer is freed only once the firmware no longer reads its descriptors (sio_end_tx(), sio_release_tx()), and is held with its channel otherwise; synchronize waits for that (sio_sync()), bounded only from the SIO's prepare to its complete, under a per-channel lock. Carry the runtime PM of this branch onto that lifecycle: - sio_terminate_work() resumes the SIO around sio_end_tx() and hands its reference to a next transfer started without one. If the resume fails, sio_end_tx() still frees the transfer only once it is known stopped. - sio_release_tx(), where an ended or held transfer is finally freed, drops the channel's transfer reference with its last transfer, and aborts issued descriptors when there is no firmware to start them on (removal, or stopped), as the old terminate path did. - sio_stop_quiet() keeps main's result and gains the runtime PM hold and the transfer reference release. - sio_sync() flushes the deferred issue worker before ending anything, and kills the tasklet before returning: descriptors aborted with no transfer to end complete through it, and dmaengine_synchronize() must not return before their callbacks have run. - A held transfer stays the channel's current one, so it keeps the channel busy and its runtime PM reference, and the firmware up. Tests: initialise the per-channel sync lock in the runtime PM KUnit fixture; give main's tag fixture an issue worker and a runtime-active, held device as probe leaves it; extend the sio-rpm-issue host model with main's held-transfer code and the fields it uses. Signed-off-by: Erik Bourget <erik@ebourget.net>
DjDeveloperr
left a comment
There was a problem hiding this comment.
drivers/dma/apple-sio.c:3207 now calls apple_sleep_engine_reset() during ordinary runtime resume, but drivers/soc/apple/sleep.c:3255–3272 can leave the PMGR register in a forced reset or off state on timeout. For example, after writing PS_ENGINE_RESET_0, a failed poll skips both the power-on and saved-value writes. The helper then restores the DART state and returns while genpd still considers the domain on. Please make the failure path restore the touched power-state registers before restoring DART state, or explicitly coordinate a failed-domain state with the PMGR provider. Please cover a timeout after the reset write in the regression test.
|
We carry this PR in our J313 (M1 Air, T8103), J713 (M4 Air, T8132), and J716c (M5 Max, T6050) daily kernels. Without runtime PM for Running smoothly across all three daily kernels (J313, J713, and J716c) with audio playback/capture and idle runtime PM working cleanly. |
SIO runtime resume resets the engine even when a sibling has kept its power switch on. If either reset poll or the subsequent power-on poll times out, the engine reset can leave a domain forced into reset or targeting off while genpd still has it on. Save the control state and restore every touched word in reverse order before restoring DART state. Check the restored request and report any domain that fails to settle while preserving the original reset error. Inject failures at each reset and power-on poll in the host test. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
@erikwb, use this head for the next J313 SIO autosuspend/resume and capture receipt and the J713 commit-stop control. The existing rows cover |
The PMGR reset rollback and timeout regression are in 4a086af.
DjDeveloperr
left a comment
There was a problem hiding this comment.
The PMGR timeout fix at 4a086af941a9 resolves the earlier reset-state finding. Every failed power-state poll now reaches rollback, including the domain whose poll failed. The helper restores the saved controls in reverse order before DART restore, preserves the original error, and SIO keeps descriptor admission closed on that error. I reran the successful sequence and all nine timeout points with GCC and Clang. All nine host issue-lifecycle scenarios and the hosted Apple build, DT, host and SIO KUnit checks also passed.
@erikwb, the last physical results here cover 0e6b27f5a2a8. On your next docked J313 build, please record one actual SIO wake after autosuspend, a completed transfer and a return to suspended. The external DP audio channel can carry silence. A mic capture also checks MCA/ADMAC, but on the earlier J313 run SIO stayed suspended throughout capture. On your J713 commit-stop control, one known-good sleep/wake with SIO active, successful capture and ADMAC back at idle is sufficient. Please include the build SHA and any new driver errors. The J313 candidate can include #3850 unchanged.
Resolve conflicts in drivers/dma/apple-sio.c with T6030 commit-stop and commit_early updates from main: keep commit_no_cpu_down NULL base selection and hw->commit_early gating in sio_probe(), and keep sio->rx_held resume alongside WRITE_ONCE(sio->asleep, false) in sio_resume_early(). Signed-off-by: Erik Bourget <erik@ebourget.net>
|
Merged
Verified at
@DjDeveloperr, updated the PR description for
Remaining in |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Approving at 06a014735072.
The PMGR reset rollback asked for in the earlier round is in. Every failed poll in sleep_engine_reset_power() rolls the touched domains back in reverse order, including the one that timed out, before the DART restore, and the original error is kept. The merge with main keeps main's commit_no_cpu_down, commit_early and rx_held handling in sio_probe() and sio_resume_early(). Apart from line offsets, this PR's own changes to apple-sio.c, mca.c and the T8103 DT are the same as at 0e6b27f5a2a8.
I checked these and found no blocking defect:
- runtime PM get/put balance on every probe, remove and error path in both drivers;
- system-sleep ordering:
sio_system_suspend()stops the firmware throughsio_suspend(), sosio_suspend_late()andsio_resume_early()skip it, andpm_runtime_force_resume()restarts it; - channel teardown while runtime-suspended:
sio_terminate_work(),sio_stop_quiet()andsio_set_idle()resume first.
Checked locally on the merge with current main (bf7d80caf992, merges cleanly), arm64 LLVM=1:
W=1build, defconfig + asahi.config, ofsleep.o,apple-sio.o,mca.o,apple-admac.o,pwm-apple.oand the five T8103 DTBs: 0 warnings, 0 errors.- SIO KUnit (
drivers/dma/apple-sio.kunitconfig), compile only: 0 warnings, 0 errors. tools/asahi/run-host-tests.py --only sio: 70/70, including thea8d2f37caf89control.checkpatch.pl --stricton the 9 non-merge commits: 0 errors. It reports 2 long commit-log lines, 1 MAINTAINERS note, and 29 style checks in the host-test C file.
Non-blocking:
drivers/dma/apple-sio.c:3211,sio_suspend(): ifapple_rtkit_sleep_stop()fails butapple_rtkit_sleep_return()brings the firmware back, the stop error is still returned. Runtime PM keeps any error other than -EBUSY/-EAGAIN inpower.runtime_error. Every laterpm_runtime_resume_and_get()then fails with -EINVAL, sosio_device_config()andsio_set_idle()refuse until the next system sleep, even though the firmware is running. The fix is to return -EAGAIN in that branch and keep the real error only for the double failure.tools/asahi/run-host-tests.pyloses its executable bit (100755 to 100644, from4a086af941a9). CI and the docs run it throughpython3, so nothing breaks, but it should keep its mode.
Before merge: SIO/MCA is shared audio code, so it needs hardware rows from two generations. The J313 row covers this head. The second generation is still owed at this head: the J713 stop_at_commit control listed under Not yet. The J713 row at 0e6b27f5a2a8 doesn't carry over, because sleep.c has changed since then. Hosted KUnit for this head is still queued.
|
J773g (T8132, 27.2) 06a0147 PASS: apple-sio (3ade00000, SIO v10) and apple-admac (393300000/393800000) bound cleanly on 7.3.0-j773g-comp3-3359-3972 (main 1262f9e + #3359 + #3972, boot_id=3506c984); playback and capture skipped (t8132-j773g.dtb has no /sound card or internal mic); 1x s2idle (rtcwake -m freeze) PASS with SIO/ADMAC forced active, then both ADMACs returned to runtime-suspended after idle while T8132 commit_stop SIO stayed active per sio_can_runtime_suspend(); mem sleep refused identically to base at 48ae00000.dcp (-16) without error; 0 SIO/ADMAC/MCA errors, 0 DART faults, 0 WARN/Oops, 0 failed units. |
aurora-silicon#3359 landed and its branch was deleted, so this PR now targets main. apple-sio.c: main made sio_commit_stop() skip the CPU-control word on SIOs whose commit keeps the CPU up (commit_no_cpu_down). Keep that, and keep this branch's early return for a SIO runtime PM already stopped. Signed-off-by: DjDeveloperr <hey@djdev.me>
What: Implement SIO firmware stop/restart across runtime PM (
apple-sio+apple_sleep_engine_reset()fallback with PMGR rollback on timeout), defersio_issue_pending()descriptor publication via a resume worker when firmware is suspended or suspending, close SIO admission on runtime/sleep stop-return double failure until a confirmed RTKit restart (0e6b27f5a2a8), carry SIO runtime PM onto#3195's held-transfer lifecycle (df82585852cb) without letting timed-out stale tags pin SIO active (daf99763dd95), enable MCAaudio_pruntime PM with lazy ADMAC channel allocation on open (mca), parent T8103ps_fpwm0..2underps_sio(t8103-pmgr.dtsi), and mergemain(0bc45c54fbe6) at06a014735072.Tested: Host checks, KUnit suites, DT schema checks, kernel builds, and
J313(T8103) hardware verification at06a014735072(merged withorigin/main0bc45c54fbe6; prior composite J313, J713, and J716c hardware rows at0e6b27f5a2a8under Evidence):J313(M1 MacBook Air,T8103,27.2firmware) at06a014735072(in composite807c3bbf2263overorigin/maind3de772ac0c1, one-shot trial Stage 2 witht8103-j313.dtb, default cmdline): booted DT carriesps_fpwm0..2underps_sio,apple-sioautosuspend500 ms(control=auto); playing zeros (aplay,3 stwice, rc0) tohw:USBC,0(dock monitor) wokeapple-siofromsuspended(apple-sio: RTKit: Initializing), advancedruntime_active_time1257 -> 8500 ms, readactiveon close, and returned tosuspendedwithin2 sin both rounds (repeating8500 -> 15706 msafter deep S2R);arecord -D hw:AppleJ313HPAI,03-ch float 48 kHz (3 s) passed before and after3xdocked deep S2R (rtcwake -d /dev/rtc1 -m mem -s 20,suspend_statssuccess 0 -> 1per cycle,fail 0, 16 MB RAM integrity PASS,0Oops/WARN/SError;speakerguardd-v2-switchtest.servicefailed identically on a separate newer-mainbuild lacking#3359's DT/MCA changes while passing on the stock daily baseline).06a014735072: fulllinux-j313,linux-j713, andlinux-j716ckernel builds pass (7.3.0+);arm64 LLVM=1 W=1(defconfig+asahi.config,-d RUST) object builds pass with 0 errors and 0 warnings acrossdrivers/soc/apple/sleep.o,drivers/dma/apple-sio.o,sound/soc/apple/mca.o,drivers/dma/apple-admac.o,drivers/gpu/drm/apple/audio.o, anddrivers/pwm/pwm-apple.o.arm64 LLVM=1) at06a014735072:macaudio(apple-speaker-*) 84/84 passed;apple-sio45 passed, 1 skipped (apple_g17_rx_util_min_test, needsCONFIG_UCLAMP_TASK);pwm-apple40/40 passed.tools/asahi/run-host-tests.py) at06a014735072:--only sio70/70 passed (includingsio-engine-reset-testsandsio-rpm-issue-tests13 runs);--only dcpaud15/15 passed;--only apple-pwm-pm2/2 passed.06a014735072:scripts/dtc/apple-dt-check.sh origin/main HEADchecked 5 changed DTBs with 0 new warnings;scripts/checkpatch.pl --strict --git origin/main..HEADreported 0 errors across all commits.Risk: two-way door · all Apple Silicon Macs with Apple SIO / MCA audio / T8103 FPWM (M1–M5;
commit_stopandstop_at_commitSIO controllers remain active at runtime).Not yet: Remaining exact-head
06a014735072checks and other hardware paths:807c3bbf2263pass: physical-unplugs2idle(dockeds2idlewas refused cleanly bynhi, and software-undockeds2idlewithout a physical dock unplug hung/cold-reset), reboot-timeled_pwm_shutdown()under idleps_sio, and permitted speaker playback (with machine owner permission and activespeakerguarddv2 gating; a kbd-backlight write read back0underaurora-kbd-lightownership).06a014735072stop_at_commitsleep/wake with SIO active, mic capture, and ADMAC idle return (board off-network during this sweep, staged for retry).06a014735072boot sanity (recording the booted DT'ssionode status alongsideapple-sio/apple-mcabinding; not run before theJ716cpass stopped ons2idle).06a014735072: pending push and CI run on the unpublished06a014735072merge head.commit_no_cpu_down+commit_earlyalongsidestop_at_commit, vs J713'sstop_at_commit-only control) late-refusal sleep/wake (sio_resume_early()rx_heldunwind viaapple_rtkit_resume_rx()) and post-resume DP-audio recovery run.Details
dmaengine: apple-sio: stop and restart SIO firmware across runtime PM(ddf95fc58b08):sio_probe()dropped its runtime PM reference whilesio_suspend()was a no-op stub, leavingsio_mboxactive and riskingps_sio_cpupowering off under live SIO firmware if no sibling pinnedsio_dart.!hw->commit_stop && !hw->stop_at_commit),sio_suspend()stops idle SIO firmware viaapple_rtkit_sleep_stop()after a 500 ms autosuspend delay once all channels are quiet and no live mailbox tags are in flight.sio_resume()pulsesapple_sleep_engine_reset(dev)upfront beforeapple_rtkit_power_cycled_return(), avoiding the 1-second-ETIME(-62) wait when a sibling domain (audio/SPI) keptps_siopowered on across runtime suspend.sio_device_config(),sio_terminate_work(),sio_stop_quiet(), and active idle transfers (sio_set_idle()..sio_clear_idle()), and avoids double-stopping or waking an already runtime-suspended SIO across system sleep.apple_sleep_engine_reset()(drivers/soc/apple/sleep.c) to fall back to reg index 0 whenreg-namesis absent and to mapapple,pmgrdirectly whenapple_sleepis not bound.ASoC: apple: mca: enable runtime PM on audio_p and allocate ADMAC channels on open(a8d2f37caf89):apple_mca_probe()pinnedaudio_pviamca->pd_link(DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE) without enabling runtime PM onmca->dev, andmca_pcm_new()held ADMAC channels for the lifetime of the sound card, permanently pinningps_sio_adma,sio_dart, and the SIO domain hierarchy.mca_fe_set_fmt()and writes them inmca_fe_hw_params()/mca_configure_serdes()sops_audio_pcan safely power off between streams.mca->dev, holding references acrossmca_pcm_open()/mca_close()andmca_be_startup()/mca_be_shutdown(), and skips MMIO inapple_mca_suspend_late()/apple_mca_resume_early()when already runtime-suspended.char name[16]buffer inmca_request_dma_channel()instead ofdevm_kasprintf(), validates channel presence inmca_pcm_new(), and allocates/releases ADMAC channels per stream inmca_pcm_open()/mca_close()viasnd_dmaengine_pcm_close_release_chan().arm64: dts: apple: t8103: parent ps_fpwm0..2 under ps_sio(e5a7623da91c):ps_fpwm0,ps_fpwm1, andps_fpwm2underps_sioinarch/arm64/boot/dts/apple/t8103-pmgr.dtsi, matching t600x, t8112, t602x, t6030, t6040, and t8140 sopwm_apple(includingled_pwm_shutdown()on reboot) keepsps_sioup while active and letsps_fpwm*andps_siosuspend together when idle.dmaengine: apple-sio: hold runtime PM across issued transfers(457a940bfff4):sio_device_config()drops its runtime PM reference after configuring a channel, sosio_issue_pending()can run after the 500 ms autosuspend window or whilesio_suspend()is in flight.tx_rpm_held) acquired viapm_runtime_get_if_active()when SIO is active or deferred tosiochan->issue_wq(pm_runtime_resume_and_get()), guardssio_fill_in_{old,ring}_locked()against stopped firmware, includestx_rpm_heldand!list_empty(&siochan->vc.desc_issued)insio_chan_busy(), flushesissue_wqbeforeterminate_wqinsio_synchronize(), and adds KUnit coverage (sio_issue_pending_after_autosuspend_testandsio_sleep_busy_testindrivers/dma/apple-sio-boot-test.c).dmaengine: apple-sio: harden runtime PM transfer lifecycle, teardown, and error reporting(4295db09de60):sio_firmware_active()(!READ_ONCE(sio->rpm_stopped) && !READ_ONCE(sio->asleep)), and releasestx_rpm_heldviasio_take_tx_pm_put_locked()/sio_put_tx_pm()acrosssio_handle_issue_ack(),sio_process_report(),sio_stop_quiet(),sio_clear_idle(),sio_terminate_all(), andsio_terminate_work()oncecurrent_tx,retired, non-idleringstate, andpendingACKs are clear.READ_ONCE(siochan->host->removing)undervc.lockbeforevchan_issue_pending()insio_issue_pending()(and insio_prep_dma_cyclic()), so late issue calls after teardown admission closes neither move submitted descriptors todesc_issuednor invokevchan_cookie_complete()to rearmvc.task.sio_remove(), closes admission (WRITE_ONCE(sio->removing, true)synchronized under each channel'svc.lock), cancelsissue_wq, flushesterminate_wqbefore and after unregistering the DMA provider, quiesces runtime PM (pm_runtime_dont_use_autosuspend()+pm_runtime_barrier(), whilesio_suspend()refuses new suspends onceremovingis set), and shuts down / disables RTKit mailbox RX (apple_rtkit_shutdown()whensio->arraysis present, plusapple_rtkit_mailbox_off()) before the final drain andtasklet_kill(&siochan->vc.task).vc.desc_issueddescriptors withDMA_TRANS_ABORTEDon runtime resume /pm_runtime_get_if_active()failure,asleep, or teardown, and records each aborted cookie alongside its exactu32residue in a bounded 16-entry FIFO ring (error_cookies) preserved across subsequent healthy transfers until cookie reuse or channel release.tools/asahi: add apple-sio runtime PM issue lifecycle host test(e9cfcbd1b8fb):apple-sio.cfunctions into a host runtime PM,virt-dma, and RTKit model registered intools/asahi/run-host-tests.py, covering post-autosuspend issue, mid-suspend issue (bothdesc_issuedrefusal and concurrentapple_rtkit_sleep_stop()race), cancel beforeissue_wq, ring/idle handover withclear_idle(),commit_stop,asleep, multi-residueDMA_ERRORretention across healthy transfers, lateissue_pending()afterremovingcloses, and activesio_remove()quiescingapple_rtkit_shutdown()->apple_rtkit_mailbox_off()before finaltasklet_kill(), plus 10 mutations and the pre-fixa8d2f37caf89baseline.Merge branch 'main' into feat/apple-sio-mca-runtime-pm(df82585852cb):#3195's held-transfer lifecycle (sio_end_tx(),sio_release_tx(),sio_sync()):sio_terminate_work()resumes SIO aroundsio_end_tx()and hands its reference to a next transfer started without one;sio_release_tx()dropstx_rpm_heldwith the last transfer and aborts issued descriptors when firmware is stopped or removing;sio_stop_quiet()holds runtime PM and releasestx_rpm_held;sio_sync()flushesissue_wqfirst and killsvc.taskbefore returning so callbacks from aborted descriptors complete beforedmaengine_synchronize()returns; updates KUnit andsio-rpm-issue-testsfixtures forsync_lock/sync_waitand held-transfer fields.dmaengine: apple-sio: let a stale tag not hold the SIO up at runtime(daf99763dd95):sio_tags_live()(!bitmap_subset(tags->allocated, tags->stale, SIO_NTAGS)undertags->lock) so timed-out stale tags no longer permanently blocksio_suspend(), while live in-flight tags still return-EBUSY.sio_release_stale(sio)insio_resume()immediately after restarting SIO firmware from reset before clearingsio->rpm_stopped.dmaengine: apple-sio: close admission on suspend stop/return double failure(0e6b27f5a2a8):sio->rtk_unavailable = truewhen bothapple_rtkit_sleep_stop()and immediateapple_rtkit_sleep_return()fail insio_suspend()orsio_suspend_late(), preventing descriptor issue on theRPM_ACTIVEreturn path while RTKit is unavailable.sio_prep_dma_cyclic(),sio_device_config(),sio_set_idle(), andsio_issue_pending()/sio_issue_work()(aborting queued descriptors withDMA_TRANS_ABORTED) whilertk_unavailableis set, and reopens admission only if a confirmed RTKit restart runs insio_resume()orsio_resume_early()(clearingrtk_unavailablealongsiderpm_stopped/asleep; note that after a non--EBUSY/-EAGAINruntime-suspend error, Linux runtime PM recordspower.runtime_error, so recovery viasio_resume()is not triggered automatically without clearing the runtime PM error or running system-sleepsio_resume_early()).sio_rtk_unavailable_rejects_issue_testindrivers/dma/apple-sio-boot-test.c) and host model coverage (double-failure rejection whileRPM_ACTIVEand mid-suspend, failed restart staying closed, confirmed restart reopening, andadmit-after-suspend-double-failmutation).soc: apple: sleep: restore PMGR domains when an engine reset fails(4a086af941a9):sleep_engine_reset_power()indrivers/soc/apple/sleep.cto save PMGR domain controls upfront and roll back every touched domain (including the domain whose poll timed out) in reverse order before restoring DART state, verifying settled state while preserving the original error.tools/asahi/sio-engine-reset-tests.py(registered intools/asahi/run-host-tests.py) covering the full sequence and injected failures across all nine reset and power-on poll points.Merge branch 'main' into feat/apple-sio-mca-runtime-pm(06a014735072):origin/main(0bc45c54fbe6), resolving the two conflicts indrivers/dma/apple-sio.cwith the T6030commit_no_cpu_down/commit_early/rx_heldupdates insio_probe()andsio_resume_early().Evidence
0bc45c54fbe6, 10 files+2835/-181vsorigin/main):ddf95fc58b08f70a70513f30c73f7fcc8d17c46f—dmaengine: apple-sio: stop and restart SIO firmware across runtime PMa8d2f37caf8953f54470eb4d54bfb21e903846d3—ASoC: apple: mca: enable runtime PM on audio_p and allocate ADMAC channels on opene5a7623da91c9d112cb890674b2b62cde6e17158—arm64: dts: apple: t8103: parent ps_fpwm0..2 under ps_sio457a940bfff4574219bc6954009243286010e9ae—dmaengine: apple-sio: hold runtime PM across issued transfers4295db09de607ec485b815b20ce963690f209c54—dmaengine: apple-sio: harden runtime PM transfer lifecycle, teardown, and error reportinge9cfcbd1b8fbd2219d23cca242e90db8a290bf37—tools/asahi: add apple-sio runtime PM issue lifecycle host testdf82585852cbe7560dc22f356f90762d19048877—Merge branch 'main' into feat/apple-sio-mca-runtime-pmdaf99763dd959d8647803d50722150aba381cf42—dmaengine: apple-sio: let a stale tag not hold the SIO up at runtime0e6b27f5a2a8e6acddf027c53574e84d3a794548—dmaengine: apple-sio: close admission on suspend stop/return double failure4a086af941a9269d04e4cef19e207092aa5e75b8—soc: apple: sleep: restore PMGR domains when an engine reset fails06a0147350726f28bd672915d8c6ae21fad5c74a—Merge branch 'main' into feat/apple-sio-mca-runtime-pmarm64 LLVM=1) at06a014735072:W=1object build (defconfig+asahi.config,-d RUST): 0 errors, 0 warnings acrossdrivers/soc/apple/sleep.o,drivers/dma/apple-sio.o,sound/soc/apple/mca.o,drivers/dma/apple-admac.o,drivers/gpu/drm/apple/audio.o, anddrivers/pwm/pwm-apple.o.linux-j313,linux-j713, andlinux-j716ckernel builds (7.3.0+): exit 0 (Image.gz,dtbs,modules.tar.zst).scripts/dtc/apple-dt-check.sh origin/main HEAD: 5 changed DTBs checked with their families;base: make rc=0, 294 warning lines, 5 of 141 DTBs checked;head: make rc=0, 294 warning lines, 5 of 141 DTBs checked;new warnings: 0, removed: 0.arm64 LLVM=1) at06a014735072:scripts/ci/apple-kunit.py run macaudio apple-sio:macaudio(sound/soc/apple/macaudio.kunitconfig,apple-speaker-*): 84/84 passed.apple-sio(drivers/dma/apple-sio.kunitconfig): 45 passed, 1 skipped (apple_g17_rx_util_min_test, needsCONFIG_UCLAMP_TASK).drivers/pwm/pwm-apple.kunitconfig: 40/40 passed (pwm-apple).tools/asahi/run-host-tests.py) at06a014735072:--only sio: 70/70 passed (includingsio-engine-reset-tests,sio-rpm-issue-tests13 runs covering all 11 mutations anda8d2f37caf89control).--only dcpaud: 15/15 passed.--only apple-pwm-pm: 2/2 passed.scripts/checkpatch.pl --strict --git origin/main..HEAD): 0 errors across all PR commits.J313(M1 MacBook Air,T8103,27.2firmware) at06a014735072in composite807c3bbf2263(origin/maind3de772ac0c1+06a014735072, one-shot trial Stage 2 witht8103-j313.dtb, default cmdline):ps_fpwm0..2andps_siowithpower-domains;apple-sioautosuspend500 ms,control=auto.suspended: playing zeros (aplay,3 s, twice, rc0) tohw:USBC,0(dcp-dp-audio, dock monitor only) wokeapple-siofromsuspendedwithapple-sio: RTKit: Initializingon each open, advancedruntime_active_time1257 -> 8500 ms, readactiveimmediately after close, and returned tosuspendedwithin2 sin both rounds; repeated after deep S2R (8500 -> 15706 ms, same pattern).arecord -D hw:AppleJ313HPAI,03-channel float 48 kHz,3 sto/dev/null): rc0before and after sleep.3/3docked (rtcwake -d /dev/rtc1 -m mem -s 20,suspend_statssuccess 0 -> 1per cycle,fail 0, 16 MB RAM integrity PASS,0Oops/WARN/SError);speakerguardd-v2-switchtest.servicefailed identically on a separate newer-mainbuild without#3359's DT/MCA changes while passing on the stock daily baseline.0e6b27f5a2a8(composite trial kernels overorigin/main429e7e15f122):M1 MacBook Air,T8103) composite (origin/main429e7e15f122+#3335,#3506,#3508,#3269,#33590e6b27f5a2a8,#3289;3/3.o/.texthashes byte-identical inapple-sio.o,sleep.o, andmca.ovs single-PR merge on429e7e15f122; GRUB one-shot, default cmdline, docked CalDigit TS5 +DP-23840x2160@120, AC 100%):0failed units,0AVC denials,5err+lines identical to default boot;arecord hw:0,0(3chFLOAT_LE48 kHz, 3 s =1,728,044bytes) and10/10capture cycles with>500 msgaps passed withsio/admac/pwmruntime status returning tosuspended;kbd_backlight0 -> 255 -> 0pwmactive/suspended;0dmesgSIO/ADMAC/MCA errors;1x deepS2R (rtcwake -d rtc1 -m mem -s 30, ext display DPMS off first) passed (success=1, wakeNUB.SPMI0Sw3IRQ; right after deep S2R, post-resume ISPv4l2-ctlcapture hung with cause unassigned).M4 MacBook Air,T8132, 27.2 firmware) composite (origin/main429e7e15f122+#33590e6b27f5a2a8,#35606c38b2268568,#349144d22bf36fb3,#371727ffbe1aa92a,#32970378182e01b8,#3300241b8646ccdf; Linux7.3.0, GRUB one-shot + one-shot Stage 2 carrying compositet8132-j713.dtb, default cmdline, battery 50% to 43%, no speaker playback, no external display attached):apple-sio3ade00000.dma-controllerstaysruntime_statusactive(runtime_suspended_time0,stop_at_commit); bothapple-admaccontrollers (393300000,393800000) aresuspendedat idle;arecord -D hw:0,0 -f FLOAT_LE -r 48000 -c 3 -d 3(built-in high-quality microphone, 3 runs before sleeps and 1 after both) cycles393300000suspended -> activefor the stream and-> suspendedwithin 1 s of stop, capturing144000frames per run with410396–410397non-zero samples, peak0.0002,0NaN;rtcwake -m freeze -s 20(s2idle) andrtcwake -m mem -s 25(deep sleep) both resumed cleanly (suspend_statssuccess1and2,fail0) with SIOactive, ADMACssuspended, and capture repeating unchanged;0SIO/MCA/ADMAC error lines,0failed units,0AppArmor denials,0Oops/WARN.16-inch M5 Max,T6050) composite boot sanity (origin/main429e7e15f122+#3409,#3560,#3651,#3717,#33590e6b27f5a2a8,#3289; Linux7.3.0, default cmdline, default Stage 2b0a2f222b5a9): boots to desktop;apple-sioregistered (/sys/bus/platform/drivers/apple-sio) withapple-sio/apple-mcaunbound (sourcet6050-j716c.dtbdefinessio: dma-controller@505e00000withstatus = "disabled"; the booted0e6b27f5a2a8DT was not archived to distinguish a disabled node from an omitted one;apple-admac293800000.dma-controllerand2d3200000.dma-controllerprobe);sleep.capple,seq-commit-siopresent and2x pm_test=devices+1x pm_test=platformresumed cleanly;0apple-sio/apple-admac/mcaerrors or warnings;1baseline failed unit (aurora-peripherals.service),0failed user units,0LSM denials,0Oops/BUG/WARN/SError/GPU faults (4kernelerr+lines frommainbase).e9cfcbd1b8fb(retained for baseline context):mainfe9af4b604784withe9cfcbd1b8fbd, alongside iio: aop_temp, aop_las: run board temperature and lid angle reports on demand with idle stop #3409 and serial: apple-dockchannel: stop idle console drain timer, back off RX, and add sleep PM #3335): clean boot, 0 failed units, 0dmesgerrors,speakerguardd-v2active (Speaker Playback Mux=Secondary), both audio ADMACs (513300000.dma-controller,513800000.dma-controller) entersuspended(usage=0) at idle,apple-sio(429e00000.dma-controller) stays active (stop_at_commit), settled battery idle3.52–3.59 W(disp_bl=100,kbd_bl=64).e9cfcbd1b8fb:apple-sio(3ade00000,stop_at_commit=true) stayedactive;apple-admac(393300000/393800000) cycledsuspended -> active -> suspendedacross a 2 s 3-chFLOAT_LEarecordmic capture (hw:0,0,96,000frames,266,397non-zero samples, peak0.00169,0NaNs) and remained clean across 3×s2idle;0SIO/MCA/ADMAC errors.e9cfcbd1b8fb: internal HPAI mic (hw:AppleJ313HPAI,0, 3-ch float, 2 s =96,000frames,~288k/288knon-zero, peak7e-4, rms1.35e-4,0NaN/Inf, both before and afterdeepsleep) and jack mic (hw:AppleJ313,0, 2-ch S16,96,000frames) exercised cleanly;apple-admac,apple-mca, and AOP DMA cycledsuspended -> active -> suspendedwithin 5 s;apple-siostayedsuspendedacross capture and sleeps;0SIO/ADMAC/MCA errors or leaks. In batched candidateac44bee46ee4(main9e38a276dcb4): live DT showsps_fpwm0..2parented underps_sio,236400000.sioand236408000.mboxstayedsuspendedwithspeakersafetydholdingpcmC1D2c(0-62/-ETIME), stoppingspeakersafetyddropped all 5 devices tosuspendedand 14 power domains (sio_cpu,dpa0,mca0..5,sio_adma,audio_p,uart_p,spi_p,fpwm0,fpwm2) tooff-0, andkbd_backlight0 -> 128 -> 0ran before and afterdeepS2R with0SErrors.a8d2f37caf89: boot + dockeddpaudio1wake (~2 ms wake, 0-62/-ETIME); all 5 devices reachedsuspendedand all 9 PMGR domains (sio_cpu,dpa0,mca2,sio_adma,audio_p,uart_p,spi_p,sio,sio_busif) dropped tooff-0with all PCMs closed (macsmc_hwmonHeatpipe Power3,248.1 -> 3,171.2 mW); real mic capture and speaker playback passed with 0 errors.