Skip to content

kernel: ship blob .cmd stubs + gate open_pm + add dev_warn shim (cv200/av100 neo unblock)#171

Merged
widgetii merged 2 commits into
mainfrom
feat/v2-shim-expand-modpost-syms
May 22, 2026
Merged

kernel: ship blob .cmd stubs + gate open_pm + add dev_warn shim (cv200/av100 neo unblock)#171
widgetii merged 2 commits into
mainfrom
feat/v2-shim-expand-modpost-syms

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

Three small follow-ups to the V2/V2A shim work in #170 that surface only when you actually exercise the firmware-tarball build path (the openhisilicon repo CI uses actions/checkout so it never hits these):

  1. Ship stub .o.cmd files for cv200/av100 blobs (47 files). GitHub-archive tarballs strip dotfile siblings; Linux 7.0 modpost calls read_text_file() and exit(1)s on missing .cmd. cv500 already had them committed (31 files); cv200/av100 didn't.

  2. Gate open_pm.ko build behind DISABLE_PM in kernel/hi3516av100.kbuild. Vendor blob references dev_pm_opp_init_cpufreq_table / cpufreq_table_validate_and_show / cpufreq_generic_attr — all removed in mainline. opensdk already passes DISABLE_PM=1 by default; matching the gate makes the directive effective. Lite (4.9) unaffected — DISABLE_PM=1 already applied there and the previous unconditional obj-m made it a no-op anyway.

  3. Add dev_warn to both shims (cv200_shim.c, av100_shim.c). Same shape as the dev_err shim from kernel/osal_v2_shim,osal_v2a_shim: cover the full V2/V2A blob-symbol set #170 — macro in <linux/dev_printk.h> that funnels through _dev_err; variadic wrapper via dev_vprintk_emit at KERN_WARNING.

Verification

End-to-end QEMU smoke on both neo targets (login + DHCP + ping):

Target Kernel DoD
hi3516cv200_neo 7.0 ✅ login + IP + ping (4.218 ms)
hi3516av100_neo 7.0 ✅ login + IP + ping (2.728 ms) — via new openipc/linux higmac driver
hi3516cv200_lite 4.9 ✅ byte-equivalent to nightly (331/331 files, 68/68 .ko)
hi3516av100_lite 4.9 ✅ byte-equivalent to nightly (290/290 files, 61/61 .ko)

Test plan

  • cv200_neo builds + boots + login + ping
  • av100_neo builds + boots + login + ping
  • cv200_lite byte-equivalence vs nightly
  • av100_lite byte-equivalence vs nightly

Related

Builds on #170 (full V2/V2A blob-symbol set). Companion to a forthcoming openipc/linux PR adding hi3516av100 mainline DT + CRG + higmac driver, and an OpenIPC/firmware PR with the cv200_neo + av100_neo board files + opensdk hash bump.

🤖 Generated with Claude Code

Vixand and others added 2 commits May 22, 2026 11:27
Linux 7.0 modpost (scripts/mod/modpost.c) calls read_text_file() on the
.<basename>.o.cmd sibling of every .o referenced from a module's .mod
list, and exits non-zero if the file is missing. For prebuilt blob .o
files (cv200's hi3518e_*.o, av100's hi3516a_*.o) there's no kbuild rule
that generates the .cmd — they're committed binaries with no build
metadata.

cv500 already has these .cmd files committed (31 of them, dating back
to the cv500 mainline-kernel bring-up). cv200 and av100 didn't — which
worked fine on 4.9 lite (modpost was lax) and on standalone CI builds
(actions/checkout fetches dotfiles), but breaks on firmware-tarball
neo builds where the github-archive tarball strips them.

Each .cmd is a one-line stub:
    savedcmd_kernel/obj/<chiparch>/<obj>.o := :
satisfying modpost's read_text_file() without claiming any CRC info
(no #SYMVER lines). Linker symbol resolution is unaffected.

47 files total (21 cv200 + 26 av100). Unblocks cv200_neo and
av100_neo firmware builds end-to-end.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two follow-ups discovered while exercising the hi3516av100_neo
firmware build for the first time (cv200 was unblocked by #170; av100
hit two further issues this commit closes):

  - kernel/hi3516av100.kbuild: gate open_pm.ko build behind
    DISABLE_PM (opensdk already passes DISABLE_PM=1 by default;
    matching the gate makes the directive effective). The vendor blob
    hi3516a_pm.o references dev_pm_opp_init_cpufreq_table,
    cpufreq_table_validate_and_show, cpufreq_generic_attr — all
    removed in mainline. Even with CONFIG_CPU_FREQ + REGULATOR
    enabled, modpost still fails. open_pm.ko is the AVS / CPU-DVFS
    blob; not needed for boot. Lite (4.9) is unaffected — the
    DISABLE_PM=1 default already applied there and the previous
    unconditional obj-m made it a no-op anyway.

  - osal_v2_shim/cv200_shim.c, osal_v2a_shim/av100_shim.c: add
    dev_warn export. Same shape as the dev_err shim landed in #170 —
    macro in <linux/dev_printk.h> that funnels through _dev_err;
    variadic wrapper via dev_vprintk_emit at KERN_WARNING (loglevel
    digit 4). av100 blobs reference dev_warn from open_pm (gated out
    above) and from other vendor sources; safer to ship the shim
    for symmetry.

Verified end-to-end: hi3516av100_neo now builds and boots to
login prompt with eth0 up via the new mainline higmac driver
(openipc/linux feat/av100-mainline), DHCP from SLIRP, ping 10.0.2.2
succeeds. cv200_neo continues to meet the same DoD. cv200_lite and
av100_lite (4.9 kernel) remain byte-equivalent to nightly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii widgetii force-pushed the feat/v2-shim-expand-modpost-syms branch from ea1f8c1 to 73d45f4 Compare May 22, 2026 08:27
@widgetii widgetii merged commit 7fa06b2 into main May 22, 2026
28 checks passed
widgetii added a commit that referenced this pull request May 24, 2026
* kernel/hi3516cv100: V1 OSAL shim + mmz source patches for Linux 7.0

Brings the cv100 (V1, ARM926EJ-S) module set up against the openipc/linux
7.0 base used by cv200_neo / av100_neo. cv100 has no OSAL abstraction —
the vendor .o blobs in kernel/obj/hi3516cv100/ embed kernel API calls
verbatim against the 3.0.8 SDK base. Two-layer fix mirrors the cv200
#162 pattern:

* `kernel/osal_v1_shim/cv100_shim.c` — re-exports legacy kernel symbols
  the cv100 blobs reference (do_gettimeofday, register_sysctl_table,
  init_timer_key, strlcpy, _cond_resched, __kmalloc, kmem_cache_alloc,
  __memzero, printk, del_timer, vmalloc, sched_setscheduler). Gated to
  >=5.0 so on the cv100_lite production target (3.0.8) the module is a
  benign no-op shell. Strict subset of v2_shim coverage; symbols cv200
  needs but cv100 doesn't (PDE_DATA, dev_err/warn, jiffies_to_msecs,
  register_sysctl_paths) are omitted.

* `kernel/mmz/hi3516cv100/{media-mem,kcom,mmz-userdev}.c` — strip
  mach/hardware.h and asm/system.h (removed in modern ARM); guard
  asm/outercache.h with CONFIG_OUTER_CACHE; add the 3.10 proc-fs
  version branch (proc_create + COMPAT_USE_PROC_OPS) for media-mem's
  /proc entry; switch mmz_write_proc signature for the new
  fops/proc_ops .write slot.

* `kernel/cipher/hi3516cv100/src/cipher_intf.c` — drop asm/system.h.

* `kernel/hi3516cv100.kbuild` — wire v1_shim ahead of mmz with the same
  CFLAGS_*=-D_cond_resched=...unused_inline trick cv200 uses to suppress
  the static-inline definition from <linux/sched.h>.

* kernel/{rtc,ir}/hi3516cv100: drop IO_ADDRESS, switch to ioremap_nocache

Both files keyed their MMIO macros off `IO_ADDRESS(phys_addr)`, the
mach/hardware.h static virtual-mapping table that's gone on modern ARM
(removed alongside mach support cleanup). cv200's equivalent files had
already been refactored to ioremap-backed globals pre-#162 — cv100's
source predates that work.

* `rtc/hi_rtc.c`: hold ioremap_nocache results for the CRG (0x20030000)
  and SPI (0x20060000) windows in `rtc_{crg,spi}_base_addr` globals,
  redefine CRG_BASE_ADDR / RTC_SPI_BASE_ADDR to point to them. All
  writel/readl call sites get a `(void *)` cast (modern __iomem-typed
  prototype). The temperature_detection timer callback gets the
  COMPAT_TIMER_SETUP signature swap from kernel_compat.h — same dual-
  signature pattern as cv200 hi_rtc.c. iounmap both windows in
  rtc_exit().

* `ir/hiir.c`: ioremap_nocache the 0x40-byte IR register window
  (0x20070000) and the single-word IOCONFIG cell (0x200f01F8) at
  init, redefine IR_REG_BASE / IOCONFIG as casts of the resulting
  void __iomem* pointers so WRITE_REG/READ_REG keep their offset
  arithmetic. iounmap on exit.

Both modules' writel/readl indirection through ((volatile u32 *)addr)
in WRITE_REG/READ_REG works equally well with the new pointer-typed
base addresses cast through unsigned long.

* kernel/obj/hi3516cv100: ship .cmd stubs for blob .o files

Mirrors PR #171 for cv200/av100 — modern kbuild's modpost requires a
companion .<file>.o.cmd file alongside each .o. The .o blobs in
kernel/obj/hi3516cv100/ were extracted from vendor SDK V1.0.B.0 with
no .cmd metadata, so a stub `savedcmd_kernel/obj/.../foo.o := :`
satisfies modpost on >= 5.x kernels without changing the build flow
on 3.0.8 (modpost on older kernels doesn't consult the .cmd files).

Force-added past .gitignore (which blanket-excludes .*.cmd because
buildroot's normal flow regenerates them from .o builds).

* kernel/osal_v1_shim: extend with V1-specific kernel-API shims

cv100 blobs (V1, Hi3518 SDK V1.0.B.0, kernel 3.0.8 base) reference a
broader set of removed-since-3.0 kernel symbols than cv200 does —
surface via modpost when linking against ARMv5 Linux 7.0.

Add re-exports for:

* __arm_ioremap / __iounmap — pre-3.10 ARM ioremap/iounmap helpers;
  wrap modern ioremap/iounmap.
* create_proc_entry — removed 3.10; wrap proc_create_data(..., NULL).
  Blob post-call writes to ->proc_fops / ->write_proc become no-ops
  (struct fields gone) but procfs entry exists; acceptable since
  cv100 procfs nodes are diagnostic.
* __bug — BUG() arch backend; panic() with file:line for clean fail.
* do_mmap_pgoff / do_munmap — kernel-internal mmap helpers, unexported
  in 4.x for security. Wrap vm_mmap / vm_munmap which carry security
  hooks; SELinux is off in OpenIPC's kernel config so semantics match
  for the cv100 mmz blob's MMZ-region user-mapping path.
* __copy_to_user / __copy_from_user — renamed to
  arm_copy_{to,from}_user on modern ARM. Signature-compatible alias.

* osal_v1_shim: rename static-inline __copy_*_user via Kbuild -D

Modern <linux/uaccess.h> defines __copy_to_user / __copy_from_user as
static-inline wrappers around raw_copy_*_user — but the cv100 .o blobs
expect them as exported symbols. Use the same Kbuild macro-rename
trick the shim already uses for _cond_resched: pass
-D__copy_to_user=...unused_inline so the header inline is emitted
under a throwaway name, then #undef inside the shim TU and provide
our own function under the legacy symbol name.

* osal_v1_shim: shim msecs_to_jiffies / __get_free_pages / module_put / __udelay

Round 2 of cv100_neo modpost unresolved symbols (after the first batch
covering __copy_*_user, __arm_ioremap, __iounmap, create_proc_entry,
__bug, do_mmap_pgoff, do_munmap):

* msecs_to_jiffies — static inline; alias to __msecs_to_jiffies.
* __get_free_pages — was a function pre-6.x; alias to get_free_pages_noprof.
* module_put — static inline with no exported helper for the put path;
  no-op stub since cv100 blob modules don't unload at runtime under QEMU.
* __udelay — now a macro dispatching arm_delay_ops.udelay; wrap the
  function-pointer call with the same 0x10C7 pre-scale the macro applies.

Two more Kbuild -D macro renames (msecs_to_jiffies, module_put) to
suppress the static-inline definitions in their respective headers.

* kernel/init/hi3516cv100: re-export blob __ksymtab entries via DECLARE_BLOB_FUNC

The cv100 .o blobs (V1, Hi3518 SDK V1.0.B.0) carry __ksymtab_* entries in
the legacy 8-byte struct kernel_symbol layout — modern modpost on Linux
7.0 doesn't recognize that section format, so cross-module symbol
references fail at link time with "undefined!" even though the symbol
is defined and "exported" inside the blob.

Mirror the existing cv200/av100 vou_init.c pattern: re-declare each
blob-exported symbol via DECLARE_BLOB_FUNC + EXPORT_SYMBOL in the
corresponding init wrapper. modpost regenerates the modern ksymtab
metadata from the wrapper's EXPORT_SYMBOL directives, and the legacy
__ksymtab section in the blob is ignored.

92 symbols across 9 init wrappers — mmz (18), vou (35), hidmac (14),
rc (10), sio + sensor_i2c (5 each), hiuser (3), isp + hifb (1 each).
Plus hi_sched_clock added to osal_v1_shim (no blob defines it, it's
a vendor wrapper for the kernel's sched_clock()).

* osal_v1_shim: shim __const_udelay / dma_*_coherent / no_llseek / rtc_*_to_*_tm / schedule_work

Final batch of cv100_neo modpost unresolved kernel symbols:

* __const_udelay — companion to __udelay, dispatches via
  arm_delay_ops.const_udelay.
* dma_alloc_coherent / dma_free_coherent — became macros over
  dma_alloc_attrs / dma_free_attrs with attrs=0.
* no_llseek — removed in 6.12. Provide as a function returning -ESPIPE
  (what the legacy kernel-internal helper did).
* rtc_time_to_tm / rtc_tm_to_time — renamed *_time64_* in 5.6;
  wrap with the cast from unsigned long → time64_t.
* schedule_work — static inline wrapper over queue_work_on; provide
  as a real exported function symbol.

Adds two more Kbuild -D renames (schedule_work, no_llseek) to suppress
the static-inline definitions in their headers.

---------

Co-authored-by: Vasiliy Yakovlev <vixand@openipc.org>
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