waybeam_venc icon indicating copy to clipboard operation
waybeam_venc copied to clipboard

cv610: load-cv610-online loads no modules on an OpenIPC image -- mmz_allocator is hardcoded to ot

Open DmtryJS opened this issue 3 weeks ago • 1 comments

Follow-up to #131 and #132, from running the kernel half on a real board: Hi3516CV610 + IMX335, OpenIPC image, kernel 5.10.221 with hisi_mem. The checklist run and the rate/shading numbers are in #131; this is the defect that run turned up.

Symptom

S95waybeam start never reaches the daemon, and the craft comes up with no MPP modules at all:

load patched open_sys_config
load open_osal
load open_mmz
mmz_userdev:mmz_register_check:
Conflict MMZ:
PHYS(0x42000000, 0x47FFFFFF), GFP=0, nBYTES=98304KB,    NAME="anonymous"
MMZ conflict to kernel memory (0x40000000, 0x47FFFFFF)
mmz_userdev:allocator_init:
Add MMZ failed: PHYS(0x42000000, 0x47FFFFFF), ...
load mmz failed!

Cause

init.d/load-cv610-online passes mmz_allocator=ot together with a zone it names itself (default 0x44000000, 64M). That shape belongs to a bootloader-driven layout, where the zone is a carve-out outside kernel memory.

An OpenIPC hi3516cv6xx kernel does not work that way. It measures DRAM and reserves the MMZ zone inside kernel memory through CMA, ignoring the bootloader's totalmem/osmem and any mem= on the command line — dmesg says so outright:

hisi_mem: 64M of memory from the bootloader ignored, DRAM is 128M
hisi_mem: DRAM 128M (probed), cma, OS 32M, mmz=anonymous,0,0x42000000,96M

OpenIPC's own load_hisilicon reads exactly that and reaches its ot branch only when hisi_mem is absent:

if [ -n "$kernel_alloc" ]; then
	mmz_args="anony=1 mmz_allocator=$kernel_alloc mmz=$kernel_mmz"
else
	...
	MMZ=$(awk -F '=' '$1=="mmz"{print $2}' RS=" " $proc_cmdline)
	if [ -z "$MMZ" ]; then mmz_args="anony=1 mmz_allocator=ot mmz=anonymous,0,$mmz_start,$mmz_size"
	else                  mmz_args="anony=1 mmz_allocator=cma mmz=$MMZ"; fi
fi

load-cv610-online took that second branch unconditionally, so open_mmz refuses the zone and the sequence dies before any module is loaded. Nothing in the tree could have caught it: kmod-cv610 only compiles the modules, and no image carries them yet (#132), so this was the first run of the loader on a board.

Proposed fix

Mirror load_hisilicon: when /sys/module/hisi_mem/parameters/allocator is readable, take the allocator from it and the zone from .../mmz; otherwise keep ot with CV610_MMZ_START/CV610_MMZ_SIZE, or cma when the command line names the carve-out with mmz=. CV610_MMZ_START/CV610_MMZ_SIZE then apply only in that second case, and on a hisi_mem boot they cannot move anything — the kernel's parameters are read-only — so the loader says so instead of dropping them silently.

The change is ready and goes up as a PR right after this issue.

Numbers from the same board, which also replace the docs' estimate

  • MMZ in use at 1080p output: 94 MiB for the 2592-wide rows (modes 0 and 3), 81 MiB for 2592x1520, 44 MiB for 1080p, 34 MiB for the binned row. /proc/media-mem does not exist on this kernel; CMA in /proc/meminfo is its equivalent (CmaTotal 98304 kB).
  • Delivered rate, RTP, one row per mode: 30, 40, 60, 30 and 90 fps against 90 nominal, i.e. nominal everywhere, with the daemon's sns0_clk_hz write accepted (37125000 -> CRG 0x8440 = 0x8010).
  • With the loader fixed: 22 modules, open_pm_stub present, no vendor open_pm, /api/v1/modes five rows, snapshot 200, S95waybeam restart works ("MPP modules already loaded").

Not part of this issue

Who owns the module load — the image's S70vendor (load_hisilicon -i) or this loader — is still open: with the vendor stack already up, the loader refuses (refusing vendor open_pm, refusing dirty MPP module state). A separate decision, noted here because it is what a firmware package has to answer next.

DmtryJS avatar Nov 12 '26 20:11 DmtryJS

Correction from the board, measured with #135 applied: the 94 MiB in the report above was our VB configuration, not a requirement of the IMX335.

Same board, same kernel (Hi3516CV610 + IMX335, 128 MiB, hisi_mem zone anonymous,0,0x42000000,96M), MMZ taken from used= in /proc/umap/media-mem instead of CmaFree deltas:

mode capture MMZ, previous build 88818a87 MMZ, OpenIPC/waybeam#135 1880621
0 2592x1944@30 89.6 MiB (91776 kB) 22.19 MiB (22724 kB)
3 2592x1944@40 89.6 MiB (91776 kB) 22.19 MiB (22724 kB)
4 2592x1520@30 74.5 MiB (76276 kB) 21.73 MiB (22252 kB)
2 1920x1080@90 36.8 MiB (37728 kB) 20.94 MiB (21444 kB)
1 1296x972@60 27.0 MiB (27648 kB) 10.02 MiB (10264 kB)

VB went from three pools of four frames (capture RAW at 2 B/px, capture-size YUV, output YUV — only the VI-online rows skipped the YUV one) to a single pool of four output frames. All five rows held their nominal rate (30.00 / 40.00 / 30.00 / 90.00 / 60.00 fps measured over RTP).

Two consequences for this issue:

  • The 2592-wide rows do not need a larger zone than the 96 MiB hisi_mem gives them; the "94 MiB" figure above should not be read as a sensor or platform requirement.
  • 5 MP output (video0.size=2592x1944) no longer trips the OOM killer with #135: 49.3 MiB of MMZ, MemAvailable 53.8 MiB, 30.00 fps, error-free log. That was also the pool sizing.

The defect this issue is actually about — load-cv610-online hardcoding mmz_allocator=ot — still stands, and OpenIPC/waybeam#134 fixes it. Verified on the same board: the hisi_mem branch loads its module set (22 modules plus open_pm_stub, no vendor open_pm), sns0_clk_hz is written as 37125000 -> CRG 0x8440 = 0x8010, and the override path prints warning: the kernel laid memory out itself; CV610_MMZ_START/SIZE ignored, open_mmz gets anonymous,0,0x42000000,96M.

DmtryJS avatar Nov 13 '26 19:11 DmtryJS