Skip to content

Add Qualcomm NPU monitoring support#488

Open
Srinivas-Kandagatla wants to merge 3 commits into
Syllo:masterfrom
Srinivas-Kandagatla:master
Open

Add Qualcomm NPU monitoring support#488
Srinivas-Kandagatla wants to merge 3 commits into
Syllo:masterfrom
Srinivas-Kandagatla:master

Conversation

@Srinivas-Kandagatla

@Srinivas-Kandagatla Srinivas-Kandagatla commented Jul 3, 2026

Copy link
Copy Markdown

This series adds real-time monitoring of the Qualcomm Hexagon DSP/NPU
to nvtop, targeting Qualcomm SoCs.

Monitoring is implemented via the libqcnpuperf library [1], which uses
the FastRPC sysmon query interface to collect per-sample profiling data
from the DSP firmware. The library is separate from nvtop and must be
installed (pkg-config: qcnpuperf).

Patch 1 adds the core driver. It reports:

  • Device name: "Qualcomm Hexagon vXX NPU", where XX is the Hexagon
    ISA version read via FASTRPC_IOCTL_GET_DSP_INFO at startup.
  • Q6 core utilisation (%) and clock frequency (MHz).
  • HVX (Hexagon Vector eXtensions) utilisation (%).
  • HMX (Hexagon Matrix eXtensions) utilisation (%).
  • NSP temperature: the hottest NSP thermal zone discovered by
    scanning /sys/class/thermal at startup, so no zone numbers are
    hardcoded.
  • System memory (from /proc/meminfo), since the Hexagon DSP shares
    host DRAM.

Patches 2 and 3 extend the generic interface layer to carry these
new metrics cleanly:

Patch 2 adds a unit_name field to struct gpu_vendor so a driver
can advertise "NPU" instead of "GPU" in utilisation bars, clock
labels, and plot legends. Existing drivers are unaffected
(unit_name defaults to "GPU" when unset).

Patch 3 adds HVX and HMX time-series plots to the default plot
set for devices that set unit_name (i.e. NPU-class devices),
keeping the GPU plot layout unchanged.

Tested on a Snapdragon X Elite (SC8380XP), Arduino VENTUNO-Q running a mainline kernel.
There are few things that could be potentially added in future are Memory Bandwidth metrics and Process list.

[1] https://github.com/qualcomm/libqcnpuperf

Srinivas Kandagatla added 3 commits July 3, 2026 07:33
Add support for monitoring the Qualcomm NPU (Neural Processing Unit)
via the qcnpuperf library. The driver reports Q6 utilization and clock
speed, HVX and HMX utilization, temperature, and system memory usage.

The DSP session is opened with qcom_dsp_open() in get_device_handles()
and stored as an opaque qcom_dsp_ctx pointer in the per-device struct.
qcom_dsp_get_arch_version() is used to form the device name as
"Qualcomm Hexagon vXX NPU" where XX is the Hexagon ISA version.

NSP thermal zones are discovered at startup by scanning
/sys/class/thermal/thermal_zone*/type for entries whose type starts
with "nsp". The hottest zone is reported as the NPU temperature on
each refresh, avoiding hardcoded zone numbers that differ across SoCs.

System memory (from /proc/meminfo) is reported as device memory since
the Hexagon DSP shares the host DRAM.

The driver is built as part of MSM_SUPPORT and depends on qcnpuperf
(found via pkg-config).

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Add a unit_name field to struct gpu_vendor so drivers can declare what
kind of compute unit they represent (e.g. "NPU"). The interface uses
this label in utilization meters, clock display, plot legends, and the
integrated-device label, falling back to "GPU" when unset so existing
drivers are unaffected.

Pass the device list into populate_plot_data_from_ring_buffer() and
draw_plots() so each plot legend can be prefixed with the correct unit
name rather than the hardcoded "GPU" string.

The Qualcomm NPU driver sets unit_name = "NPU", so its utilization
bar, clock field, and plots now read "NPU" rather than "GPU".

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Add plot_hvx_util_rate and plot_hmx_util_rate to the plot information
enum and wire up data collection in save_current_data_to_ring() and
legend labels in populate_plot_data_from_ring_buffer().

Introduce plot_npu_default_draw_info() which extends the standard
default with HVX and HMX plots. Devices whose vendor sets unit_name
(i.e. NPU-like devices) get HVX and HMX in their default plot at
startup; regular GPU devices are unaffected.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.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.

1 participant