Skip to content

kernel/hi3516av100: bring up V2A generation against Linux 7.0 (issue #51)#165

Merged
widgetii merged 1 commit into
mainfrom
feat/av100-neo
May 21, 2026
Merged

kernel/hi3516av100: bring up V2A generation against Linux 7.0 (issue #51)#165
widgetii merged 1 commit into
mainfrom
feat/av100-neo

Conversation

@widgetii
Copy link
Copy Markdown
Member

Summary

  • Brings hi3516av100 (V2A, Cortex-A7) source modules up against the openipc/linux 7.0 base used by ev300_neo / av300_neo / cv500_neo / cv300_neo
  • Adds kernel/osal_v2a_shim/av100_shim.c — a tiny loadable module that re-exports legacy kernel symbols (do_gettimeofday, register_sysctl_table, init_timer_key) under their old names so the av100 vendor .ko blobs (compiled against 4.9.37) resolve at insmod time on >= 5.0 kernels
  • Mirrors the cv200 pattern from kernel/hi3516cv200: bring up V2 generation against Linux 7.0 (issue #51) #162 with three trims: no strlcpy (av100 blobs don't reference it per issue hi3516av100: OSAL shim layer for kernel version independence #50), no ARMv5-specific compat (Cortex-A7 is ARMv7), drops dead #include <mach/io.h> from mipi.c

Why two layers?

V2A (Cortex-A7) shares cv200's (V2, ARM926EJ-S) characteristic of having no OSAL — vendor .ko blobs call kernel APIs directly. Per issue #50, this is the cleanest non-OSAL legacy platform to bump — only 4 deprecated APIs across all blobs, none of the ARMv5 cache-op pain CV200/CV100 has.

  1. Source side: The open modules call APIs whose signatures changed across 4.9 → 7.0. Routed through existing compat helpers in kernel/compat/kernel_compat.h (COMPAT_TIMER_SETUP, COMPAT_USE_PROC_OPS, compat_access_ok, etc.) plus one new no_llseek → NULL macro for 6.12+ — the same shim cv200 PR kernel/hi3516cv200: bring up V2 generation against Linux 7.0 (issue #51) #162 added (av100's wdt/hi_wdt.c triggers it independently).
  2. Blob side: The vendor .ko blobs in kernel/obj/hi3516av100/ reference do_gettimeofday / init_timer_key / register_sysctl_table by symbol. Modern kernels no longer export those. The open_v2a_shim.ko module backfills them.

open_v2a_shim.ko design notes

Identical strategy to cv200_shim.c (#162), differences:

  • Drops strlcpy — av100 blobs don't reference it (cv200 did).
  • Trim shim: only 3 legacy symbols vs cv200's 4.
  • Gated #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) for the same reason as cv200 — on 4.9 (av100_lite production target) the legacy symbols are still native; re-defining triggers "conflicting types" errors. Benign no-op on 4.9.
  • printk → _printk (6.0 rename) is NOT handled here — same limitation as cv200 (<linux/printk.h> macro-defines printk, blocking a function-name redefinition).
  • Wired into kernel/hi3516av100.kbuild ahead of the MMZ entry so load_hisilicon orders it first.

Verification

  • hi3516av100_lite (kernel 4.9, production target) no-regression confirmed: rebuilt with this tree via HISILICON_OPENSDK_OVERRIDE_SRCDIR, diffed against nightly openipc.hi3516av100-nor-lite.tgz — 290/290 rootfs file count, same 61 hisilicon .ko set. v2a_shim.ko correctly not shipped on 4.9 (firmware install block doesn't reference it, and the module is gated to no-op anyway).
  • All 39 av100 source modules compile clean against the 7.0 base (openipc/linux upstream-patches).

Out of scope (follow-ups)

  • Sibling firmware PR needed to actually ship hi3516av100_neo: defconfig, neo kernel config, post-image script, opensdk hash bump. (No CI matrix row added here yet — staged for the firmware PR's red-then-green dance.)
  • struct timer_list.data drift between 4.9 and 4.15+ (chnl/viu/vpss blobs). Same blocker as cv200 — init_timer_key resolves but timers won't fire with the correct argument until either a kernel patch restores .data or the blobs are recompiled. Documented in the shim source.

Test plan

  • Linux 7.0 compile against openipc/linux:upstream-patches
  • hi3516av100_lite (kernel 4.9) byte-equivalence vs nightly — no regression
  • CI matrix row for hi3516av100_neo — deferred until firmware-side defconfig lands
  • Real-hardware test on hi3516av100 / hi3516dv100 board — deferred until full neo image is bootable

Sibling to #162 (cv200). User plans to test cv200 + av100 in parallel once both are ready.

🤖 Generated with Claude Code

)

Issue #51 tracks running modern kernels on the V2A family (hi3516av100,
hi3516dv100 — Cortex-A7). Like V2 (cv200, #162), V2A has no OSAL — the
vendor blobs from Hi3516A_SDK_V1.0.8.0 were compiled against 4.9.37 and
embed kernel-API call sites directly. Per issue #50, V2A is the cleanest
non-OSAL legacy platform: only 3 legacy symbols (do_gettimeofday in 10
blobs, register_sysctl_table in 2, init_timer_key in 3) plus the
printk → _printk rename — no strlcpy, no ARMv5-specific ops (Cortex-A7
is ARMv7), no create_proc_entry, no __arm_ioremap. Same two-layer
bring-up pattern as cv200: source-side compat shims + loadable
blob-symbol shim.

kernel_compat.h adds:

  - no_llseek -> NULL on >= 6.12 (helper removed in commit 868941b14441;
    same shim cv200 PR #162 added — needed independently because
    av100's wdt/hi_wdt.c references it). The two PRs converge on this
    line.

All other compat helpers av100 needs — COMPAT_TIMER_SETUP,
COMPAT_USE_PROC_OPS, compat_access_ok, compat_DEFINE_SEMAPHORE,
compat_platform_remove_ret / _return, compat_spi_busnum_to_controller,
COMPAT_NO_SYSCTL_TABLE, compat_register_sysctl, and the
do_gettimeofday macro — were already in place from earlier
cv300/cv500/cv200 work.

av100 sources updated to call the shims:

  - mmz/media-mem.c          : DEFINE_SEMAPHORE 1-arg via compat helper;
                               proc_ops branch under COMPAT_USE_PROC_OPS
  - mmz/mmz-userdev.c        : p4d_offset gated >= 4.11 (folded on
                               ARM32 but symbol absent on 4.9)
  - himedia/base.c           : dev_attrs -> dev_groups
                               (ATTRIBUTE_GROUPS); const-correctness
                               for bus_type callbacks on >= 6.3
  - init/base_init.c         : flat compat_register_sysctl path under
                               COMPAT_NO_SYSCTL_TABLE
  - mipi_rx/mipi.c           : drop dead #include <mach/io.h> (removed
                               from modern ARM); proc_ops branch;
                               platform_driver.remove return type
  - isp/.../drv/isp.c, ir/hiir.c, rtc/hi_rtc.c
                             : platform_driver.remove return type via
                               compat_platform_remove_ret / _return
  - ir/hiir.c, piris/piris.c, rtc/hi_rtc.c
                             : timer_setup + from_timer via
                               COMPAT_TIMER_SETUP
  - piris/piris.c            : access_ok via compat_access_ok
  - rtc/hi_rtc.c             : local spi_read/write renamed
                               hi_spi_read/write to avoid collision
                               with kernel header symbols (same fix
                               as cv200)
  - sensor_i2c/sensor_i2c.c  : I2C_M_16BIT_REG/DATA fallback macros;
                               i2c_new_device redirect to
                               i2c_new_client_device on >= 5.8
  - sensor_spi/sensor_spi.c  : spi_busnum_to_master via
                               compat_spi_busnum_to_controller on >= 6.4

kernel/osal_v2a_shim/av100_shim.c (new module, prefix open_v2a_shim.ko):

  - The entire shim body is gated >= 5.0 — pre-5.0 kernels still
    natively export every legacy symbol it re-exports, and re-defining
    them there triggers "conflicting types" compile errors and
    duplicate-export runtime errors. On 4.9 (av100_lite production
    target) the module is a benign no-op shell, printing one
    informational line at init.

  - On >= 5.0 it re-exports:
      do_gettimeofday       (removed 5.0; backed by ktime_get_real_ts64)
      register_sysctl_table (removed 6.6; routed through
                             register_sysctl_sz / register_sysctl with
                             a flat "hisi" path)
      init_timer_key        (callback signature changed in 4.15;
                             calls timer_setup but blobs using the
                             legacy void(*)(unsigned long) callback
                             will not fire correctly — see in-file
                             caveat)

  - strlcpy is intentionally NOT in the av100 shim (cv200 had it;
    av100 blobs don't reference it per issue #50).

  - printk -> _printk (6.0) is the same documented limitation as
    cv200: <linux/printk.h> macro-defines printk so a function-name
    redefinition isn't viable from this shim. Surfaces at blob
    insmod time on >= 6.0; doesn't affect 4.9 lite.

  - Wired into kernel/hi3516av100.kbuild ahead of the MMZ entry so
    load_hisilicon ordering puts it before any blob module.

Verification:

  * hi3516av100_lite (4.9 kernel, production target) rebuilt with this
    tree (via HISILICON_OPENSDK_OVERRIDE_SRCDIR) — rootfs file count
    matches nightly (290/290), hisilicon .ko set identical (61/61),
    QEMU lsmod parity confirmed. v2a_shim.ko correctly NOT shipped on
    4.9 (gated no-op; av100 firmware install block doesn't reference
    it). No regression.

  * Build-side: all 39 av100 source modules compile clean against the
    7.0 base (openipc/linux upstream-patches, the same base used by
    ev300_neo / av300_neo / cv500_neo / cv300_neo).

Out of scope for this PR (firmware-side sibling needed):

  - hi3516av100_neo defconfig, kernel config, neo post-image script
    (mirrors cv200 dependency on firmware-side PR)

Caveat — V2A blobs (chnl/viu/vpss) carry the same struct
timer_list.data drift between 4.9 and 4.15+ that cv200 has. The shim
resolves init_timer_key but the timers will never fire with the
correct argument until either a kernel patch restores .data or the
blob is recompiled. This will surface as broken video pipeline on
av100_neo and is the known remaining blocker for a full neo
bring-up — shared with cv200.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit 74d8a65 into main May 21, 2026
28 checks passed
widgetii added a commit that referenced this pull request May 22, 2026
…set (#170)

PRs #162 and #165 landed the initial V2/V2A bring-up shims based on the
issue #50 audit (4 symbols for cv200, 3 for av100). Exercising the
real firmware build for the first time (hi3516cv200_neo via the
upstream-patches 7.0 base) surfaced 8 more undefined symbols that
issue #50 missed — the audit only covered blob source-imports, not
the compiler-generated calls (memset → __memzero, kmalloc → __kmalloc
internal slowpath, etc.) and not the symbols pulled in via inline-
function expansion at blob-build time against the 4.9 kernel headers.

This commit extends both shims (V2 cv200 + V2A av100) to cover every
symbol modpost reports as undefined for the V2/V2A blob set on Linux
7.0. Verified empirically: hi3516cv200_neo now builds, boots in QEMU
to a login prompt, and meets the openipc/firmware QEMU DoD
(eth0 link, DHCP via SLIRP, ping 10.0.2.2). hi3516cv200_lite and
hi3516av100_lite (kernel 4.9 production targets) rebuilt against this
tree are byte-equivalent to nightly:

  - cv200_lite: 331/331 rootfs files, 68/68 hisilicon .ko, sets
    identical
  - av100_lite: 290/290 rootfs files, 61/61 hisilicon .ko, sets
    identical

kernel/compat/kernel_compat.h adds:

  - pte_offset_map(pmd, addr) -> pte_offset_kernel(...) on >= 6.5.
    Modern pte_offset_map() inlines to __pte_offset_map() which is
    NOT EXPORT_SYMBOL'd, so modules can't link it. pte_offset_kernel
    is a static inline over pmd_page_vaddr() + pte_index() — same
    user-page-table lookup the legacy code already did without
    locking. Source-side fix because the call is in our own
    cv200/av100 mmz-userdev usr_virt_to_phys, not the blob.

Both shim modules add the following exports (gated >= 5.0 so 4.9
lite stays a no-op shell):

   Symbol               Modern equivalent we forward to
   ──────────────────   ───────────────────────────────────────
   _cond_resched        __cond_resched
   __kmalloc            __kmalloc_noprof          (6.5+)
   kmem_cache_alloc     kmem_cache_alloc_noprof   (7.0 macro)
   __memzero            memset(ptr, 0, n)
   PDE_DATA             pde_data                  (5.17 rename)
   printk               vprintk via _printk       (6.0 rename)
   register_sysctl_paths register_sysctl_sz / register_sysctl
   jiffies_to_msecs     (MSEC_PER_SEC / HZ) * j   — header inline
   del_timer            timer_delete              (7.0 rename)
   vmalloc              vmalloc_noprof            (7.0 macro)
   dev_err              dev_vprintk_emit at KERN_ERR
   sched_setscheduler   sched_set_fifo / sched_set_normal — caller
                        priority is dropped (sched_set_fifo doesn't
                        accept one); SCHED_RR mapped to FIFO. Best-
                        effort for legacy blobs that just want
                        "raise above SCHED_NORMAL".

Two header-collision cases needed a Kbuild-level macro rename
(passed as -D... in CFLAGS_) so the static-inline definition in
<linux/sched.h> / <linux/jiffies.h> doesn't conflict with our
EXPORT_SYMBOL'd function under the same name:

  - _cond_resched         (static inline since 5.10 preempt-dynamic
                           rework; commit fe32d3cd5e8e)
  - jiffies_to_msecs      (static inline when HZ | MSEC_PER_SEC —
                           HZ=100 production config)

For the macro-style conflicts (kmem_cache_alloc, vmalloc, PDE_DATA,
printk, dev_err, del_timer) #undef in the shim source is sufficient.

Out of scope for this commit (still tracked in issue #51):

  - struct timer_list .data ABI drift (chnl/viu/vpss blobs) — the
    shim resolves init_timer_key but timers don't fire with the
    correct argument until the blob is recompiled. Documented in
    both shim sources. Surfaces as broken video pipeline on
    cv200_neo / av100_neo; not a load-time error.

  - hi3516av100 mainline DT / CRG — av100_neo firmware target is
    blocked on a separate openipc/linux PR (av100 has no mainline
    Kconfig / DT / clock-driver support yet, unlike cv200 which
    landed in OpenIPC/linux#43). cv200_neo unblocked.

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