Skip to content

Jolla: camera kernels r21–r24 boot, all three cameras stream - #104

Merged
patrickjquinn merged 9 commits into
mainfrom
feat/jolla-cameras-r24
Nov 28, 2026
Merged

patrickjquinn merged 9 commits into
mainfrom
feat/jolla-cameras-r24

Conversation

@patrickjquinn

Copy link
Copy Markdown
Owner

The Jolla's camera kernels, booting.

Why r21–r23 didn't boot. r21 built the camsys_main clock driver in and took its controller out of the CAM_MAIN power domain: CAM_MAIN needs three camsys gates on before it releases its bus protection, so they became its subsys clocks. At late_initcall clk_disable_unused() then read every camsys gate with CAM_MAIN off and hung the bus, before the console came up. r22 only booted on 27 Nov because the previous boot's camera tests had left CAM_MAIN on.

Proved on the phone, one counted test boot each:

  • r22's kernel with r19's device tree boots;
  • r22 with clk_ignore_unused boots;
  • r23 with clk_ignore_unused boots.

pstore doesn't survive a reset on this phone, so the device tree and command line did the bisecting.

The fix (r24, patch 0290): camsys_main's gates are CLK_IGNORE_UNUSED, so the unused-clock sweep stays off them. CAM_MAIN's power sequence and the drivers inside the domain switch them.

In this PR:

  • r21: camera sensors and CAM_MAIN's bus protection.
  • r22: the camera receive path and the GenieZone hyp-MMU sync that gave real frames.
  • r23: the GPU mailbox RX race (0288), CAM_MAIN power-off (0289) and the modem's 10 s dumps compiled out.
  • r24: the boot fix (0290).
  • The device package (pkgrel 25) loads the cameras at boot.

Tested on the Jolla. r24 boots with no workaround flags. All three cameras stream twice in a row, 10/10 frames each with no IOMMU faults; r22 stalled on the second stream. The shell, GPU and modem (LTE+5G) are fine.

The phone's daily entry is still r19; r24 is installed as a test entry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BrjN1gf1Fu2w5MqXBmEowh

Patches 0274-0281 from jp2601/camera-r21, appended after r20's 0273:

- 0274-0278: drivers for the IMX616 (front) and IMX766 (main rear),
  built as modules. Both probe and stream on the JP2601 through the
  bring-up receive path.
- 0279-0281: camsys_main's LARB13, LARB14 and CAM2MM_GALS gates become
  CAM_MAIN's subsys clocks, so the domain releases its bus protection
  with them running, as the stock kernel does. Released without them,
  the infra protection of CAM_MAIN stays set and no camera DMA reaches
  memory. The camsys clock driver drops runtime PM and is built in,
  since the SPM's domains now depend on it.

Not yet built or booted as a package: the bus protection finding comes
from re-releasing it by hand on r19 (marathon.camtest=busprot), after
which CAMSV2 completed frames. Give r21 a counted boot before it
becomes the daily kernel: a fault in 0280 would stop the SPM's power
domains from probing.

Per docs/CODING_RULES.md G1, G3 and G11.

(cherry picked from commit e67d312)
Patches 0282-0286 from jp2601/camera-r21 (the MT6858 SMI larbs, the MM
IOMMU, and their nodes in mt6858.dtsi) and mt6858-camera-modules: the
Genio ISP6s SENINF, CAMSV and CSI PHY drivers with the Q25's patches
plus 0006 (the Linux 7.4 set_fmt API) and 0007 (MT6858: CSI port 2,
the CAMSV2/3 gates, larb ports left to mtk-smi behind the IOMMU), the
jp2601-cam-dt overlay loader and the jp2601-camera overlay for the
three sensors.

Not working yet, so not on feat/jolla-jp2601: on r19 with the same
drivers (as bring-up modules) and the bus protection released, all
three sensors stream and CAMSV2 signals every frame done, but the
buffers stay zero, on the IOMMU route and the physical one alike, with
or without the CAMSV2/3 gates. Nothing loads these modules: the device
package carries no modules-load entry for them. Not built as a package.

Per docs/CODING_RULES.md G1, G3 and G11.

(cherry picked from commit 59a497b)
The JP2601 runs Linux at EL1 under MediaTek's GenieZone hypervisor, and
its hyp-MMU "type 2" (SMC 0xbb00ffa4 returns 1) translates MM IOMMU
traffic through its own copy of the page table. Mainline never tells it
about a map or unmap, so every CAMSV write faulted at layer 0 and the
frames stayed empty (a 0x5a pre-fill came back untouched while larb13
port 6 counted each full frame going out). Patch 0287 makes mtk_iommu
send TYPE2_INV (SMC 0xbb00ffa7) after every map, unmap and full flush,
as the vendor driver does.

Tested on r19 with the same call made from the bring-up CAMSV module:
all three sensors give real frames with no IOMMU faults. A range INV
without the unmap side let a stream DMA into freed pages and panicked
the phone, which is why the patch covers unmap too. r22 itself is not
booted yet.

Per docs/CODING_RULES.md G1, G3 and G11.

(cherry picked from commit ea1ae8b)
mtk-gpueb-mailbox marked a channel empty only after the client's callback
had returned, so mtk-mfg's next IPI (the OPP commit right after the
power-on answer) met -EBUSY and the mailbox core queued it silently. The
EB never got it, the GPU domain timed out ("No answer to GPUFreq IPI
command 8/6"), and Panthor could not boot the MCU again: the reason the
JP2601 keeps its GPU awake. Patch 0288 clears the state before passing
the message on. (G1, G3)

(cherry picked from commit 5f0f783583157b578e40f898220f8fe070e845f9)
The MT6858 SUBx bus protection was polled at 0x3cc, which never shows
the bits; MediaTek's driver polls the enable register at 0x3c0. Every
CAM_MAIN power-off timed out after setting the infra protection, genpd
left the domain on, and no power-on ran to release it, so camera streams
after the first stalled (and CAM_MAIN never powered down). Patch 0289
polls 0x3c0. (G1, G3)

(cherry picked from commit 71524767ced2e1482da490629766a7d003db4a5c)
ECCCI's DPMAIF and CCIF traffic monitors woke the JP2601 every 10 s, all
night, to print about six kernel log lines of queue counters that
journald then wrote to storage. Set both intervals to 0, which the DPMAIF
code already compiles out; the CCIF reset path no longer arms a timer
with a zero interval. (G1, G3)

(cherry picked from commit 16eb43c2a561cb472a462d349d1116b800768827)
Load the camera overlay (jp2601_cam_dt, enabled) and the dma-buf
system heap at boot, let the video group allocate from the heap, and
depend on mt6858-camera-modules, libcamera and its GStreamer element,
which the Camera app's Qt backend needs.

Tested piecewise on the Jolla (overlay, heap and libcamerasrc loaded by
hand in a test boot); the package itself is not built or booted yet.

Per docs/CODING_RULES.md G1, G3 and G11.

(cherry picked from commit ae3edcb)
Kernels r21 to r23 died before the console on most boots. r21 built the
camsys_main clock driver in and took the controller out of CAM_MAIN, so
the unused-clock sweep at late_initcall read its gates with CAM_MAIN off
and hung the bus. r22 only booted when an earlier boot's camera tests had
left CAM_MAIN on.

Patch 0290 keeps the sweep off camsys_main's gates. On the Jolla r24
boots with no workaround, and all three cameras stream twice in a row
(10/10 frames each, no IOMMU faults), which also checks r23's CAM_MAIN
power-off fix (0289).
@github-actions

Copy link
Copy Markdown

Formatting changes required
This PR does not follow the formatting rules.
Please run:

clang-format -i <files>
qmlformat -i <files> (must be from Qt 6)
cargo fmt --manifest-path crates/Cargo.toml --all

Commit the updated files and push again.

@patrickjquinn
patrickjquinn merged commit 2425093 into main Nov 28, 2026
3 checks 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.

1 participant