Repository navigation
media: apple: ave-dma: bind every SoC's apertures and let the domain idle - #3871
Conversation
…idle The auxiliary DMA aperture driver matched only apple,t6000-ave-dma, so the T8103 node that linux #3551 enabled stayed unbound. Its PMGR sync_state() then stayed pending and held ps_venc_sys on for good, and J313 deep sleep stopped waking. On T6000 the driver binds but has no runtime PM, so genpd counts the device as active and ps_venc_sys never goes off there either. The encoder firmware needs that domain power-cycled between sessions. Match the generic apple,ave-dma compatible that every node carries, and enable runtime PM without ever resuming the device. The apertures only report faults through the interrupt they share with the encoder DARTs, which can only fire while the domain is on, so the encoder and its DARTs alone decide when ps_venc_sys is powered. The DT nodes stay enabled. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
erikwb
left a comment
There was a problem hiding this comment.
Verdict: MERGE at e5dd49e7ab07
Blockers: none
Checked: no Apple material, no chip/board/firmware gates (matches generic apple,ave-dma), J313 M1 Air (T8103) hardware row at e5dd49e7ab07, CI green (apple-build, KUnit ave, host-tests passing; pr-text/readiness queued)
Evidence
Tested on J313 (M1 MacBook Air, T8103) at e5dd49e7ab07 with the unmodified t8103-j313.dtb (ave_dma enabled, CONFIG_VIDEO_APPLE_AVE=m):
- Clean boot, 0 failed systemd units,
boot_idunchanged (6e135ce4-e83c-4984-911a-c731f6ffcac9). 267020000.dmabound toapple-ave-dmawithpower/runtime_status = suspendedandvenc_sysatoff-0inpm_genpd_summary.rtcwake -d /dev/rtc1 -m mem -s 10: 2/2 PASS (CYCLE=1 RC=0 ELAPSED=11s,boot object resumes 0 -> 1;CYCLE=2 RC=0 ELAPSED=14s,boot object resumes 1 -> 2), 0 errors/warnings.rmmod apple_ave_dma && modprobe apple_ave_dma: rebinds cleanly withruntime_status = suspendedandvenc_sysstayingoff-0.
Non-blocking follow-up note: apple_ave_dma_irq() (drivers/media/platform/apple/ave/apple-ave-dma.c:28) unconditionally reads dma->base + AVE_DMA_ERROR_STATUS on IRQF_SHARED (shared with ave_dart1). Under CONFIG_DEBUG_SHIRQ=y (e.g. free_irq() on module unload while ps_venc_sys is off) or a spurious shared IRQ when idle, that read would hit a powered-off block; worth guarding in a follow-up if DEBUG_SHIRQ testing is needed.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict Request changes at e5dd49e7ab07.
drivers/media/platform/apple/ave/apple-ave-dma.c:30 needs a power-safe shared IRQ path. The J313 row confirms venc_sys can be off while this handler is installed. aurora_defconfig enables CONFIG_DEBUG_SHIRQ, and kernel/irq/manage.c invokes the shared handler during IRQ teardown even when the hardware did not signal an interrupt. The handler immediately reads the powered-off aperture in that path.
Please keep fault handling working during encoder activity and ensure the handler can return before MMIO when the aperture is off or IRQ teardown has started. The DMA device stays logically suspended even during real encoder activity, so its runtime-PM status alone cannot distinguish those cases. The generic compatible matches the affected DT nodes, and the exact-head J313 deep-sleep result covers the intended idle behavior.
With the device kept runtime-suspended, ps_venc_sys can be off while the shared interrupt handler is installed. A sharer's or a spurious interrupt, or the extra call CONFIG_DEBUG_SHIRQ makes in free_irq(), would then read a powered-off block. The device's own runtime-PM status cannot tell an idle encoder from a running one, since it stays suspended either way. Track the domain through its genpd on/off notifications instead, registered while runtime PM is still disabled and the domain is known to be on, and wait out a handler already past the check before the domain goes off. Stop reading before free_irq() too. Fault reports still come through while the encoder powers the domain. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Addressed at
Build: arm64 @erikwb, could you repeat the J313 row at |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Rechecked f1d42e2 against the shared-IRQ finding. The handler now skips MMIO after PRE_OFF, and the notifier drains hard handlers before genpd powers the domain down. The genpd core sends ON again if power-off fails. The last devres action sets stopping before free_irq invokes the DEBUG_SHIRQ probe. Fault reporting remains active when the powered encoder uses the shared line. This addresses my code review. Landing still needs the refreshed J313 idle/unload/encode/wake row, one T600x encoder control, and relevant CI.
RyanTheTide
left a comment
There was a problem hiding this comment.
The teardown guard covers DEBUG_SHIRQ. On arm64 with threadirqs, irq_setup_forced_threading moves this IRQF_SHARED handler into thread_fn. If that thread passes the powered check and is preempted before readl, PRE_OFF clears powered and synchronize_hardirq returns false with the thread still active. The callback ignores that result and the domain can power off before the thread resumes into readl. I reproduced the interleaving with the two exact driver functions and a stubbed IRQ core (one MMIO read after off). Please make the powered check and MMIO mutually exclusive with PRE_OFF in the threaded case too.
synchronize_hardirq() only waits for hard interrupt handlers. Under threadirqs the shared handler runs in a thread, which can be preempted after its powered check and resume into a read once ps_venc_sys is off. Hold a raw spinlock in the handler from the check through its last register access, and take it in the PRE_OFF/ON notification and the teardown action, so neither can pass a reader in either case. The registers are copied under the lock and the fault is printed after. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Fixed the threadirqs interleaving at Build: arm64 @erikwb, the J313 row is now wanted at |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Rechecked the threadirqs follow-up at 6e5f922. The raw lock now serializes the complete MMIO transaction with PRE_OFF and teardown for both hard and threaded handlers. No regulator or domain transition runs under the handler lock. The log runs after unlock, and genpd ON rolls the flag back on a failed power-off. This addresses the remaining code finding. The exact-head J313 wake/unload/encode and T600x encode controls are still in flight.
|
J313 (M1 Air) on aurora-silicon/linux main 5a870d0 (with #3870 and #3871)
Deep (rtcwake -d /dev/rtc1 -m mem -s 90): PASS
s2idle, run after deep (rtcwake -m mem -s 30): PASS
Before sleep: no "sync_state() pending" lines. apple_sep loads by itself on main and was bound at 4.4 s. ave-dma: apple_ave_dma was not loaded at boot. rmmod rc 1 (not loaded), modprobe rc 0, but no device bound and no ave-dma lines in dmesg. This DT seems to have no enabled ave-dma node, so the rebind with venc_sys off couldn't be checked here. New warnings vs the known-good kernel: "PS fpwm1: Failed to reach power state 0xf" (after pm_test and after each wake), apple-dcp "AFK[ep:20]: failed to extract init props: -2", one drm in-fence not signalled after 1000 ms, and apple_sep identity-keybag provisioning failed. |
What: Fix the root cause of the J313 (M1, T8103) deep-sleep wake regression from #3551. ewb's split showed
&ave_dmaalone causes it: disabling only that node passes S2R.apple-ave-dmamatched onlyapple,t6000-ave-dma, so the T8103 node (apple,t8103-ave-dma,apple,ave-dma) never bound. PMGRsync_state()then stayed pending and heldps_venc_syson permanently. This PR matches the genericapple,ave-dmathat every node carries and enables runtime PM without ever resuming the device. The apertures only report faults, through the interrupt they share with the encoder DARTs, so only the encoder and its DARTs decide whenps_venc_sysis on. The same change also letsps_venc_syspower off on T6000/T6001/T6002, where the driver bound with no runtime PM and so held the domain on. That was the "power cycle the firmware needs between sessions" that d8e9754 worked around by disabling the node. The DT nodes stay enabled.ps_venc_sysis on. It tracks this with genpdGENPD_NOTIFY_ON/PRE_OFF, registered while runtime PM is still disabled, and holds a raw spinlock shared with the PRE_OFF notification from the check through the last register access (threadirqs too, CX review). Astoppingflag set beforefree_irq()covers the extra callCONFIG_DEBUG_SHIRQmakes there (Dj's review). This fixes media: apple: ave-dma: guard the shared IRQ handler's register read when ps_venc_sys is off #3875.aes/jpg/venc_*. The two PRs are independent.ave-dmanodes. pmdomain: apple: pmgr-pwrstate: do not gate parent domains at sync_state #3829's pmgr parent guard has no SoC gate, so it already covers T8103.Tested: J313 M1 Air (T8103) at
e5dd49e7(ewb, unmodified main DTB): 2/2 S2R pass (boot object resumes 0 -> 1 -> 2),apple-ave-dmabound runtime-suspended,venc_sysoff-0 idle, rmmod/modprobe clean. Head6e5f9224adds the IRQ power guard (genpd notifier + raw spinlock shared with PRE_OFF, so threaded handlers are covered too): arm64W=1build withCONFIG_DEBUG_SHIRQ=yclean,checkpatch --strictclean. J313 row at6e5f9224: requested.Risk: two-way · M1 (J313, J293, J274, J456, J457) and M1 Pro/Max/Ultra (T6000/T6001/T6002). This only changes when
ps_venc_syscan power off: it binds one fault-reporting driver and lets its domain idle. Reverts in one commit.Not yet: J313 row at
6e5f9224(S2R +rmmod/modprobewith DEBUG_SHIRQ + one encode session) (ewb). T600x encoder row (any M1 Pro/Max).