Skip to content

media: apple: isp: keep the T8140 camera working across suspend - #229

Merged
RyanTheTide merged 2 commits into
aurora-wipfrom
j700/isp-s2idle
Oct 9, 2026
Merged

RyanTheTide merged 2 commits into
aurora-wipfrom
j700/isp-s2idle

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

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_STREAMON fails with -EIO and the driver logs firmware was stopped and cannot be restarted before the next boot. Every resume also logged PS 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.

  1. media: apple: isp: Keep system sleep off resident firmware's domains
    • The driver already switches these domains through runtime PM alone. Their virtual genpd devices still took part in
      system 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.
    • The domain devices are now marked as syscore devices while they are attached, so system sleep leaves the domains to
      runtime PM. The Apple ACIO driver (drivers/thunderbolt/apple.c) does the same for its coprocessor's domains.
    • On its own, this removes the resume errors; the camera is still stopped for sleep.
  2. media: apple: isp: Keep resident firmware running across suspend
    • .suspend no longer stops resident firmware. The stream is stopped before sleep and restarted on resume, as
      before, and its buffers are kept.
    • Hibernation (.freeze/.poweroff) still stops the firmware, because another kernel restores the image.

Why not the awake path or a firmware restart

  • The awake path is not enough. It keeps the NVMe link domains on across sleep, but genpd honours it only for a
    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) are
    first switched on by this driver, so genpd would still switch them off in the noirq phase.
  • A restart is not available. The firmware never completes its first handshake once it has been stopped and its
    domains cycled. Even if it could be restarted, the same domains would have to stay on.

Cost

  • Measured with the display off and the battery not charging, sampling SMC power at 2 Hz.
  • The J700 draws 30–50 mW more with the firmware idle and its domains on than with it stopped and the domains off:
Run Firmware running Firmware stopped (driver unbound) Difference
1 (300 samples each) 3.553 W (sd 0.060) 3.523 W (sd 0.070) 30 mW
2 (360 samples each) 3.564 W (sd 0.080) 3.512 W (sd 0.068) 52 mW
  • This is our estimate of the extra power in suspend-to-idle, where these domains used to be off. It cannot be
    measured while the machine sleeps.
  • Suspend itself gets faster:
    • The ISP's .suspend takes about 1 µs when idle and 13 ms with a stream open; it used to take 22–29 ms to stop the
      firmware.
    • Restarting an open stream on resume takes 160 ms.

Other notes

  • The idle firmware raised no interrupt in 30 seconds.
  • The three ISP DARTs are not locked, so their own resume callback resets and restores them. That happens while the
    firmware is idle, and no DART fault was seen.

Testing (MacBook Neo J700)

The test kernel was the public tip 90c6f8c7564b with its default config, plus this series. Only LOCALVERSION
changed.

Test Result
1080p NV12 capture before sleep 30.00 / 30.01 fps
Suspend-to-idle with PMU RTC wake, camera idle: 2 × 30 s, 1 × 90 s all resumed; 30.01 fps × 2 streams after each
Suspend-to-idle during a running capture (2 × 30 s) the capture resumes by itself at 30.0 fps and completes every frame (3600 and 2100 frames, rc 0); fresh streams 30.0 fps afterwards
ISP, power domain and DART errors none; the ISP domains never went off (genpd idle time unchanged across all five cycles)
Everything else after each resume NVMe live (1.8–2.0 GB/s), Wi-Fi associated with 0 % loss, BT powered, eDP connected with the CRTC active, 2 playback / 4 capture PCMs, no failed units; 0 WARN, Oops or SError. After the last cycle: glmark2 and vkcube run, PMC frequency floor honoured (terrain 160 fps)
Resume timing noirq resume 13.8–14.0 ms, early resume 0.5–0.6 ms, devices resume 2.83–3.03 s (USB re-initialisation); unchanged from the tip
Unbind, then rebind unbind clean, with every ISP domain off afterwards. Rebind fails with -110, as expected for firmware that has been stopped. No WARN
Commit 1 alone, one 30 s suspend-to-idle no Failed to reach power state; camera stopped for sleep as before
  • Known noise, also present on the unmodified tip:
    • xHC error in resume ... Reinit (USB recovers);
    • Pipehandler lock not acked;
    • intermittent Bluetooth Opcode 0x0c52 failed: -112 at suspend entry, also seen on the tip with the ISP driver
      unbound.
  • Hibernation was not tested; that path is the previous suspend code.

Other Apple machines

  • Only SoCs with resident firmware (T8140) take the new paths: the syscore marking and the suspend that leaves the
    firmware running.
  • For the other ISP generations, .suspend and the new .freeze/.poweroff do exactly what the old shared callback
    did.
  • One-shot boots with the series, without suspend:
    • M2 MacBook Air (T8112): Fedora Asahi 7.1.13 default config.
    • M1 Pro MacBook Pro (T6000): Fedora Asahi 7.0.13 default config, with the battery driver symbol renamed for 7.1.
  • On both:
    • The camera streams 1080p at 29.98–29.99 fps, S_PARM 15/30 and the low-light control behave as on the tip, and
      no ISP errors are logged.
    • Display, inputs, Wi-Fi, Bluetooth, battery and vkcube work.
    • No new kernel warning or error lines against the stock kernel, apart from the known tas2764 I2C bus renumbering on
      the M2.

Checks

  • Per-commit W=1 builds of the ISP driver, every object recompiled, with the J700 and M2 configs:
    • J700 config: 0 warnings.
    • M2 config: the same two pre-existing fortify warnings in isp-ipc.c on the base and on every commit.
  • Full J700, M2 and M1 Pro kernel builds: no compiler warnings.
  • checkpatch.pl --strict: only the Assisted-by format warning.
  • No DT or binding changes.

Draft until reviewed.

🤖 Generated with Claude Code

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]>
@RyanTheTide
RyanTheTide merged commit f215db0 into aurora-wip Oct 9, 2026
@DjDeveloperr
DjDeveloperr deleted the j700/isp-s2idle branch October 12, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant