Skip to content

media: apple: isp: leave the coprocessor control word at power-down - #1918

Merged
RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-t8132-isp-macos-stop
Nov 21, 2026
Merged

RyanTheTide merged 3 commits into
aurora-silicon:integration/aurorafrom
IronsideXXVI:j604-t8132-isp-macos-stop

Conversation

@IronsideXXVI

@IronsideXXVI IronsideXXVI commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

On T8132, the camera's first stream after system boot failed its ISP firmware boot once. The next open streamed. Reading the ISP's MMIO in two macOS camera sessions on a J604 (14" MacBook Pro M4) showed that macOS never writes the coprocessor control word 0 when it powers the ISP down. This driver wrote it 0 at every power-down on everything but T8140, where the sleep engine's restore already needs the run bit kept.

Reworked on 2026-11-20 as asked in review: there is no module parameter and no per-chip flag any more. The control word is left alone at power-down on every ISP generation. The T6040 family's boot check (a coprocessor that never ran) now also accepts the start word (0x10) that our own power-down left; the boot still writes 0 then 0x10 as for a fresh start. Any other word, or a non-zero word before our first power-down, still refuses as before. Older generations go through the full coprocessor reset at boot, so the kept word does not change their boot.

Measured on the J604 (MEASURED 2026-11-14) with the same behaviour in our kernel series (the parameter was on by default there, so T8132 ran exactly the code path this patch makes unconditional), on a true first open after boot (no earlier ISP boot in that boot's log): on three of three boots (our kernels 1.908 twice and 1.909 once; on 1.909 with the kernel's other first-open change switched off, so this one was tested alone), the first open streamed 30 of 30 frames in each of two runs, with 0 "failed to start camera" and 0 firmware boot retries. On our kernels up to 1.907, without it, the first open after boot failed: its firmware boot got no answer. davishann15's row above (one boot, 30 frames on the first and on a second open, no ISP errors) is the same behaviour.

Build check of this commit (425c96f) on integration/aurora acfcd08: checkpatch --strict 0/0/0; drivers/media/platform/apple/isp/ builds with W=1 with the same single warning as the base (apple_isp_hw_t6040 defined but not used, not from this patch). Other generations (M1, M2, M4 Pro, A18 Pro) have not been run with it by us.

Our kernel series carried three earlier workarounds for this failure (a 1.5 s minimum off time, a firmware boot retry and keeping the detecting firmware up). With this change alone the first open passed, so our kernel dropped all three. This patch is the whole fix we propose.

Assisted-by: LLM (Claude:Opus 5.5, Claude:Fable 5.2)

@davishann15-commits

Copy link
Copy Markdown

Tested on a J604 (MacBook Pro 14", M4, Mac16,1; os-fw 26.6.2, system-fw 27.0; aura 1.0.0b13). The kernel was alarm-aurora's pkgrel 38 recipe on integration/aurora 7c71d6d, plus #1543, #1894, #1895, #1917, #1918, #1919 and #1922. It booted on its own J604 tree as an aura-try trial. Userspace: Hyprland 0.57.2, mesa-aurora 26.3.0_devel.202611130318, speakerguardd-v2 1.0.0alpha.1-40.

macos_stop=Y. The first camera open after boot (no earlier ISP boot in that boot's log) streamed 30 frames with v4l2-ctl --stream-mmap. A second open a few seconds later did too, with no ISP errors in the log. One boot only (you measured three of three).


Disclosure: an LLM (Claude) ran these tests on my Mac and drafted this. I did the listening and looking, reviewed it, and am responsible for it.

Assisted-by: LLM

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for tracking down the first-open ISP boot failure and comparing it against macOS's power-down.

We select behaviour by a hardware property, not by the chips it was checked on. The reason given here is macOS behaviour, but it is enabled only on T8132 through match data (drivers/media/platform/apple/isp/isp-drv.c:1294, .macos_stop = true in apple_isp_hw_t8132), and a new module parameter can switch it off (drivers/media/platform/apple/isp/isp-fw.c:32-35, used at isp-fw.c:494 and :509).

Could you either make "leave the coprocessor control word alone at power-down" the default for every ISP generation, or, if some generation really needs the old write, keep the flag for that generation only and note the hardware reason in a code comment? Please also drop macos_stop as a module parameter: a driver behaviour should not need a boot option.

If you make it the default, we can run camera first-open rows on our M1 Pro, M2, M4 Pro and A18 Pro.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@IronsideXXVI @aeries0x, a J604 camera row request, if one of you has a few minutes.

On integration/aurora, linux#2229 (merged) changed how the T8132 ISP finds its DART address filter windows. The kernel no longer has a built-in table. It now reads them from apple,dapf-ranges, which the bootloader copies out of the ADT: aura#309 and u-boot#52 do this for every apple,t8132-isp, not only the J713. If the bootloader doesn't pass the property, the ISP refuses to probe and the camera stays off, where before it used the old table. We have only tested this on a J713, so the J604 has no row yet.

Could you boot a current integration/aurora kernel on the bootloader your J604 runs today, and post:

  1. The aura and U-Boot versions (or the release/kit you installed).
  2. grep -ri 'dapf\|isp' <(dmesg) | head -40. On an older bootloader we expect the boot loader gave no address filter (apple,dapf-ranges).
  3. Whether /proc/device-tree has the property: find /proc/device-tree -name 'apple,dapf-ranges'.
  4. If the ISP probes, one short capture: v4l2-ctl --list-devices, then a few frames with cam -c 1 --capture=10 or any viewer. Just say whether frames arrived. Please don't post the images.

If you're on an older bootloader, a second boot after updating to an aura with #309 would show both sides, but one boot on whatever you have now already helps.

@aeries0x

Copy link
Copy Markdown
Contributor

Here's a J604 row (MacBook Pro 14", M4, Mac16,1; os-fw 26.6.2, system-fw 27.2, aura Stage 1 1.0.0b8). Both boots ran integration/aurora e0ee46a with my J604 config and a local revert of #1888 to keep the speakers off; only aura and U-Boot changed between them.

With the released loader (aura 1.0.0b13.1 / 1.0.0b13-g5dcf62d0, U-Boot aurora11 / 2026.07-g250385f8c8aa), it fails as expected:

apple-isp 48c000000.isp: error -ENODEV: the boot loader gave no address filter (apple,dapf-ranges)

No apple,dapf-ranges on the ISP node, and v4l2-ctl --list-devices lists no camera.

With aura 1.0.0b13.1 plus aurora-silicon/aura#309 cherry-picked (1.0.0b13-g5ed1810f) and U-Boot at the aurora-silicon/u-boot#52 merge (2026.07-g37baf8f7b7c2), /proc/device-tree/soc/isp@48c000000/apple,dapf-ranges is present (13 start/end pairs, 208 bytes), apple-isp binds cleanly, and /dev/video0 shows up as FaceTime HD Camera (platform:48c000000.isp). I don't have cam installed, so I tested with v4l2-ctl --stream-mmap: the first open after boot streamed 10/10 frames (1920x1080 NV12, ~30 fps), and a second open a few seconds later streamed 30/30, with no ISP errors in dmesg.

One note on step 3: find /proc/device-tree -name 'apple,dapf-ranges' prints nothing even when the property is there, because /proc/device-tree is a symlink. find -L /proc/device-tree -name 'apple,dapf-ranges' or ls /proc/device-tree/soc/isp@*/ finds it.

@RyanTheTide

Copy link
Copy Markdown
Contributor

@aeries0x thank you for the J604 rows, that is exactly what we needed: the released loader refuses with the expected message, and with aura#309 and u-boot#52 the property is present, the ISP binds and frames stream. Thanks also for the find -L correction.

macOS powers the J604's ISP (M4 MacBook Pro 14", T8132) down without
writing the coprocessor control word 0; read from the ISP's MMIO in two
macOS camera sessions. This driver wrote it 0 at every power-down on
everything but T8140, where the sleep engine's restore needs the run
bit kept.

Leave the word alone at power-down on every ISP generation, with no
module parameter. The T6040 family's boot check, which wants a
coprocessor that never ran, now also accepts the start word (0x10) our
own power-down left; the boot still writes 0 then 0x10. Any other word,
or a non-zero word before our first power-down, still refuses.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI
IronsideXXVI force-pushed the j604-t8132-isp-macos-stop branch from 39388eb to 425c96f Compare November 20, 2026 17:26
@IronsideXXVI IronsideXXVI changed the title media: apple: isp: power the T8132 ISP down as macOS does media: apple: isp: leave the coprocessor control word at power-down Nov 20, 2026
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks, done in 425c96f (rebased onto integration/aurora acfcd08):

  • macos_stop is gone, as a module parameter and as match data. The control word is left alone at power-down on every ISP generation.
  • The T6040 family's boot check also accepts the start word (0x10) that our own power-down left. Any other word, or a non-zero word before our first power-down, still refuses.
  • I found no generation that needs the old write, so there is no per-generation flag. T8140 already skipped it.

On the J604 this is the code path our kernels ran by default: the first open after boot streamed 30/30 frames on 3 of 3 boots (1.908, 1.909), with 0 firmware boot retries. Without it, every first open after boot failed. checkpatch --strict is clean, and the ISP directory builds with W=1 with no new warning.

First-open rows from your M1 Pro, M2, M4 Pro and A18 Pro would cover the other generations. Thank you for offering them.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 425c96f. Dropping macos_stop entirely and leaving the control word alone at power-down on every generation is what we hoped for. Accepting only the start word our own power-down left, and only after that power-down, keeps the boot check strict.

As offered, we will run first-open rows on 425c96f on our M1 Pro, M2, M4 Pro and A18 Pro: first open after boot, frames streamed, and firmware boot retries. We'll post them here.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks, and thanks for running the first-open rows on the other machines. I'll look at them when they're posted.

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

Thanks for dropping macos_stop and making the power-down the same on every generation. That resolves the earlier review.

One problem with the new boot check. coproc_left is set at the end of isp_firmware_shutdown_stage1(), and that function also runs on the failure path of isp_firmware_boot_stage1(). So the case the check exists for slips through:

  1. The coprocessor is found already started, with control non-zero before any power-down of ours.
  2. isp_check_coproc_t6040() returns -EBUSY.
  3. The shutdown: path sets coproc_left.
  4. The next open accepts control == 0x10 and writes 0, then 0x10, over a coprocessor this driver never started.

The description says that case still refuses; on the second open it doesn't.

Setting the flag only after our own start closes it:

	apple_isp_power_down_domains(isp);
	if (isp->fw.started)
		isp->coproc_left = true;

Alternatively, test isp->fw.started in isp_check_coproc_t6040() and drop the new field. Either way, the path you measured doesn't change: after a successful first boot, fw.started is set before any power-down.

Minor: the 0x10 in the check is the start word that isp_firmware_boot_stage1() writes. A shared define would tie the two together.

The changed check runs on every T6040-generation ISP: T6040/T6041, T6050 (M5 Pro) and T8132. Ryan's rows cover the M1 Pro, M2, M4 Pro and A18 Pro. An M5 Pro first-open row would be useful after merge, but it doesn't need to block.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks, good catch. The failure path of isp_firmware_boot_stage1() sets coproc_left too, so a coprocessor this driver never started gets through on the second open. I'll set it only when isp->fw.started is set, and add a shared define for the 0x10 start word.

isp_firmware_shutdown_stage1() also runs when isp_firmware_boot_stage1()
gives up, including when isp_check_coproc_t6040() finds a coprocessor
that was already started. It set coproc_left there too, so the next open
accepted that coprocessor's control word 0x10 and wrote 0, then 0x10,
over a coprocessor this driver never started.

Set coproc_left only when fw.started is set. After a successful first
boot fw.started is set before any power-down, so the measured path is
unchanged.

Name the start word ISP_COPROC_CONTROL_START, so the boot check and the
boot write use the same value.

Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Pushed 851b5f6 on top: coproc_left is now set only when isp->fw.started is set, so the failure path of isp_firmware_boot_stage1() no longer marks a coprocessor we never started, and that case refuses on every open. The 0x10 is now ISP_COPROC_CONTROL_START, used by both the boot check and the boot write.

checkpatch --strict is clean, and the isp directory builds with W=1 with the same one warning as before (apple_isp_hw_t6040 unused). The J604 first-open row on this head is still to come.

fw.started is set at the first start and is never cleared, so gating
coproc_left on it only helps until the first open. After that, when an
open finds the coprocessor already started, isp_check_coproc_t6040()
returns -EBUSY, isp_firmware_boot_stage1() goes to shutdown, and
isp_firmware_shutdown_stage1() sets coproc_left again. A later open
that finds 0x10 then accepts a control word this driver did not write.

Set coproc_left right after the boot writes the start word, and clear
it when the check refuses. Nothing else writes the control word and
power-down leaves it, so coproc_left now means that the word still
holds our start word. Power-down no longer sets it.

A first open and a reopen after our own close take the same path as
before.

Suggested-by: Artyom Astafurov <artyom.astafurov@gmail.com>
Signed-off-by: Dylan Ironside <dylan@dylanironside.io>
@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Pushed 8d1257b on top, from @astaff's remark that the goto shutdown path still sets coproc_left after -EBUSY. The fw.started gate in 851b5f6 only helped until the first open: fw.started is never cleared, so after one start of ours an open that finds the coprocessor already started gets -EBUSY from isp_check_coproc_t6040(), goes to shutdown, and isp_firmware_shutdown_stage1() set coproc_left again. A later open that found 0x10 would then accept a control word we didn't write.

Now coproc_left is set right after the boot writes ISP_COPROC_CONTROL_START and cleared when the check refuses. Power-down no longer touches it. A first open and a reopen after our own close take the same path as before. checkpatch --strict is clean, and the W=1 build of the ISP directory gives no warning in isp-fw.c.

#2216 is already in this branch's base and doesn't touch isp-fw.c, so there is no merge order to worry about. T6041 goes through the same isp_check_coproc_t6040() via ISP_GEN_T6040.

The J604 first-open and reopen-after-close rows will follow from a device run that is queued. @astaff, could you run the J616c reopen check you offered on 8d1257b?

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 8d1257b, and to astaff for spotting it. Setting coproc_left right after the boot writes ISP_COPROC_CONTROL_START, and clearing it when isp_check_coproc_t6040() refuses, closes the -EBUSY -> shutdown path: a later open can no longer accept a start word we didn't write. Power-down leaving the control word alone on every generation is unchanged. No further code asks from us.

Still owed on this head: your J604 first-open and reopen-after-close rows, the J616c reopen check, and our first-open rows on the M1 Pro, M2, M4 Pro and A18 Pro, which we'll post here.

@IronsideXXVI

Copy link
Copy Markdown
Contributor Author

Thanks, both. The J604 test kernel I had built for this carries 851b5f6, so I'm rebuilding it on 8d1257b before I take the rows. I'll post the first open after boot and the reopen after our own close together, from the same boot.

@IronsideXXVI
IronsideXXVI force-pushed the j604-t8132-isp-macos-stop branch from 8d1257b to 4d31418 Compare November 21, 2026 15:15
@RyanTheTide
RyanTheTide merged commit 29c4704 into aurora-silicon:integration/aurora Nov 21, 2026
1 check passed
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.

5 participants