[PATCH V1 00/20] accel/amdxdna: Kernel submission and PM for AIE4

From: David Zhang

Date: Tue Sep 29 2026 - 23:33:08 EST


This patch series extends the amdxdna accelerator driver to support
AMD AIE4 (NPU3) platforms with kernel-mode command submission (KMQ),
device telemetry queries, comprehensive system and runtime power
management, and NPU3 classic device support.

This series establishes kernel-mode submission as the default execution
path. Additionally, it implements suspend/resume and runtime power
management across Physical Functions (PF), Virtual Functions (VF), and
Classic devices.

Changes in v1:
- Firmware version 6.0: return IOMMU_PASID_INVALID from aie4_msg_pasid()
- Power mode: consolidate cached power mode override restoration on
hardware start directly into the power mode introduction patch, and
respect user buffer size.
- Transport hooks: fix header include to use <drm/amdxdna_accel.h>.
- Command submission & fencing:
- Fold fence timeline naming (using dev_name() backed by struct
device to avoid use-after-free) and unique timeline context allocation
into the command submission patch.

Series structure:

1. Firmware Interfaces, Versioning & Compatibility (Patches 1-4)
- Patch 1: Rename NPU3 firmware filenames to match official release
binaries.
- Patch 2: Remove userspace doorbell mmap and default to kernel
submission.
- Patch 3: Add CERT (Column Embedded Run Time) firmware version
queries and protocol validation.
- Patch 4: Upgrade firmware interface version to 6.0.

2. Device Operations, Telemetry & Power Modes (Patches 5-8)
- Patch 5: Add NPU3 classic device operations, and remove device IDs
0x1B0B and 0x1B0C.
- Patch 6: Expose AIE and NPU firmware versions via GET_INFO ioctl.
- Patch 7: Add power mode support, and restore cached user power mode.
- Patch 8: Add clock metadata, DPM frequency table initialization,
and hardware resource info queries.

3. Hardware Initialization & Transport Hooks (Patches 9-11)
- Patch 9: Add context switch hysteresis configuration with debugfs
control (ctx_switch_hysteresis_us) applied on hardware start.
- Patch 10: Refactor AIE4 hardware initialization sequence into
distinct modular phases (query_fw, config_fw, setup_aie) across
PF, VF, and classic devices.
- Patch 11: Decouple PCI doorbell and MSI-X notification transport
hooks from transport-neutral context management code.

4. Kernel-Mode Command Submission & Fencing (Patches 12-14)
- Patch 12: Implement kernel queue lifecycle, job workqueue, and
memory layout for kernel-mode submission.
- Patch 13: Prepare command submission structures.
- Patch 14: Implement full command packet building (direct/indirect
packets).

5. System & Runtime Power Management (Patches 15-18)
- Patch 15: Fix runtime PM deadlock on device removal by finalizing
RPM before acquiring dev_lock, and symmetrically initialize RPM
during probe across all device types.
- Patch 16: Implement system suspend and resume for PF, VF, and
classic devices, restoring contexts.
- Patch 17: Link SR-IOV VFs via device_link_add() to ensure the PM
core suspends VFs before the PF and resumes the PF before VFs.
- Patch 18: Implement runtime suspend and resume support.

6. Userspace ABI Compatibility (Patch 19)
- Patch 19: Add a stub hwctx_config callback returning 0 to support
the DRM_AMDXDNA_CONFIG_HWCTX ioctl, enabling userspace validation
runtimes (such as XRT GEMM tests) to run unmodified.

7. Firmware Logging (Patch 20)
- Patch 20: Allocate a DRAM buffer for firmware logging on PF and
classic devices and register it at hardware start, with the log
level set to the least verbose setting.

Testing:
- Tested on AMD AIE4/NPU3 hardware in both classic and SR-IOV (PF/VF)
modes.
- Verified kernel-mode command submission with direct and indirect
execution packets under concurrent workloads.
- Verified system suspend/resume (S2idle/S3) and runtime autosuspend
cycles during idle and active command submission.
- Verified SR-IOV VF binding, execution, and PM dependency sequencing.
- Confirmed no regression on existing AIE2 devices (NPU1/NPU4).

David Zhang (20):
accel/amdxdna: Rename NPU3 firmware files
accel/amdxdna: Remove mmap for doorbell
accel/amdxdna: Add CERT firmware version support
accel/amdxdna: Upgrade firmware version to 6.0
accel/amdxdna: Add NPU3 classic device support
accel/amdxdna: Add AIE version query to aie4_get_info
accel/amdxdna: Add get and set power_mode for AIE4
accel/amdxdna: Add clock, DPM frequency, and resource info queries for
AIE4
accel/amdxdna: Add context switch hysteresis with debugfs control
accel/amdxdna: Refactor AIE4 hardware initialization sequence
accel/amdxdna: Decouple AIE4 doorbell and MSI-X notification transport
hooks
accel/amdxdna: Implement AIE4 kernel queue lifecycle and memory layout
accel/amdxdna: Prepare for AIE4 command submission
accel/amdxdna: Implement AIE4 command packet building and submission
accel/amdxdna: Finalize runtime PM before acquiring dev_lock on
removal
accel/amdxdna: Implement AIE4 suspend and resume
accel/amdxdna: Link SR-IOV VFs for power management sequencing
accel/amdxdna: Implement runtime suspend and resume support
accel/amdxdna: Add stub hwctx_config for AIE4
accel/amdxdna: Enable AIE4 firmware logging to DRAM

drivers/accel/amdxdna/aie.c | 45 +-
drivers/accel/amdxdna/aie.h | 45 +-
drivers/accel/amdxdna/aie2_message.c | 4 +-
drivers/accel/amdxdna/aie2_pci.c | 65 +-
drivers/accel/amdxdna/aie2_pci.h | 39 +-
drivers/accel/amdxdna/aie2_pm.c | 10 +-
drivers/accel/amdxdna/aie4_ctx.c | 1086 +++++++++++++++++++++--
drivers/accel/amdxdna/aie4_host_queue.h | 79 +-
drivers/accel/amdxdna/aie4_message.c | 237 +++++
drivers/accel/amdxdna/aie4_msg_priv.h | 161 +++-
drivers/accel/amdxdna/aie4_pci.c | 867 +++++++++++++++++-
drivers/accel/amdxdna/aie4_pci.h | 143 ++-
drivers/accel/amdxdna/aie4_sriov.c | 104 ++-
drivers/accel/amdxdna/amdxdna_ctx.c | 20 +-
drivers/accel/amdxdna/amdxdna_ctx.h | 22 +
drivers/accel/amdxdna/amdxdna_debugfs.c | 3 +
drivers/accel/amdxdna/amdxdna_pci_drv.c | 53 +-
drivers/accel/amdxdna/amdxdna_pci_drv.h | 18 +-
drivers/accel/amdxdna/amdxdna_pm.c | 35 +
drivers/accel/amdxdna/amdxdna_pm.h | 4 +-
drivers/accel/amdxdna/amdxdna_sysfs.c | 2 +-
drivers/accel/amdxdna/npu1_regs.c | 19 +-
drivers/accel/amdxdna/npu3_regs.c | 99 ++-
drivers/accel/amdxdna/npu4_regs.c | 30 +-
24 files changed, 2907 insertions(+), 283 deletions(-)

--
2.34.1