Skip to content

accel/amdxdna: move get PMF data and query sensors to common code + AIE4 temp support#1286

Open
hlaccabu wants to merge 3 commits intoamd:mainfrom
hlaccabu:staging_pmf
Open

accel/amdxdna: move get PMF data and query sensors to common code + AIE4 temp support#1286
hlaccabu wants to merge 3 commits intoamd:mainfrom
hlaccabu:staging_pmf

Conversation

@hlaccabu
Copy link
Copy Markdown
Contributor

@hlaccabu hlaccabu commented May 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 4, 2026 17:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors sensor/PMF metric handling in the AMD XDNA accel driver by moving duplicated “get PMF data + query sensors” logic into common AIE code, while also extending the UAPI/implementation to report a temperature sensor (and enabling sensors query on AIE4).

Changes:

  • Add AMDXDNA_SENSOR_TYPE_TEMPERATURE to the UAPI and report NPU temperature via the sensors query.
  • Introduce a shared amdxdna_query_sensors() implementation in aie.c and route AIE2/AIE4 GET_INFO sensor queries to it.
  • Centralize PMF access macros into aie.h and update NPU4 PMF metrics retrieval to use the common macro.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
include/uapi/drm/amdxdna_accel.h Extends sensor type enum with temperature.
drivers/accel/amdxdna/npu4_regs.c Switches to common PMF metrics macro and drops direct PMF header include.
drivers/accel/amdxdna/aie4_pci.c Adds GET_INFO handling for DRM_AMDXDNA_QUERY_SENSORS on AIE4.
drivers/accel/amdxdna/aie2_pci.h Removes AIE2-specific PMF macro helpers (moved to common code).
drivers/accel/amdxdna/aie2_pci.c Replaces local sensor query implementation with amdxdna_query_sensors().
drivers/accel/amdxdna/aie.h Adds common PMF macro helpers and declares amdxdna_query_sensors().
drivers/accel/amdxdna/aie.c Implements shared amdxdna_query_sensors() and adds temperature reporting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/accel/amdxdna/aie.c Outdated
Comment thread drivers/accel/amdxdna/npu4_regs.c Outdated
Comment thread drivers/accel/amdxdna/aie.c Outdated
Comment thread drivers/accel/amdxdna/aie.h Outdated
…ayer

Move aie2_get_sensors() from aie2_pci.c to aie.c, renaming to
amdxdna_query_sensors(). Add parameter for total columns for different
devices. Update call site in aie2_pci.c and add call site inside
aie4_pci.c to enable query sensors for aie4 devices. Move
AIE2_GET_PMF_NPU_METRICS / AIE2_GET_PMF_NPU_DATA from aie2_pci.h to
aie.h, renaming them to AIE_GET_PMF_NPU_METRICS / AIE_GET_PMF_NPU_DATA.
Both aie2 and aie4 now include linux/amd-pmf-io.h through aie.h, so the
direct include in npu4_regs.c is dropped.

Call site in aie4_pci.c is for npu3 device to return estimated power
for command xrt-smi examine -r platform

Signed-off-by: Hayden Laccabue <hlaccabu@amd.com>
@NishadSaraf NishadSaraf self-requested a review May 4, 2026 20:18
Comment thread drivers/accel/amdxdna/aie.c Outdated
maxzhen
maxzhen previously approved these changes May 4, 2026
Copilot AI review requested due to automatic review settings May 4, 2026 20:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

hlaccabu added 2 commits May 4, 2026 16:09
Add AMDXDNA_SENSOR_TYPE_TEMPERATURE to the amdxdna_sensor_type uAPI
enum and add a corresponding entry into amdxdna_query_sensors().

Allows xrt-smi examine -r platform to populate temperature on
NPUs whose PMF backend exposes amd_pmf_npu_metrics::npu_temp.

Zero-initialize the on-stack amd_pmf_npu_metrics so platforms whose
PMF arms do not write npu_temp report 0.

Signed-off-by: Hayden Laccabue <hlaccabu@amd.com>
…one ioctl

Signed-off-by: Hayden Laccabue <hlaccabu@amd.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.

3 participants