Repository navigation
media: apple: isp: keep the T8140 camera working across suspend - #229
Merged
Merged
Conversation
The driver switches the power domains of resident firmware through runtime PM alone, because the firmware does not start again once they have been off. Their virtual genpd devices still take part in system sleep, though: genpd counts them as suspended in the noirq phase of suspend, switches the domains off when nothing else holds them, and switches every one of them back on in the noirq phase of resume. The firmware is stopped for system sleep, so on T8140 the CPU core domains of the stopped coprocessor fail to reach the active state on every resume, and genpd turns them off again when the resume completes: PS isp_cpu_core0: Failed to reach power state 0xf (now: 0xf000b4f) PS isp_cpu_core1: Failed to reach power state 0xf (now: 0xf000b4f) Mark the domain devices as syscore devices for as long as they are attached, so that system sleep leaves the domains to runtime PM. The Apple ACIO driver does the same for the domains of its coprocessor. SoCs whose firmware is started for each stream are unchanged. On J700 (T8140) with this change, suspend-to-idle with a PMU RTC wake no longer logs the errors; the camera is still stopped for sleep. Fixes: 62b659e ("media: apple: isp: Keep resident firmware running between streams") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
Resident firmware is stopped for every system sleep, because its power domains used to go off under it. It does not start again, so on T8140, where suspend-to-idle now works, the camera is unavailable after the first suspend until the next boot, and every VIDIOC_STREAMON fails with -EIO. System sleep now leaves those domains to the driver, which keeps them on while the firmware runs. Keep the firmware running, idle, across suspend. The stream is stopped before the system sleeps and restarted when it resumes, as before, with its buffers kept. The awake path, which keeps the NVMe controller's link domains on across sleep, would not be enough here: genpd honours it only for a domain that was on when it was registered, and nine of the fourteen ISP domains are first switched on by this driver. Keeping the domains on has a cost. With the display off and the firmware idle, the J700 draws 30 to 50 mW more than with the firmware stopped and its domains off (3.553 W against 3.523 W, and 3.564 W against 3.512 W, means of 300 and 360 samples). The idle firmware raised no interrupt in 30 seconds, and the ISP DARTs, which are not locked, are reset and restored by their own resume callback while it is idle. SoCs whose firmware is started for each stream are unchanged. Hibernation still stops the firmware: the image is restored by another kernel, and firmware left running would go on using the memory of the kernel that started it. Tested on J700 with a PMU RTC wake: five suspend-to-idle cycles of 30 and 90 seconds. 1080p NV12 capture runs at 30 fps before and after each cycle. A capture left running across two of the cycles resumes by itself at 30 fps and completes all its frames. No ISP, power domain or DART errors are logged, and the ISP domains stay on throughout. Fixes: 62b659e ("media: apple: isp: Keep resident firmware running between streams") Assisted-by: LLM Signed-off-by: Ryan Murray <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
media: apple: isp: keep the T8140 camera working across suspend
Since suspend-to-idle works on the MacBook Neo (J700, T8140), the camera has been unusable after the first sleep until
the next boot: every
VIDIOC_STREAMONfails with-EIOand the driver logsfirmware was stopped and cannot be restarted before the next boot. Every resume also loggedPS isp_cpu_core0/1: Failed to reach power state 0xf.The T8140 ISP firmware is loaded by the bootloader and can only be started once per boot. The driver stopped it for
every system sleep because its power domains would otherwise go off under it. This series keeps the firmware running,
idle, across suspend instead, with its domains on.
media: apple: isp: Keep system sleep off resident firmware's domainssystem sleep: genpd switched the domains off in the noirq phase of suspend and back on in the noirq phase of
resume. With the coprocessor stopped, its CPU core domains could not reach the active state, which is where the
resume errors came from.
runtime PM. The Apple ACIO driver (
drivers/thunderbolt/apple.c) does the same for its coprocessor's domains.media: apple: isp: Keep resident firmware running across suspend.suspendno longer stops resident firmware. The stream is stopped before sleep and restarted on resume, asbefore, and its buffers are kept.
.freeze/.poweroff) still stops the firmware, because another kernel restores the image.Why not the awake path or a firmware restart
domain that was already on when it was registered. Five ISP domains were on at boot (
isp_sys,isp_cpu,isp_cpu_core0/1,isp_fe). The other nine (dprx,secure,sts0/1,pearl,be,clr,cvd,cvm) arefirst switched on by this driver, so genpd would still switch them off in the noirq phase.
domains cycled. Even if it could be restarted, the same domains would have to stay on.
Cost
measured while the machine sleeps.
.suspendtakes about 1 µs when idle and 13 ms with a stream open; it used to take 22–29 ms to stop thefirmware.
Other notes
firmware is idle, and no DART fault was seen.
Testing (MacBook Neo J700)
The test kernel was the public tip
90c6f8c7564bwith its default config, plus this series. OnlyLOCALVERSIONchanged.
Failed to reach power state; camera stopped for sleep as beforexHC error in resume ... Reinit(USB recovers);Pipehandler lock not acked;Opcode 0x0c52 failed: -112at suspend entry, also seen on the tip with the ISP driverunbound.
Other Apple machines
firmware running.
.suspendand the new.freeze/.poweroffdo exactly what the old shared callbackdid.
S_PARM15/30 and the low-light control behave as on the tip, andno ISP errors are logged.
the M2.
Checks
W=1builds of the ISP driver, every object recompiled, with the J700 and M2 configs:isp-ipc.con the base and on every commit.checkpatch.pl --strict: only theAssisted-byformat warning.Draft until reviewed.
🤖 Generated with Claude Code