Skip to content

hi_cma: synthesize fallback zone from default CMA when no mmz= passed#37

Merged
widgetii merged 1 commit intohisilicon-hi3516cv500from
fix/cv500-cma-fallback-default-pool
May 7, 2026
Merged

hi_cma: synthesize fallback zone from default CMA when no mmz= passed#37
widgetii merged 1 commit intohisilicon-hi3516cv500from
fix/cv500-cma-fallback-default-pool

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented May 7, 2026

Summary

openhisilicon's V3.5 `cma_allocator` (in user-side `open_osal.ko`) calls
`hisi_get_cma_zone("anonymous")` to look up a CMA region registered via
the kernel cmdline `mmz=` early_param. On stock OpenIPC firmware where
the U-Boot bootargs were never customised, no `mmz=` is present,
`hisi_get_cma_zone` returns NULL, the OSAL allocator fails to register
any zone, and after OpenIPC/openhisilicon#73 propagated `-ENODEV` from
the empty-zone case, `insmod hi_osal.ko` started failing loud.

Existing hi3516av300 / hi3516cv500 / hi3516dv300 cameras that worked
for years
stopped loading any vendor module after a sysupgrade.

Fix

When the named lookup misses, synthesize a single fallback zone that
points to the kernel's default CMA pool (set by `CONFIG_CMA_SIZE_MBYTES`
or `cma=` in cmdline). The fallback is one-shot (cached in a `static`
struct) so subsequent get-by-name calls reuse it.

Boards that DO put `mmz=anonymous,...` in bootargs keep their per-zone
intent — named lookup is still tried first.

Test plan (verified on hi3516av300_imx415)

With default OpenIPC bootargs (no mmz=, no cma=) and
`CONFIG_CMA_SIZE_MBYTES=256`:

  • Boot to login on UART
  • All 37 OSDRV modules load (open_osal → ... → open_acodec)
  • `ipcinfo --short-sensor` returns `imx415`
  • `HiSilicon SDK started`, `Free MMZ mem after allocation: 257924KB`
  • H.264 4K + MJPEG 4K channels both succeed
  • RTSP server on :554, HTTP/HTTPS on :80/:443
  • `curl http://root:12345@CAM/image.jpg\` returns valid 3840×2160
    baseline JPEG (368 KB)

Companion firmware-side change: openipc/firmware bumps
`CONFIG_CMA_SIZE_MBYTES` to 256 and disables `CONFIG_HIGHMEM` in the
cv500-family generic configs (av300/cv500/dv300). HIGHMEM=y created the
lowmem/highmem boundary at `0xb0000000` that broke any CMA region
spanning it; HIGHMEM=n matches what hi3516ev300 has shipped for years.

🤖 Generated with Claude Code

openhisilicon's V3.5 cma_allocator (in user-side open_osal.ko) calls
hisi_get_cma_zone("anonymous") to look up a CMA region registered via
the kernel cmdline `mmz=` early_param. On stock OpenIPC firmware where
the U-Boot bootargs were never customised, no `mmz=` is present,
hisi_get_cma_zone returns NULL, and the OSAL allocator fails to register
any zone. After OpenIPC/openhisilicon#73 propagated -ENODEV from the
empty-zone case, `insmod hi_osal.ko` started failing loud, and
load_hisilicon's `|| report_error` aborts the whole module load chain.

Existing hi3516av300 / hi3516cv500 / hi3516dv300 cameras that "worked
for years" stopped loading any vendor module after a sysupgrade.

Fix: when the named lookup misses, synthesize a single fallback zone
that points to the kernel's default CMA pool (set by
CONFIG_CMA_SIZE_MBYTES or `cma=` in cmdline). The fallback is one-shot
(cached in a static struct) so subsequent get-by-name calls reuse it.

Verified on hi3516av300_imx415 with default OpenIPC bootargs (no mmz=,
no cma=) and CONFIG_CMA_SIZE_MBYTES=256: all 37 OSDRV modules load,
IMX415 4K2K_30FPS init succuss, RTSP server on :554, HTTP /image.jpg
returns a valid 3840x2160 baseline JPEG. No bootargs change required.

Boards that DO put `mmz=anonymous,...` in bootargs keep their per-zone
intent (named lookup is still tried first).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants