Repository navigation
media: apple: isp: leave the coprocessor control word at power-down - #1918
RyanTheTide merged 3 commits into
Conversation
|
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
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 |
|
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 ( 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 If you make it the default, we can run camera first-open rows on our M1 Pro, M2, M4 Pro and A18 Pro. |
|
@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 Could you boot a current integration/aurora kernel on the bootloader your J604 runs today, and post:
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. |
|
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 With the released loader (aura 1.0.0b13.1 / No With aura 1.0.0b13.1 plus aurora-silicon/aura#309 cherry-picked ( One note on step 3: |
|
@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 |
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>
39388eb to
425c96f
Compare
|
@RyanTheTide thanks, done in 425c96f (rebased onto integration/aurora acfcd08):
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. |
|
Thanks for 425c96f. Dropping 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. |
|
@RyanTheTide thanks, and thanks for running the first-open rows on the other machines. I'll look at them when they're posted. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
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:
- The coprocessor is found already started, with control non-zero before any power-down of ours.
isp_check_coproc_t6040()returns -EBUSY.- The
shutdown:path setscoproc_left. - 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.
|
Thanks, good catch. The failure path of |
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>
|
Pushed 851b5f6 on top: checkpatch --strict is clean, and the isp directory builds with W=1 with the same one warning as before ( |
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>
|
Pushed 8d1257b on top, from @astaff's remark that the Now #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 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? |
|
Thanks for 8d1257b, and to astaff for spotting it. Setting 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. |
8d1257b to
4d31418
Compare
29c4704
into
aurora-silicon:integration/aurora
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/auroraacfcd08: 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_t6040defined 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)