Skip to content

gk7205v500: keep 64 MB boards on the media-memory carve-out - #2620

Merged
openipc-ai merged 1 commit into
masterfrom
gk7205v500-64m-carveout
Oct 17, 2026
Merged

openipc-ai merged 1 commit into
masterfrom
gk7205v500-64m-carveout

Conversation

@openipc-ai

@openipc-ai openipc-ai commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

load_goke switches any gk7205v500 command line that names no allocator to CMA for the next boot. That switch was measured on one 128 MB V510, where Linux went from 28 MB to 125 MB (#2526). It was never run on a 64 MB board, which is what most gk7205v500 cameras carry. The 64 MB reporter in OpenIPC/majestic#350 objects to their board being moved to CMA.

At 64 MB the media zone is 32 MB with CMA or without it, and a 4 MP pipeline uses most of it. So CMA can lend Linux only the little the zone leaves free. In exchange, every media allocation depends on the kernel first migrating movable pages out of the zone.

What this is not. It is not a fix for an observed CMA failure. Both of the #350 reporter's logs, with CMA and without, fail with the same ERR_VPSS_NOMEM / ERR_VENC_NOMEM. That failure is majestic putting a 2560-wide sensor on VI offline, which is being fixed in majestic. This PR returns 64 MB boards to the configuration they had before #2526, until CMA is measured there.

Hardware tested on

Not run on a camera. The lab has no 64 MB gk7205v500. The only gk7205v500-family board (a 128 MB V510) was unreachable. A 128 MB board would only show that nothing changes for it.

The evidence below is the function itself, run in busybox with stubbed fw_printenv/fw_setenv, /proc/cmdline and /proc/meminfo. A board with this image would also show it: on a fresh 64 MB install, load_goke no longer prints Media memory: switching to CMA, and fw_printenv bootargs keeps mem=32M. Confirmation from anyone with a 64 MB board is welcome.

Evidence

check_allocator() extracted from load_goke, with /proc paths redirected to test files and osmem=32M.

Before (origin/master):

totalmem=64 [mem=32M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3] -> Media memory: switching to CMA from the next boot (mem=64M)
SETENV bootargs mem=64M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 mmz_allocator=cma mmz=anonymous,0,0x42000000,32M
totalmem=128 [mem=32M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3] -> Media memory: switching to CMA from the next boot (mem=128M)
SETENV bootargs mem=128M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 mmz_allocator=cma mmz=anonymous,0,0x42000000,96M
totalmem=32 [mem=32M console=ttyAMA0] -> <bootargs unchanged>
totalmem=128 [mem=128M mmz_allocator=cma mmz=anonymous,0,0x42000000,96M] -> <bootargs unchanged>

After:

totalmem=64 [mem=32M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3] -> <bootargs unchanged>
totalmem=128 [mem=32M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3] -> Media memory: switching to CMA from the next boot (mem=128M)
SETENV bootargs mem=128M console=ttyAMA0,115200 panic=20 root=/dev/mtdblock3 mmz_allocator=cma mmz=anonymous,0,0x42000000,96M
totalmem=32 [mem=32M console=ttyAMA0] -> <bootargs unchanged>
totalmem=128 [mem=128M mmz_allocator=cma mmz=anonymous,0,0x42000000,96M] -> <bootargs unchanged>

A 64 MB board that has already been switched keeps its CMA bootargs. To move it back, drop mmz_allocator= and mmz= from bootargs and set mem= back to osmem (mem=32M). Removing the allocator alone leaves mem=64M, and the carve-out then has no room for the zone.

Scope

  • No kernel patches under general/package/all-patches/linux/ (those go to OpenIPC/linux)
  • No files specific to a single retail camera model (those go to OpenIPC/builder)
  • No probing or bring-up tooling (that goes to OpenIPC/ipctool)
  • Nothing under general/overlay/ or in a shared load_<vendor> script hardcodes a value specific to my board
  • Package sources come from an OpenIPC repository, and any version bump keeps at least the specificity of the pin it replaces (a new package should pin a full 40-character SHA)
  • No LD_PRELOAD, and no binaries that cannot be rebuilt from source
  • New code is selected by a defconfig, so CI actually builds it

load_goke moves a command line that names no allocator to CMA for the next
boot. That was measured on a 128 MB V510, where Linux went from 28 MB to
125 MB (#2526); it was never run on a 64 MB board, which is what most
gk7205v500 cameras carry (OpenIPC/majestic#350). There the zone is 32 MB
either way and a 4 MP pipeline fills most of it, so CMA lends Linux little
while every media allocation depends on migrating pages out of the zone.

64 MB and less now stay on the carve-out. A board that was already switched
keeps its CMA bootargs; to move it back, drop mmz_allocator= and mmz= from
bootargs and set mem= back to osmem (mem=32M), as removing the allocator
alone would leave mem=64M and no room for the zone.
@openipc-ai
openipc-ai marked this pull request as ready for review October 17, 2026 17:09
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Keep 64 MB gk7205v500 boards on the media-memory carve-out

🐞 Bug fix 🕐 Less than 10 minutes

Grey Divider

AI Description

• Prevent automatic CMA migration on gk7205v500 boards with 64 MB of RAM or less.
• Preserve CMA migration for larger boards and leave existing bootargs unchanged.
Diagram

graph TD
  check["Allocator check"] --> prechecks{"Prechecks pass?"} -->|Yes| threshold{"DDR > 64 MB?"} -->|Yes| rewrite["Schedule CMA"]
  prechecks -->|No| unchanged["Leave bootargs"]
  threshold -->|No| unchanged
Loading
High-Level Assessment

The guard at the existing migration decision is the narrowest approach: it preserves behavior above 64 MB and does not overwrite boards already configured for CMA. Changing the default allocator or forcing bootargs for all boards would broaden the impact without evidence from 64 MB hardware.

Files changed (1) +6 / -0

Bug fix (1) +6 / -0
load_gokeExclude 64 MB and smaller boards from automatic CMA migration +6/-0

Exclude 64 MB and smaller boards from automatic CMA migration

• Adds an early return when detected total memory is 64 MB or less, before check_allocator rewrites bootargs for the next boot. Comments explain why the existing media-memory carve-out is retained until CMA is measured on those boards.

general/package/goke-osdrv-gk7205v500/files/script/load_goke

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Other cameras inherit a 64 MB policy 📘 Rule violation ≡ Correctness
Description
check_allocator() returns early when totalmem is 64 MB or less, embedding the 64 MB policy in
the shared load_goke script. Every board image that installs this script, including the separate
lite configuration, now gets the carve-out behavior based on memory size rather than device-specific
builder configuration.
Code

general/package/goke-osdrv-gk7205v500/files/script/load_goke[R112-117]

+	# CMA was measured on 128 MB (a V510: Linux 28 MB -> 125 MB, #2526). A
+	# 64 MB board has a 32 MB zone either way, and a 4 MP pipeline fills most
+	# of it, so CMA would lend Linux little while every media allocation would
+	# depend on migrating pages out first. Until it is measured there, 64 MB
+	# and less stay on the carve-out (majestic#350).
+	[ "$totalmem" -gt 64 ] || return 0
Evidence
The checklist forbids introducing board-specific values or branches in shared load scripts. The
changed script hardcodes a 64 MB cutoff, and the same package is selected by multiple board
configurations, including the separate gk7201v200_lite configuration.

general/package/goke-osdrv-gk7205v500/files/script/load_goke[112-117]
br-ext-chip-goke/configs/gk7201v200_lite_defconfig[46-53]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The shared `load_goke` script now hardcodes a 64 MB board policy, so every board using this script inherits the behavior even when the policy is intended for a specific board family or memory configuration.
## Fix Focus Areas
- general/package/goke-osdrv-gk7205v500/files/script/load_goke[112-117]
- br-ext-chip-goke/configs/gk7201v200_lite_defconfig[46-53]
- br-ext-chip-goke/configs/gk7205v500_lite_defconfig[46-53]
## Recommended Fix
Move the memory-policy threshold or board-family selection into the appropriate device-specific builder configuration, and have the shared script consume that configuration without hardcoding a value that changes behavior for unrelated images.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can see how risky a PR is at a glance with blast radius labels

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@openipc-ai
openipc-ai merged commit 1d04842 into master Oct 17, 2026
43 of 47 checks passed
@openipc-ai
openipc-ai deleted the gk7205v500-64m-carveout branch October 17, 2026 17:22
openipc-ai added a commit to OpenIPC/wiki that referenced this pull request Oct 17, 2026
…nger reserve a frame (#604)

* memory-tuning: wide sensors on 64 MB boards, and snapshots that no longer reserve a frame

- New section, Wide sensors on 64 MB boards: where a 32 MB media region
  goes on a gk7205v500 + SC401AI (2560x1440) with two streams, why builds
  before mid-October 2026 had no main stream there (OpenIPC/majestic#350,
  OpenIPC/firmware#2587), what the streamer does when the pool does not
  fit, and what to turn off if it still does not. The figures are labelled
  as estimates; they were not measured on a gk7205v500.
- The capture path's width limit is per chip: 2304 on the ev200/ev300 and
  gk7205v200/v300, 3072 on the gk7205v500 family.
- Kernel 4.9: the gk7205v500 firmware moves boards to CMA at boot except
  those with 64 MB or less (OpenIPC/firmware#2620), and how to move a
  64 MB board that was already switched back to the fixed split. Removing
  the allocator alone leaves the media region nothing.
- jpeg.enabled and jpeg.tuned: on current HiSilicon and Goke builds, other
  than hi3516cv100 and hi3516cv6xx, snapshots reserve no frame, so turning
  JPEG off frees none and jpeg.tuned is ignored. Measured on a gk7205v200
  with a 1080p sensor: 16632 KB of media memory with JPEG on and off, and
  18680 KB while snapshots are being served. The old figures stay in the
  table, marked as older builds.

* memory-tuning, majestic-streamer, majestic-config: review fixes

- The fixed-split recipe now sets mem=32M whatever mem= held before,
  ${osmem} included, which may itself have been set to the whole DDR.
  Tested with BusyBox sed on a numeric mem=, a variable and a mem= in
  the middle of the line.
- The other places that promised a frame back from jpeg.enabled: false
  now say where that holds: majestic-streamer's JPEG section, the
  one-frame-per-channel paragraph, majestic-config's comment.
- Parameterised snapshots on current HiSilicon and Goke builds need no
  jpeg.tuned and no restart. Measured on a gk7205v300 with a 2592x1944
  sensor and jpeg.tuned unset: 640x360, q30 and 1280x720 served; a size
  above the frame came back at 2592x1944; 16x16 refused with 400; a crop
  came back at 1:1 with width/height not applied. The cap and the restart
  are kept for hi3516cv100, hi3516cv6xx and older builds.
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