Skip to content

axera: AX620E camera support on 5.15.73, ported from Axera's SDK kernel - #259

Merged
dimerr merged 25 commits into
axera-ax620efrom
axera-ax620e-sdk
Nov 18, 2026
Merged

dimerr merged 25 commits into
axera-ax620efrom
axera-ax620e-sdk

Conversation

@dimerr

@dimerr dimerr commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Axera's kernel support for the AX620E IP-camera SoC (2x Cortex-A53), ported from Axera's SDK kernel (4.19.125) to 5.15.73 — the version the AX620E camera's vendor media modules (ax_*.ko) are built against. With it, OpenIPC firmware for the AX620E boots and loads the full vendor driver stack.

What's in it (13 commits on axera-ax620e)

  • SDK headers and dt-bindings; GPIO (axera,ax-apb-gpio) and reset-controller drivers; the remaining peripheral clock gates (UART, GPIO, I2C, timers, PWM); the Axera UART in 8250_dw.
  • SoC drivers the vendor modules need: hwinfo, os_mem, hrtimer, bandwidth limiter, sysmap, timers, display stubs, and the built-in OSAL with /proc/ax_proc (the ~265 kernel symbols the vendor ax_*.ko import all resolve).
  • Vendor DesignWare SSI driver for the SPI NOR with AX_DMAPER DMA; mtd: name the MTD after a devicetree label (the stock layout's spi_nor.0).
  • Ethernet: dwmac-axera EQOS glue (GMAC4) and the internal 10/100 EPHY driver.
  • Watchdog (ax_wdt), which is also the reboot path.
  • arm64: dts: axera: the Xiongmai AX620E IP camera devicetree (from the stock camera's own DTB, compiles back to an identical tree) and ax620e_xm_ipc_defconfig.

Vendor-module ABI notes: the stock kernel runs at HZ=100, the modules' module layout only matches with CONFIG_KPROBES=y, and the release string must be exactly 5.15.73.

Tested (QEMU, OpenIPC/qemu-bench -M ax620e)

OpenIPC U-Boot → this kernel on both CPUs (vendor spin-table) → rootfs from NOR via the vendor SPI driver with the jffs2 overlay → login, DHCP, SSH; load_axera loads all 21 vendor modules with no oops (ax_vdec reports "Unknown HW" exactly as on the stock firmware, because QEMU has no decoder model); watchdog reboot works.

Not yet ported: RTC, thermal, SD, USB, audio, display; no mtdsplit. Not yet verified on real hardware: EPHY setup, watchdog reboot sequence, dual-mode SPI reads, clock-gate bits derived from the binding's ID order.

Used by the AX620E part of OpenIPC/firmware#2670.

From the Axera maix_ax620e_sdk 4.19.125 kernel: the display, mailbox,
hrtimer, apb timer and board-info headers the vendor drivers use, and the
dt-binding headers of the AX620E devicetree. ax_printk.h is rewritten for
5.15: the vendor modules call _ax_printk(id, tag, level, fmt, ...).
…rivers

Ported from the Axera SDK 4.19.125 kernel. Without them every AX620E
device with resets or GPIOs (Ethernet, the SPI NOR chip select on
GPIO2_29) defers forever.

GPIO numbering stays static in probe order as in the vendor kernel: the
Xiongmai XmGpio.ko asks for legacy GPIO numbers. The reset controller
takes #reset-cells from the node (5.15's reset core checks it before
of_xlate).
…rs, PWM)

The AX620E vendor 5.15 devicetree points the UARTs at periph
UART0_EB/PCLK_UART0_EB (baudclk/apb_pclk) instead of a clock-frequency;
without those clocks dw8250 fails with "clock rate not defined".
Add the UART source mux (MUX0[18:17], as the SDK's 8250_axera.c sets
it) and every EB0..EB3 gate the binding header lists; the bit of each
follows the header's ID order, which matches every gate the SDK driver
already had.
The Axera UART is a plain DesignWare APB UART; the vendor devicetree
names it axera,ax-apb-uart. Match it in 8250_dw and as an earlycon.
…ay stubs

The Axera SDK SoC drivers the vendor media modules and their user space
expect: /proc/ax_proc/{chip_type,board_id,uid} (ax_hwinfo),
ax_os_mem_* per-module allocation accounting, ax_hrtimer on the DW
timer, the DDR bandwidth limiter, /dev/ax_sysmap, the APB/periph
timer32 channels and ax_display_register() stubs for builds without
DRM. Ported to 5.15 (proc_ops, ax_printk.h).
The closed AX620E modules (ax_sys, ax_cmm, ax_pool, ax_npu, ax_ivps,
ax_venc, ...) are built against Axera's 5.15.73 kernel, which carries
the OSAL (AX_OSAL_*) built in and creates /proc/ax_proc at boot. This
is the SDK's kernel/osal/linux OSAL with the export names of the vendor
5.15 kernel (AX_OSAL_SYNC_wait_* without the leading __, checked
against the stock kernel's code), plus:

- /proc/ax_proc, /proc/ax_proc/version and the ax_printk log
  (/proc/ax_proc/kmsg; errors also go to the kernel log), which the
  vendor kernel keeps in fs/proc and kernel/printk;
- platform_device/platform_driver pointers OSAL's platform and devfreq
  wrappers hang their data on, as in the vendor kernel.

With this all 265 kernel imports of the 21 stock modules resolve.
…MAPER

The AX620E boot flash sits on a DW SSI (snps,dwc-ssi-1.03a) with a GPIO
chip select. Axera's driver (from the SDK 4.19.125 kernel) runs it
polled with enhanced dual/quad reads and AX_DMAPER receive DMA; the
upstream spi-dw core needs the EEPROM-read mode and the IRQ instead.
Ported to 5.15 as SPI_AXERA/SPI_AXERA_MMIO/SPI_AXERA_DMA, plus the
AX_DMAPER dmaengine driver (axera,dma-per). The polled loop gets a one
second timeout so a dead controller no longer hangs the boot.
From the Axera SDK 4.19.125 kernel: clocks, EMAC/EPHY resets (the EPHY
must be taken out of shutdown and reset before the MAC sees a PHY),
RMII/RGMII selection and speed setup for axera,dwmac-4.10a.
From the Axera SDK 4.19.125 kernel: the Ethernet PHY built into the
AX620E (id 0x00441400) the IP cameras use over RMII.
stmmac_probe_config_dt() only knows snps,dwmac-4.10a as GMAC4; under
axera,dwmac-4.10a the core came up as a DWMAC100 with no PHY. Do in the
glue what the SDK did by patching stmmac_platform.c.
ax620e-xm-ipc.dts is the devicetree the camera's stock 5.15.73 kernel
boots with (FIT in /boot/uImage of the IVG-A6 firmware), turned back
into source with labels (dtb -> dts, phandles -> &labels named after
the SDK's AX620E.dtsi; it compiles back to the same tree). It keeps the
vendor nodes (axera,cmm, axera,sys, axera,npu, venc, ivps, ...) the
closed media modules bind to, the spin-table CPU release (the NOR
camera has no ATF) and leaves bootargs to U-Boot.

ax620e_xm_ipc_defconfig: a camera kernel for it, built in what the board
needs (clocks, pinctrl, GPIO, resets, vendor SPI NOR, DMAPER, EQOS +
EPHY, UART, I2C, watchdog, OSAL), squashfs xz + jffs2 + overlay on MTD,
modules on. Matches the vendor kernel where the closed ax_*.ko depend
on it: SMP, PREEMPT, HZ=100, module unload, no modversions, and KPROBES
(struct module is 0x300 bytes with exit at 0x2e0 in the vendor .ko).
Build with an empty LOCALVERSION: the modules' vermagic is 5.15.73.
The AX620E vendor kernel calls its boot NOR spi_nor.0, and the camera's
U-Boot environment and user space pass mtdparts=spi_nor.0:...; without
it the partitions are never created. Take the name from the flash
node's label property when there is one (dev_name() otherwise).
From the Axera SDK 4.19.125 kernel, ported to 5.15. Without PSCI (the
NOR cameras have no ATF) the watchdog's restart handler is the only way
to reboot; without it "reboot" hangs.

The AX620E vendor 5.15 devicetree has one reg and none of the SDK's
clk_set/aclk/pclk/arst/prst cells (the bootloader leaves the block
clocked and out of reset), so that block is optional. The watchdog is
left stopped until user space opens it, as the vendor kernel does:
the Xiongmai user space opens /dev/watchdog and gives up when its own
ioctl fails, which must not end in a reset.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Add AX620E camera support to the 5.15.73 Axera kernel

✨ Enhancement ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Port AX620E board support and peripheral drivers so the Xiongmai camera can boot from SPI NOR.
• Add the built-in Axera OSAL and SoC services required by the vendor media modules.
• Provide the stock-derived devicetree and ABI-compatible defconfig for OpenIPC firmware.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 5 capabilities

  • 5 affected capabilities span independent functional scopes: AX620E Ethernet integration, AX620E camera/media integration, AX620E persistent storage integration, AX620E platform bring-up, AX620E reliability/reset integration.
  • The DT, clock/reset/GPIO/UART/timer/watchdog and OSAL providers jointly define one board bring-up and core-services behavior.
  • They are separate implementation hops but serve the same platform integration outcome.
  • SPI transfers, DMA descriptors, SPI-NOR access and MTD partition naming form one end-to-end storage integration.
  • The partition-label change affects this storage behavior specifically and does not by itself reach unrelated network or camera functions.
  • MAC platform setup, speed clock correction and the matching internal EPHY implement one wired-network behavior.
  • LED GPIO handling is ancillary to the same integration and is not treated as an independent capability.
  • Sensor, ISP, NPU, CMM, mailbox, reserved memory, timing and encoding nodes serve the bounded camera/media pipeline.
  • They are grouped despite spanning drivers because the end-to-end outcome is capture and processing of camera media.
  • Watchdog servicing and the board reboot mechanism are two outcomes of the same AX620E watchdog/reset integration and share its registers and DT instances.
Behavioral complexity 🔴 High 🧩 Interacting branches, Concurrent ordering

  • Before, the repository lacked this Axera controller path.
  • After, SPI transfers can use separate TX/RX DMA channels, callbacks, FIFO interrupts, timeout handling and channel suspend/resume.
  • The new correctness condition is that DMA ownership, descriptor visibility, FIFO state, completion ordering and SPI message finalization agree for every transfer mode.
  • This is more than routine use of an existing mapping helper.
Potential damage 🔴 High 🩹 Critical loss

  • A boot-critical provider or malformed board resource can prevent the system from reaching userspace.
  • If boot completes but one provider fails, the affected core service remains unavailable.
  • Recovery generally requires replacing the kernel/DTB; a source revert does not repair a device already booted with the bad image until rebooted.
  • Code rollback is straightforward for an unflashed image.
  • A deployed board needs a bootable replacement image and reboot; no automatic repair path is established.
Assessed commit acc58f2
Diagram

graph TD
  DT["Camera devicetree"] --> CORE["Clocks GPIO resets"] --> SPI["SPI and DMA"] --> NOR["NOR rootfs"]
  DT --> NET["Ethernet and PHY"]
  DT --> SOC["SoC services"] --> OSAL["Built-in OSAL"] --> MOD["Vendor modules"]
  CORE --> NET
  CORE --> SOC
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Extend upstream DesignWare SPI
  • ➕ Avoids maintaining a parallel SSI driver
  • ➕ Could reuse upstream SPI maintenance and tests
  • ➖ Requires integrating AX620E-specific transfer modes and AX_DMAPER behavior
  • ➖ Increases uncertainty for the SPI NOR boot path
2. Split the vendor devicetree into shared SoC and board files
  • ➕ Makes subsequent AX620E boards easier to add
  • ➕ Reduces duplication between boards
  • ➖ Makes comparison with the stock camera DTB harder
  • ➖ Adds migration risk to vendor module bindings

Recommendation: Keep the stock-compatible devicetree and vendor SPI path for the initial boot and module-ABI milestone. Consider upstream SPI integration and shared devicetree extraction after real-hardware validation; neither should block establishing a working baseline.

Files changed (124) +31856 / -1

Enhancement (93) +31419 / -0
ax620e-xm-ipc.dtsDescribe the Xiongmai AX620E camera +9976/-0

Describe the Xiongmai AX620E camera

• Adds the stock-derived hardware tree, including CPUs, memory, clocks, peripherals, storage, networking, and vendor media nodes. Retains vendor bindings needed by the external modules.

arch/arm64/boot/dts/axera/ax620e-xm-ipc.dts

clk-ax620e.cComplete AX620E peripheral clock registration +87/-0

Complete AX620E peripheral clock registration

• Adds the UART source mux and remaining UART, GPIO, I2C, timer, and PWM gates referenced by the vendor devicetree.

drivers/clk/axera/clk-ax620e.c

axera-dma-per.cPort the AX_DMAPER controller +1317/-0

Port the AX_DMAPER controller

• Adds the vendor-derived DMA engine implementation used by peripheral clients, including SPI receive DMA.

drivers/dma/axera-dma-per/axera-dma-per.c

axera-dma-per.hDefine AX_DMAPER hardware interfaces +276/-0

Define AX_DMAPER hardware interfaces

• Provides controller registers, descriptors, and internal definitions for the DMA implementation.

drivers/dma/axera-dma-per/axera-dma-per.h

deb-gpio-lp-axera.cAdd debounced low-power GPIO wakeup +327/-0

Add debounced low-power GPIO wakeup

• Ports the Axera low-power GPIO interrupt and wakeup interface.

drivers/gpio/deb-gpio-lp-axera.c

gpio-axera.cPort AX620E APB GPIO +538/-0

Port AX620E APB GPIO

• Adds GPIO and interrupt support while preserving probe-order-based legacy GPIO numbering needed by vendor modules.

drivers/gpio/gpio-axera.c

dwmac-axera-plat.cConnect AX620E Ethernet to stmmac +194/-0

Connect AX620E Ethernet to stmmac

• Adds platform probing and devicetree handling for the Axera EQOS controller and PHY settings.

drivers/net/ethernet/stmicro/stmmac/dwmac-axera-plat.c

dwmac-axera.cConfigure AX620E EQOS hardware +803/-0

Configure AX620E EQOS hardware

• Ports Axera-specific GMAC clock, reset, interface, and internal EPHY initialization.

drivers/net/ethernet/stmicro/stmmac/dwmac-axera.c

dwmac-axera.hDefine Axera EQOS integration data +109/-0

Define Axera EQOS integration data

• Declares controller-specific settings and interfaces shared by the Ethernet glue files.

drivers/net/ethernet/stmicro/stmmac/dwmac-axera.h

axera-ephy.cPort AX620E internal Ethernet PHY +771/-0

Port AX620E internal Ethernet PHY

• Adds vendor-derived PHY setup and link handling for the SoC's 10/100 Ethernet interface.

drivers/net/phy/axera-ephy.c

axera_reset.cPort Axera syscon resets +300/-0

Port Axera syscon resets

• Adds reset-controller operations for vendor reset bindings, including clock handling and devicetree reset-cell translation.

drivers/reset/axera_reset/axera_reset.c

axera_dw_apb_timer.cPort Axera APB timer channels +502/-0

Port Axera APB timer channels

• Provides the vendor timer-channel interfaces consumed by Axera services.

drivers/soc/axera/apb_timer/axera_dw_apb_timer.c

ax_hwinfo.cExpose Axera hardware information +262/-0

Expose Axera hardware information

• Provides chip, board, and identifier information through the vendor-compatible proc interface.

drivers/soc/axera/ax_hwinfo/ax_hwinfo.c

ax_hwinfo.hDeclare hardware-information data +15/-0

Declare hardware-information data

• Defines internal types and declarations for the Axera hardware-information service.

drivers/soc/axera/ax_hwinfo/ax_hwinfo.h

ax_proc.cCreate vendor-compatible proc and logging +164/-0

Create vendor-compatible proc and logging

• Creates /proc/ax_proc and implements the Axera printk ABI with a readable log ring and configurable console forwarding.

drivers/soc/axera/ax_proc.c

axera_hrtimer.cPort vendor high-resolution timer service +802/-0

Port vendor high-resolution timer service

• Implements the Axera timer API used by the media stack.

drivers/soc/axera/axera_hrtimer/axera_hrtimer.c

ax_bw_limiter.cPort Axera DDR bandwidth limiter +955/-0

Port Axera DDR bandwidth limiter

• Adds the bandwidth-control service expected by vendor components.

drivers/soc/axera/bwlimiter/ax_bw_limiter.c

display_dummy.cSupply display registration symbols +46/-0

Supply display registration symbols

• Provides no-op display and virtual-framebuffer registration symbols so media modules can link without a display driver.

drivers/soc/axera/display_dummy/display_dummy.c

ax_os_malloc.cPort Axera memory accounting +1062/-0

Port Axera memory accounting

• Implements vendor memory allocation and per-module accounting interfaces.

drivers/soc/axera/os_mem/ax_os_malloc.c

ax_os_mem.hDefine os_mem interfaces +46/-0

Define os_mem interfaces

• Declares types and interfaces for Axera memory accounting.

drivers/soc/axera/os_mem/ax_os_mem.h

axdev.hDefine Axera device-bus interfaces +95/-0

Define Axera device-bus interfaces

• Declares vendor device and driver structures used by the OSAL bus.

drivers/soc/axera/osal/include/axdev.h

axdev_log.hDefine Axera device logging helpers +41/-0

Define Axera device logging helpers

• Provides logging declarations and macros for the vendor device layer.

drivers/soc/axera/osal/include/axdev_log.h

base.hShare OSAL device-layer definitions +26/-0

Share OSAL device-layer definitions

• Defines common declarations used by the Axera bus and device implementations.

drivers/soc/axera/osal/include/base.h

osal_ax.hDeclare the primary OSAL API +534/-0

Declare the primary OSAL API

• Defines vendor-compatible task, synchronization, timer, and other kernel abstraction interfaces.

drivers/soc/axera/osal/include/osal_ax.h

osal_cmm_ax.hDeclare CMM memory interfaces +37/-0

Declare CMM memory interfaces

• Provides allocation, cache, mapping, and block-information declarations for CMM integration.

drivers/soc/axera/osal/include/osal_cmm_ax.h

osal_dev_ax.hDeclare OSAL device abstractions +323/-0

Declare OSAL device abstractions

• Defines vendor device-facing types and API declarations used by media modules.

drivers/soc/axera/osal/include/osal_dev_ax.h

osal_kfifo.hDefine Axera FIFO compatibility types +542/-0

Define Axera FIFO compatibility types

• Provides the vendor-prefixed FIFO layout and helpers.

drivers/soc/axera/osal/include/osal_kfifo.h

osal_lib_ax.hDeclare OSAL library helpers +102/-0

Declare OSAL library helpers

• Exposes vendor utility interfaces implemented by the OSAL.

drivers/soc/axera/osal/include/osal_lib_ax.h

osal_list.hDefine OSAL list helpers +722/-0

Define OSAL list helpers

• Adds doubly linked-list types and operations used by the Axera device layer.

drivers/soc/axera/osal/include/osal_list.h

osal_list_ax.hDefine AX-prefixed list helpers +484/-0

Define AX-prefixed list helpers

• Adds the vendor-facing list types and operations used by OSAL consumers.

drivers/soc/axera/osal/include/osal_list_ax.h

osal_logdebug_ax.hDeclare OSAL logging and debug interfaces +90/-0

Declare OSAL logging and debug interfaces

• Defines debug and logging interfaces for Axera components.

drivers/soc/axera/osal/include/osal_logdebug_ax.h

osal_mailbox.hDeclare OSAL mailbox wrappers +26/-0

Declare OSAL mailbox wrappers

• Defines the callback and message interfaces for mailbox compatibility.

drivers/soc/axera/osal/include/osal_mailbox.h

osal_pm_ax.hDefine vendor power-management interfaces +44/-0

Define vendor power-management interfaces

• Declares power states, subsystem identifiers, and OSAL power-management operations.

drivers/soc/axera/osal/include/osal_pm_ax.h

osal_type_ax.hDefine common Axera OSAL types +60/-0

Define common Axera OSAL types

• Provides shared vendor types used throughout the compatibility API.

drivers/soc/axera/osal/include/osal_type_ax.h

osal_user_ax.hDefine vendor user-interface constants +91/-0

Define vendor user-interface constants

• Provides Axera-facing constants and compatibility definitions for user-facing interfaces.

drivers/soc/axera/osal/include/osal_user_ax.h

osal_address.cWrap I/O and user-memory access +58/-0

Wrap I/O and user-memory access

• Exports vendor-named mapping, unmapping, and user-copy operations.

drivers/soc/axera/osal/osal_address.c

osal_atomic.cImplement OSAL atomic operations +172/-0

Implement OSAL atomic operations

• Exports allocation, update, comparison, and teardown operations for vendor atomic objects.

drivers/soc/axera/osal/osal_atomic.c

osal_axera_core.cRegister the Axera device bus +383/-0

Register the Axera device bus

• Adds the vendor device-bus, driver matching, and power-management integration.

drivers/soc/axera/osal/osal_axera_core.c

osal_axera_misc_device.cExpose vendor OSAL character devices +232/-0

Expose vendor OSAL character devices

• Implements Axera device registration, minor dispatch, and associated character-device infrastructure.

drivers/soc/axera/osal/osal_axera_misc_device.c

osal_barrier.cExport OSAL memory barriers +68/-0

Export OSAL memory barriers

• Wraps kernel and architecture memory-ordering operations under vendor symbol names.

drivers/soc/axera/osal/osal_barrier.c

osal_bwlimiter.cBridge OSAL bandwidth controls +61/-0

Bridge OSAL bandwidth controls

• Connects vendor OSAL calls to the Axera bandwidth-limiter service.

drivers/soc/axera/osal/osal_bwlimiter.c

osal_cache.cExport vendor cache operations +81/-0

Export vendor cache operations

• Provides cache flush and invalidate wrappers used by media components.

drivers/soc/axera/osal/osal_cache.c

osal_clk.cWrap kernel clock operations +106/-0

Wrap kernel clock operations

• Exposes clock acquisition and control through the vendor OSAL interface.

drivers/soc/axera/osal/osal_clk.c

osal_debug.cBridge debug logging and proc entries +278/-0

Bridge debug logging and proc entries

• Adds vendor logging, proc creation, and sequence-file helper exports.

drivers/soc/axera/osal/osal_debug.c

osal_devdfs.cBridge device-frequency and OPP APIs +148/-0

Bridge device-frequency and OPP APIs

• Wraps devfreq and operating-point operations for vendor drivers.

drivers/soc/axera/osal/osal_devdfs.c

osal_device.cImplement OSAL device operations +757/-0

Implement OSAL device operations

• Provides vendor device registration, polling, and memory-mapping interfaces.

drivers/soc/axera/osal/osal_device.c

osal_devtree.cWrap devicetree property reads +65/-0

Wrap devicetree property reads

• Exports OSAL interfaces for reading string, boolean, and integer properties.

drivers/soc/axera/osal/osal_devtree.c

osal_fileops.cWrap kernel file operations +56/-0

Wrap kernel file operations

• Exports vendor-named file open, close, read, and write operations.

drivers/soc/axera/osal/osal_fileops.c

osal_i2c.cBridge OSAL I2C access +183/-0

Bridge OSAL I2C access

• Implements vendor I2C read, write, and lifecycle interfaces.

drivers/soc/axera/osal/osal_i2c.c

osal_interrupt.cWrap interrupt management +86/-0

Wrap interrupt management

• Exports vendor IRQ request, release, enable, disable, and state operations.

drivers/soc/axera/osal/osal_interrupt.c

osal_kfifo.cImplement Axera FIFO operations +372/-0

Implement Axera FIFO operations

• Provides runtime FIFO operations matching the vendor compatibility types.

drivers/soc/axera/osal/osal_kfifo.c

osal_kmalloc.cWrap kernel memory allocation +129/-0

Wrap kernel memory allocation

• Exports vendor allocation, free, and address-mapping helpers.

drivers/soc/axera/osal/osal_kmalloc.c

osal_mailbox.cSupply OSAL mailbox symbols +39/-0

Supply OSAL mailbox symbols

• Forwards mailbox calls when supported and supplies compatibility stubs otherwise.

drivers/soc/axera/osal/osal_mailbox.c

osal_math.cExport OSAL math helpers +86/-0

Export OSAL math helpers

• Provides vendor-named arithmetic helpers used by media modules.

drivers/soc/axera/osal/osal_math.c

osal_mem.cTranslate vendor memory addresses +164/-0

Translate vendor memory addresses

• Provides user and kernel virtual-to-physical address helpers.

drivers/soc/axera/osal/osal_mem.c

osal_mutex.cImplement OSAL mutex operations +188/-0

Implement OSAL mutex operations

• Exports vendor-compatible mutex creation and synchronization operations.

drivers/soc/axera/osal/osal_mutex.c

osal_percpu.cWrap per-CPU operations +47/-0

Wrap per-CPU operations

• Exposes per-CPU facilities through the Axera compatibility layer.

drivers/soc/axera/osal/osal_percpu.c

osal_platform.cBridge platform-device operations +372/-0

Bridge platform-device operations

• Implements OSAL registration and interaction with Linux platform devices and drivers.

drivers/soc/axera/osal/osal_platform.c

osal_power.cSupply vendor power interfaces +44/-0

Supply vendor power interfaces

• Provides OSAL power-management compatibility calls.

drivers/soc/axera/osal/osal_power.c

osal_prefetch.cExport prefetch wrappers +23/-0

Export prefetch wrappers

• Provides vendor-named read and write prefetch helpers.

drivers/soc/axera/osal/osal_prefetch.c

osal_reset.cWrap reset-controller access +57/-0

Wrap reset-controller access

• Exports vendor-named reset acquisition, assertion, and deassertion operations.

drivers/soc/axera/osal/osal_reset.c

osal_semaphore.cImplement OSAL semaphores +108/-0

Implement OSAL semaphores

• Provides vendor semaphore initialization, wait, signal, and teardown operations.

drivers/soc/axera/osal/osal_semaphore.c

osal_sort.cSupply OSAL sorting routines +270/-0

Supply OSAL sorting routines

• Exports vendor sorting and context-aware sorting interfaces.

drivers/soc/axera/osal/osal_sort.c

osal_spinlock.cImplement OSAL spinlocks +128/-0

Implement OSAL spinlocks

• Exports vendor spinlock setup, locking, IRQ-safe locking, and teardown operations.

drivers/soc/axera/osal/osal_spinlock.c

osal_srcu.cWrap SRCU synchronization +114/-0

Wrap SRCU synchronization

• Exports SRCU initialization, read-side locking, synchronization, and cleanup.

drivers/soc/axera/osal/osal_srcu.c

osal_string.cExport vendor string utilities +303/-0

Export vendor string utilities

• Provides vendor-prefixed string comparison, copy, concatenation, and search helpers.

drivers/soc/axera/osal/osal_string.c

osal_task.cBridge OSAL tasks to kernel threads +129/-0

Bridge OSAL tasks to kernel threads

• Implements vendor thread lifecycle, scheduling, and current-task interfaces.

drivers/soc/axera/osal/osal_task.c

osal_timer.cImplement OSAL time and timer APIs +236/-0

Implement OSAL time and timer APIs

• Wraps timers, delays, clocks, jiffies, and Axera high-resolution timers.

drivers/soc/axera/osal/osal_timer.c

osal_waitqueue.cImplement OSAL wait queues +246/-0

Implement OSAL wait queues

• Exports vendor wait, timeout, wakeup, and queue-lifecycle operations.

drivers/soc/axera/osal/osal_waitqueue.c

osal_workqueue.cImplement OSAL work scheduling +188/-0

Implement OSAL work scheduling

• Wraps immediate and delayed kernel work, including cancellation and teardown.

drivers/soc/axera/osal/osal_workqueue.c

ax_sysmap.cExpose Axera physical mapping device +124/-0

Expose Axera physical mapping device

• Adds the ax_sysmap misc device and mmap interface used for vendor userspace mappings.

drivers/soc/axera/sysmap/ax_sysmap.c

axera_periph_timer32.cPort AX620E peripheral timer32 +418/-0

Port AX620E peripheral timer32

• Provides vendor peripheral timer32 functionality for AX620E.

drivers/soc/axera/timer32/axera_periph_timer32.c

spi-axera-dma.cIntegrate AX_DMAPER with SSI reads +512/-0

Integrate AX_DMAPER with SSI reads

• Provides the vendor SPI controller's optional receive-DMA path.

drivers/spi/spi-axera-dma.c

spi-axera-mmio.cProbe memory-mapped Axera SSI +255/-0

Probe memory-mapped Axera SSI

• Adds platform resource, clock, reset, and devicetree integration for the SPI controller.

drivers/spi/spi-axera-mmio.c

spi-axera.cPort vendor DesignWare SSI transfers +768/-0

Port vendor DesignWare SSI transfers

• Adds the AX620E SPI controller path used by boot NOR, including polled and enhanced reads.

drivers/spi/spi-axera.c

spi-axera.hDefine Axera SSI controller data +322/-0

Define Axera SSI controller data

• Provides controller register definitions and shared transfer structures.

drivers/spi/spi-axera.h

8250_dw.cRecognize the Axera UART binding +1/-0

Recognize the Axera UART binding

• Maps axera,ax-apb-uart to the DesignWare 8250 platform driver.

drivers/tty/serial/8250/8250_dw.c

8250_early.cRecognize the Axera early console +1/-0

Recognize the Axera early console

• Allows the AX620E UART binding to select 8250 early-console support.

drivers/tty/serial/8250/8250_early.c

ax_wdt.cPort the Axera watchdog and reboot path +515/-0

Port the Axera watchdog and reboot path

• Implements the AX620E watchdog driver, including the SoC reboot mechanism.

drivers/watchdog/ax_wdt.c

axera_display.hDefine Axera display binding constants +42/-0

Define Axera display binding constants

• Adds display identifiers and constants from the Axera SDK.

include/dt-bindings/display/axera_display.h

AX620E_reserve_mem_define.hDefine AX620E reserved-memory macros +67/-0

Define AX620E reserved-memory macros

• Adds SDK reserved-memory definitions for AX620E firmware configurations.

include/dt-bindings/memory/AX620E_reserve_mem_define.h

axera-dt-phy.hDefine Axera PHY binding values +23/-0

Define Axera PHY binding values

• Adds PHY-related devicetree constants used by Axera hardware descriptions.

include/dt-bindings/phy/axera-dt-phy.h

ax_display_hal.hDeclare Axera display HAL ABI +250/-0

Declare Axera display HAL ABI

• Adds display structures and callbacks expected by vendor components.

include/linux/ax_display_hal.h

ax_hrtimer.hDeclare Axera hrtimer API +38/-0

Declare Axera hrtimer API

• Provides the shared timer interface used by Axera services and modules.

include/linux/ax_hrtimer.h

ax_mailbox.hDefine Axera mailbox messages +20/-0

Define Axera mailbox messages

• Declares message layout, callbacks, and master identifiers for mailbox compatibility.

include/linux/ax_mailbox.h

ax_printk.hDeclare vendor logging ABI +52/-0

Declare vendor logging ABI

• Defines Axera logging levels and the _ax_printk signature consumed by vendor modules.

include/linux/ax_printk.h

ax_timestamp.hProvide Axera timestamp declarations +8/-0

Provide Axera timestamp declarations

• Adds the shared timestamp header used by the vendor interfaces.

include/linux/ax_timestamp.h

ax_vfb.hDeclare virtual framebuffer interfaces +44/-0

Declare virtual framebuffer interfaces

• Defines vendor framebuffer types and registration declarations satisfied by display stubs.

include/linux/ax_vfb.h

axera_dw_apb_timer.hDeclare APB timer interfaces +69/-0

Declare APB timer interfaces

• Provides shared declarations for Axera DesignWare APB timer channels.

include/linux/axera_dw_apb_timer.h

platform_device.hAttach OSAL data to platform objects +6/-0

Attach OSAL data to platform objects

• Conditionally adds Axera pointers to platform devices and drivers for vendor devfreq and driver integration.

include/linux/platform_device.h

ax_boardinfo.hDefine board-information interfaces +93/-0

Define board-information interfaces

• Adds shared Axera chip and board-information definitions used by SoC drivers.

include/linux/soc/axera/ax_boardinfo.h

ax_bw_limiter.hDeclare bandwidth-limiter API +30/-0

Declare bandwidth-limiter API

• Provides shared declarations for the Axera DDR bandwidth limiter.

include/linux/soc/axera/ax_bw_limiter.h

chip_reg.hDefine Axera chip register constants +15/-0

Define Axera chip register constants

• Adds shared register definitions for AX620E SoC support.

include/linux/soc/axera/chip_reg.h

Bug fix (1) +4 / -0
core.cHonor devicetree SPI NOR labels +4/-0

Honor devicetree SPI NOR labels

• Uses a flash node's label as the MTD name when no name is already set, preserving the stock partition naming.

drivers/mtd/spi-nor/core.c

Other (30) +433 / -1
MakefileBuild the Xiongmai AX620E DTB +1/-0

Build the Xiongmai AX620E DTB

• Adds the camera devicetree to the Axera DTB build.

arch/arm64/boot/dts/axera/Makefile

ax620e_xm_ipc_defconfigConfigure an AX620E OpenIPC kernel +269/-0

Configure an AX620E OpenIPC kernel

• Enables the board's boot, flash, network, watchdog, and Axera support. Sets HZ=100 and KPROBES for vendor-module ABI compatibility.

arch/arm64/configs/ax620e_xm_ipc_defconfig

KconfigExpose AX_DMAPER configuration +10/-0

Expose AX_DMAPER configuration

• Adds the peripheral DMA controller option and its DMA engine dependencies.

drivers/dma/Kconfig

MakefileBuild the Axera DMA driver +1/-0

Build the Axera DMA driver

• Connects AX_DMAPER to the DMA subsystem build.

drivers/dma/Makefile

MakefileDefine AX_DMAPER build objects +2/-0

Define AX_DMAPER build objects

• Adds the local build rule for the peripheral DMA controller.

drivers/dma/axera-dma-per/Makefile

KconfigExpose Axera GPIO options +15/-0

Expose Axera GPIO options

• Adds configuration options for APB GPIO and the debounced low-power GPIO wakeup driver.

drivers/gpio/Kconfig

MakefileWire Axera GPIO drivers into the build +2/-0

Wire Axera GPIO drivers into the build

• Builds the APB GPIO and optional low-power GPIO implementations.

drivers/gpio/Makefile

KconfigExpose Axera DWMAC support +8/-0

Expose Axera DWMAC support

• Adds a configuration option for AX620E EQOS Ethernet integration.

drivers/net/ethernet/stmicro/stmmac/Kconfig

MakefileBuild Axera DWMAC glue +2/-0

Build Axera DWMAC glue

• Includes the Axera platform and controller glue in the stmmac build.

drivers/net/ethernet/stmicro/stmmac/Makefile

KconfigExpose internal Axera EPHY +6/-0

Expose internal Axera EPHY

• Adds the AX620E Ethernet PHY configuration option.

drivers/net/phy/Kconfig

MakefileBuild the Axera EPHY driver +1/-0

Build the Axera EPHY driver

• Connects the internal PHY implementation to the PHY subsystem.

drivers/net/phy/Makefile

KconfigInclude Axera reset configuration +1/-0

Include Axera reset configuration

• Sources the Axera reset-controller configuration.

drivers/reset/Kconfig

MakefileInclude Axera reset build rules +1/-0

Include Axera reset build rules

• Connects the Axera reset-controller directory to the reset subsystem.

drivers/reset/Makefile

KconfigConfigure the Axera reset controller +7/-0

Configure the Axera reset controller

• Defines the option for the AX620E reset controller.

drivers/reset/axera_reset/Kconfig

MakefileBuild the Axera reset controller +1/-0

Build the Axera reset controller

• Adds the controller's local build rule.

drivers/reset/axera_reset/Makefile

KconfigConfigure Axera SoC services +44/-0

Configure Axera SoC services

• Adds options for built-in OSAL, hardware information, memory accounting, timers, bandwidth limiting, sysmap, and display stubs.

drivers/soc/axera/Kconfig

MakefileConnect Axera services to the build +10/-1

Connect Axera services to the build

• Adds conditional build entries for the new SoC service directories and proc interface.

drivers/soc/axera/Makefile

MakefileBuild Axera APB timer support +1/-0

Build Axera APB timer support

• Adds the APB timer implementation to the local build.

drivers/soc/axera/apb_timer/Makefile

MakefileBuild hardware information support +1/-0

Build hardware information support

• Adds the hardware-information service build rule.

drivers/soc/axera/ax_hwinfo/Makefile

MakefileBuild Axera high-resolution timers +1/-0

Build Axera high-resolution timers

• Adds the Axera hrtimer service build rule.

drivers/soc/axera/axera_hrtimer/Makefile

MakefileBuild DDR bandwidth limiting +1/-0

Build DDR bandwidth limiting

• Adds the bandwidth limiter build rule.

drivers/soc/axera/bwlimiter/Makefile

MakefileBuild display compatibility stubs +1/-0

Build display compatibility stubs

• Adds the dummy display implementation to the build.

drivers/soc/axera/display_dummy/Makefile

MakefileBuild vendor memory accounting +1/-0

Build vendor memory accounting

• Adds the os_mem service build rule.

drivers/soc/axera/os_mem/Makefile

MakefileBuild the OSAL into the kernel +11/-0

Build the OSAL into the kernel

• Compiles the compatibility API and Axera device infrastructure as built-in objects.

drivers/soc/axera/osal/Makefile

MakefileBuild Axera sysmap +1/-0

Build Axera sysmap

• Adds the sysmap service build rule.

drivers/soc/axera/sysmap/Makefile

MakefileBuild peripheral timer32 support +1/-0

Build peripheral timer32 support

• Adds the timer32 implementation to the local build.

drivers/soc/axera/timer32/Makefile

KconfigConfigure vendor AX620E SSI support +18/-0

Configure vendor AX620E SSI support

• Adds SPI controller, platform-glue, and optional AX_DMAPER receive-DMA options.

drivers/spi/Kconfig

MakefileBuild Axera SPI components +3/-0

Build Axera SPI components

• Connects the vendor SSI core, platform glue, and DMA support to the SPI build.

drivers/spi/Makefile

KconfigExpose AX620E watchdog support +11/-0

Expose AX620E watchdog support

• Adds a configuration option for the watchdog used by the camera's reboot path.

drivers/watchdog/Kconfig

MakefileBuild the Axera watchdog +1/-0

Build the Axera watchdog

• Connects ax_wdt to the watchdog subsystem build.

drivers/watchdog/Makefile

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

qodo-free-for-open-source-projects Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Oversized reads corrupt the kernel stack ✓ Resolved
Description
AX_OSAL_DEV_i2c_read() assigns unchecked reg_addr_num and data_byte_num values to I²C messages
that both reference tmp_buf[4]. An OSAL caller supplying a length greater than four makes the
adapter read beyond or write beyond that stack buffer during i2c_transfer().

2. Resource names can overrun callers ✓ Resolved
Description
AX_OSAL_DEV_platform_get_resource() and its by-name counterpart use strlen(res_tmp->name) to
copy into AXERA_RESOURCE.name without checking for null or limiting the copy to the 32-byte field.
An unnamed indexed resource dereferences a null pointer; a long DT node name or reg-names string
writes beyond the caller's output object, while a name of exactly 32 bytes leaves no NUL terminator.

3. Camera GPIO clocks use an unknown bit ✓ Resolved
Description
ax_gpio_probe() ignores failure to read ax_clk_id and passes the resulting uninitialized
clk_id to ax_gpio_clk(). The supplied GPIO nodes specify clocks but not that property, so every
such probe can write an indeterminate gate bit.

View action required (6)
4. Removing DMA leaves registrations behind ✓ Resolved
Description
ax_dma_per_remove() destroys the descriptor cache but never unregisters the DMA device or destroys
its descriptor pool and request-register mapping. Unbinding the controller leaves published DMA
channels and leaked resources, and outstanding descriptors can refer to the destroyed cache.

5. A watchdog IRQ failure can crash probe 🐞 Bug ☼ Reliability
Description
ax_wdt_probe() calls watchdog_unregister_device(wdd) when devm_request_irq() fails, before
assigning wdd. An IRQ request failure therefore passes an uninitialized local pointer into
watchdog cleanup.
Code

drivers/watchdog/ax_wdt.c[R417-420]

+		if (ret) {
+			pr_err("err %d\n", ret);
+			watchdog_unregister_device(wdd);
+			goto err_proc;
Evidence
The failure branch uses wdd at line 419, but the first assignment to that pointer occurs at line
433.

drivers/watchdog/ax_wdt.c[407-435]

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 IRQ failure path unregisters a watchdog that has not yet been initialized or registered.
## Fix Focus Areas
- drivers/watchdog/ax_wdt.c[407-433]
## Recommended Fix
On IRQ failure, clean up only resources acquired so far and return the IRQ error. Reserve watchdog_unregister_device() for paths after successful watchdog registration.

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


6. Timer callbacks can deadlock the system ✓ Resolved
Description
ax_hrtimer_interrupt() invokes caller-provided timer functions while holding ax_hrtimer_lock. A
callback that calls ax_hrtimer_stop() attempts to acquire that same raw spinlock and cannot
complete.

7. Destroying an active timer leaves freed data ✓ Resolved
Description
ax_hrtimer_destroy() frees its timer without removing an active timer from the global red-black
tree or synchronizing with the interrupt handler. If a caller destroys a started timer, the next
tree traversal can dereference its freed node.

8. Closing a timer can leave work running ✓ Resolved
Description
periph_timer32_close() disables the hardware but neither drains scheduled callback work nor
synchronizes with the IRQ handler. If an interrupt races with close, the handler can rearm the
clock-gated timer and queued work can still invoke the former owner's callback.

9. Any opener can map all physical memory read-write ✓ Resolved
Description
sys_devmap_mmap() passes the caller’s vm_pgoff and mapping length to remap_pfn_range() without
a physical-range or CAP_SYS_RAWIO check, and forces PTE_WRITE|PTE_DIRTY into the page
protection. Anyone able to open /dev/ax_sysmap can therefore map RAM or device registers writable
even through an O_RDONLY open and PROT_READ mapping, bypassing STRICT_DEVMEM; the device node
is root-only by default.


Remediation recommended

10. An external Ethernet reset is skipped ✓ Resolved
Description
axera_dwmac_get_dts() looks for phy-rst-gpio, while the existing AX630C Ethernet node supplies
phy-reset-gpios. On that RGMII board, the missing lookup makes the driver's external-PHY reset
routine return without toggling the configured GPIO.

11. The gzip device claims four gigabytes ✓ Resolved
Description
The gzipd node's four-cell reg value gives it a size of 0x100000000 rather than a small
register window. With the parent's two address and two size cells, that resource overlaps the
board's declared RAM and other device regions.

12. Full-duplex SPI transfers silently lose receive data ✓ Resolved
Description
In the ENHANCED_SPI_SUPPORT path (always defined), dw_spi_transfer_one clears dws->rx/rx_end
whenever tx_buf is set, so the controller is programmed SPI_TMOD_TO and the RX buffer is never
filled. The controller does not advertise SPI_CONTROLLER_HALF_DUPLEX, so the SPI core and spidev
(enabled in the defconfig) pass full-duplex transfers that then report success with garbage RX data.

View review recommended (5)
13. SPI receive DMA is never enabled ✓ Resolved
Description
spi-axera.c calls dw_spi_dma_register(dws) only under #ifdef CONFIG_SPI_DW_DMA, which is the
upstream DesignWare option and depends on SPI_DESIGNWARE, while the Axera DMA backend is built
under CONFIG_SPI_AXERA_DMA. With the shipped defconfig (SPI_AXERA_DMA=y, no SPI_DESIGNWARE),
dws->dma_ops stays NULL, can_dma is never set, and every NOR read falls back to polled PIO even
though the DMA code is compiled in.

14. Failed DMA controller setup reports success ✓ Resolved
Description
ax_dma_per_probe jumps to err_disable without setting ret when dma_pool_create or
kmem_cache_create fails, leaving the successful initialization's zero return value intact. Either
failure can therefore leave descriptor resources absent while the OF DMA controller remains
registered, and a later SPI DMA prepare can reach a NULL descriptor allocation resource.

15. Removing the wake-GPIO driver leaves its IRQ handler live ✓ Resolved
Description
deb_gpio_lp_remove() passes NULL to free_irq() even though deb_gpio_lp registered the shared
IRQ with deb_lp_res as its device ID. Removal therefore leaves the handler installed when the
driver state is released, so the next interrupt dereferences freed state and the mismatch also
triggers a WARN on a shared line.

16. Failed device opens leak memory ✓ Resolved
Description
osal_open allocates pdata, stores it in file->private_data, then returns the vendor
fops->open result directly. When that callback fails, pdata is never freed: VFS does not call
release after a failed open, so every rejected open of an ax_* device node leaks the allocation.

17. Ethernet probe never defers for missing resets ✓ Resolved
Description
dwmac_axera_probe() ignores the return value of emac_get_reset_control(eqos), which can retain
an error pointer and return a reset lookup error. When the reset provider has not probed yet or
lookup otherwise fails, probe still calls emac_sw_rst() with invalid reset handles, so the
EMAC/EPHY reset and EPHY un-shutdown sequence fails instead of deferring or stopping initialization.


Informational

18. More than eight wake GPIOs overflow driver arrays ✓ Resolved
Description
Probe takes the lp-status element count from DT and loops over it, writing wait[index],
gpio_num[index] and lp_trigger_type[index], all sized LP_GPIO_MAX (8), with no upper bound. A
devicetree with more than eight pairs corrupts the static wait[] array and the deb_lp_res
allocation during probe and in later IRQ handling.

19. A 32-byte proc write over-reads the stack ✓ Resolved
Description
ax_bw_limiter_create_write allows count == 32 and copies all 32 bytes into kbuf[32] without
adding a NUL terminator. A 32-byte write to the registration proc entry then reaches sscanf, which
can read past the local array.

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…led open

AX_OSAL_DEV_i2c_read() uses one 4-byte stack buffer for the register
address and the reply but took both lengths from the caller: reject
anything but the 8/16-bit addresses and values it decodes.

The platform resource helpers copied strlen(name) bytes into the 32-byte
AXERA_RESOURCE.name: an unnamed resource dereferenced NULL, a long one
overran the caller's struct. Copy with strscpy().

osal_open() leaked its per-file data when the module's open callback
failed (release is not called after a failed open).
A 32-byte write to the bw_limiter register entry filled kbuf[32] with no
terminator before sscanf(). Accept at most 31 bytes and terminate.
Probe passed an uninitialised clk_id to the gate writes whenever the
node had no SDK "ax_clk_id" property, which is the case for every
GPIO node of the AX620E devicetree: those carry clocks = <clk_gpio>,
<pclk_gpio> instead. Enable those through the clock framework, keep
"ax_clk_id" as the fallback for SDK devicetrees, and pass reset lookup
errors (-EPROBE_DEFER) through instead of -ENODEV.
remove() freed the shared IRQ with a NULL dev_id, so the handler stayed
installed (and the core warned) after the state it uses was gone. And
probe trusted the lp-status element count from the devicetree although
the arrays it fills hold LP_GPIO_MAX (8) entries.
A failed IRQ request called watchdog_unregister_device() on the not yet
assigned (and not registered) wdd pointer; just unwind the proc entry.
A failed proc_create() or a missing SDK clock/reset cell returned 0
instead of an error.
…n remove

Probe returned 0 when dma_pool_create() or kmem_cache_create() failed
(with the OF controller already registered and descriptors to be
allocated from a NULL cache), and its error path unwound only the
request-register mapping. remove() emptied the channel list by hand
before the managed dmaengine unregistration ran, so the channels were
never unregistered, and it leaked the descriptor pool and the mapping.

Allocate the pool and cache first, register the device unmanaged, unwind
every step on failure, and tear down in reverse order on remove.
The interrupt handler called timer callbacks with ax_hrtimer_lock held,
so a callback that stopped or started a timer deadlocked on it. Expired
callback timers now leave the tree under the lock and their callbacks
run after it is dropped; a timer whose callback asks for a restart is
queued again unless it was stopped meanwhile.

ax_hrtimer_destroy() freed a timer that could still be in the tree or
in its callback: it now detaches a queued timer and waits for a running
callback first. A queued timer can no longer be started twice, the
hardware's current-timer pointer no longer outlives the tree's last
timer, and AX_OSAL_DEV_hrtimer_alloc() checks the allocation.
…acks

The interrupt handler rearmed the timer and queued the owner's callback
without looking at the state that close() clears, and close() did not
wait for either: a racing interrupt could rearm a closed, clock-gated
timer, and a queued callback could still run for the former owner.
Check the state under the lock in the handler (and take the lock with
interrupts off elsewhere), then synchronize with the IRQ and cancel the
work in close() before gating the clocks.

Also: check the timer index before using it, set up the lock and work
before requesting the IRQ, and return the IRQ request's error.
/dev/ax_sysmap mapped any physical range the caller named, and forced
PTE_WRITE|PTE_DIRTY into the protection even for a PROT_READ mapping.
Its user is the MSP library (libax_sys AX_SYS_Mmap/MmapCache and the
dump tools built on it), which maps CMM buffers by physical address;
the CMM is the DRAM above the kernel's mem= that ax_cmm hands out.

Treat it like /dev/mem: require CAP_SYS_RAWIO, refuse ranges that
overlap System RAM or wrap around, add the write/dirty bits only to
writable mappings, create the node 0600 and report misc_register()
failures.
…rs on

The glue only knew the SDK's phy-rst-gpio, so the external PHY reset of
a board that uses the standard phy-reset-gpios (ax630c.dts) was never
toggled. Look the line up with the descriptor API under both names:
phy-reset-gpios follows its flags, phy-rst-gpio keeps the SDK's raw
"low = reset" driving. Lookup errors, -EPROBE_DEFER included, now fail
probe, as do the errors of axera_dwmac_get_dts() and of the reset
control lookups, which probe used to ignore before running the
EMAC/EPHY reset sequence with error pointers.
The vendor devicetree (and the SDK's AX620E.dtsi) give gzipd a size of
<0x1 0x0>, i.e. 4 GiB over RAM and every other device. The SDK driver
ioremaps 0x4000 of it; the next block (hwspinlock) is at 0x10420000.
dimerr pushed a commit to OpenIPC/firmware that referenced this pull request Nov 18, 2026
ax620e_lite and ax620u_lite build against the kernels in OpenIPC/linux#259
and #260; the axera-ax620e/u branch tarballs CI downloads do not have them
yet. List both boards in UNBUILT_BOARDS with that reason, their board
directories in UNBUILT_FAMILIES and their osdrv packages in NOT_BUILT, so
--self-test passes; they move into ALL_BOARDS once the kernels merge.
The enhanced (dual/quad) transfer path, which this driver always uses,
runs a transfer TX-only or RX-only: with both buffers set it dropped
the receive side and still reported success. Advertise
SPI_CONTROLLER_HALF_DUPLEX so that the core refuses such transfers
(spi-mem, i.e. the NOR, only issues one-direction transfers).

dw_spi_dma_register() was called under CONFIG_SPI_DW_DMA, the SDK's
name for the option, which this port renamed to CONFIG_SPI_AXERA_DMA:
the DMA code was built but never used and every NOR transfer was PIO.
Call it unconditionally, the header stubs it without SPI_AXERA_DMA. As
in the SDK (SPI_DW_DMA=y), transfers longer than the FIFO now go over
AX_DMAPER.
@dimerr

dimerr commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. All 19 findings were real, and each is now fixed in its own commit on top of the branch (c277dfd..acc58f2):

# Finding Fix
1 OSAL I²C read overflows tmp_buf[4] 86ab78a: reject anything other than 1–2 byte addresses and 1–2 byte values, which is all the decode handles (the only vendor caller is ax_proton.ko)
2 Resource name copy (NULL / overrun / no NUL) 86ab78a: strscpy() into the 32-byte field, skipped when the name is NULL
3 gpio-axera uninitialised clk_id 363fd47: enables the DT clocks (clk_gpio/pclk_gpio) through the clock framework. SDK ax_clk_id is only a fallback. Reset lookup errors, -EPROBE_DEFER included, now pass through
4 dma-per remove leaks/unregister 10821c8: the device is now registered unmanaged. remove() frees the OF controller, unregisters the device (which removes the channels; the old code emptied the channel list by hand first), frees the IRQ, kills the tasklets, then frees the pool, cache and mapping
5 ax_wdt uninitialised wdd on IRQ failure cef6ecb: no unregister before registration. The proc-create and clk-cell failure paths also returned 0, and now return errors
6 hrtimer callbacks under the lock de1ce4e: expired callback timers are taken out of the tree under the lock, and their callbacks run after it is dropped. A restart re-queues the timer unless it was stopped in the meantime
7 destroying an active hrtimer de1ce4e: destroy detaches a queued timer and waits for a running callback before kfree. Double start now returns -EBUSY, and the stale current-timer pointer is cleared
8 timer32 close races 9900ddb: the IRQ handler checks the state under the lock and does not rearm a closed timer. close() calls synchronize_irq() and cancel_work_sync() before gating clocks. Also: index bounds check, and lock and work are initialised before request_irq
9 ax_sysmap maps anything writable c3fe2e1: requires CAP_SYS_RAWIO and refuses ranges that overlap System RAM or wrap around. PTE_WRITE/DIRTY is only added to VM_WRITE mappings, the node is 0600, and misc_register errors are checked. The user is the MSP libax_sys (AX_SYS_Mmap*, dump tools), which maps CMM (the DRAM above mem=), so that keeps working
10 phy-rst-gpio vs phy-reset-gpios 1e7a3da: gpiod lookup under both names. phy-reset-gpios follows its flags, while the SDK's phy-rst-gpio keeps its raw "low = reset" driving
17 reset lookup errors ignored 1e7a3da: errors from emac_get_reset_control() and axera_dwmac_get_dts() (including -EPROBE_DEFER) now go to the existing cleanup path
11 gzipd 4 GiB reg a85670a: size 0x10000. <0x1 0x0> comes from the SDK AX620E.dtsi and the stock dtb; the SDK driver ioremaps 0x4000, and hwspinlock is at 0x10420000
12 full-duplex SPI drops RX acc58f2: SPI_CONTROLLER_HALF_DUPLEX. The enhanced path, which is always on, is TX-only or RX-only, and spi-mem only issues one-direction transfers
13 SPI DMA never enabled acc58f2: dw_spi_dma_register() is now called unconditionally (the header stubs it without SPI_AXERA_DMA). The SDK builds with SPI_DW_DMA=y, so this restores the intended AX_DMAPER path
14 dma-per probe returns 0 on pool/cache failure 10821c8: -ENOMEM, pool and cache created first, full unwind
15 deb-gpio-lp free_irq(.., NULL) 2bf1cde: frees with the deb_lp_res cookie
18 more than 8 lp-status entries 2bf1cde: -EINVAL above LP_GPIO_MAX
16 osal_open leaks pdata 86ab78a: freed (and private_data restored) when the module's open fails
19 bwlimiter 32-byte write unterminated 8535b7a: at most 31 bytes, then NUL-terminated

Re-verified in QEMU (-M ax620e, NOR image with the OpenIPC U-Boot, kernel from ax620e_xm_ipc_defconfig), all checks passed:

  • Boot: both CPUs come up and the rootfs mounts from NOR, now read over AX_DMAPER (axera_dma_per IRQ count > 20k). The kernel and rootfs partitions read back with the same md5 as the image.
  • Login works, DHCP works, and all 21 vendor modules load.
  • fw_setenv and a jffs2 overlay file both survive a reboot, and the watchdog reboot works.
  • ax_sysmap: RAM is refused (EPERM), a CMM read/write mapping works, and writing through a PROT_READ mapping raises SIGSEGV.
  • /dev/ax_hrtimer: 50 × 20 ms sleeps take 1027 ms.
  • No oops. The only WARN is the existing ax_vdec "Unknown HW" vfree warning, which the stock firmware also shows in QEMU.

Compile-checked as well: timer32 and deb-gpio-lp, which the defconfig does not enable.

@dimerr

dimerr commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Re-review follow-up: Qodo marked 18 of the 19 findings resolved and raised no new ones. #5 (ax_wdt uses an uninitialised wdd on IRQ failure) is still listed as open, but it is fixed in cef6ecb. At acc58f2 the only watchdog_unregister_device() left is in remove(), and the IRQ failure path only unwinds the proc entry:

		ret = devm_request_irq(&pdev->dev, ax_wdt->irq, ax_wdt_interrupt,
			IRQF_SHARED, KBUILD_MODNAME, ax_wdt);
		if (ret) {
			pr_err("err %d\n", ret);
			goto err_proc;
		}

The snippet the finding quotes is from the original diff, not from the current head.

@dimerr
dimerr merged commit b1bb212 into axera-ax620e Nov 18, 2026
@dimerr
dimerr deleted the axera-ax620e-sdk branch November 18, 2026 19:56
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