From: Lizhi Hou <lizhi.hou@amd.com>
To: "Mario Limonciello (AMD)" <superm1@kernel.org>,
<mario.limonciello@amd.com>, <airlied@gmail.com>,
<maarten.lankhorst@linux.intel.com>, <mamin506@gmail.com>,
<mripard@kernel.org>, <ogabbay@kernel.org>, <simona@ffwll.ch>,
<tzimmermann@suse.de>
Cc: <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] accel/amdxdna: Support sensors for column utilization
Date: Sat, 28 Feb 2026 11:56:43 -0800 [thread overview]
Message-ID: <85172fca-e400-c542-772e-704bcef0a5dc@amd.com> (raw)
In-Reply-To: <20260228061109.361239-3-superm1@kernel.org>
On 2/27/26 22:10, Mario Limonciello (AMD) wrote:
> The AMD PMF driver provides realtime column utilization (npu_busy)
> metrics for the NPU. Extend the DRM_IOCTL_AMDXDNA_GET_INFO sensor
> query to expose these metrics to userspace.
>
> Add AMDXDNA_SENSOR_TYPE_COLUMN_UTILIZATION to the sensor type enum
> and update aie2_get_sensors() to return both the total power and up
> to 8 column utilization sensors if the user buffer permits.
>
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> drivers/accel/amdxdna/aie2_pci.c | 27 ++++++++++++++++++++++++---
> drivers/accel/amdxdna/aie2_pci.h | 2 ++
> include/uapi/drm/amdxdna_accel.h | 3 ++-
> 3 files changed, 28 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
> index a2e586512e26c..1f11822f0bfda 100644
> --- a/drivers/accel/amdxdna/aie2_pci.c
> +++ b/drivers/accel/amdxdna/aie2_pci.c
> @@ -787,16 +787,24 @@ static int aie2_get_clock_metadata(struct amdxdna_client *client,
> static int aie2_get_sensors(struct amdxdna_client *client,
> struct amdxdna_drm_get_info *args)
> {
> + struct amdxdna_dev_hdl *ndev = client->xdna->dev_handle;
> struct amdxdna_drm_query_sensor sensor = {};
> + struct amd_pmf_npu_metrics npu_metrics;
> + u32 sensors_count, util_count, i;
> int ret;
>
> - if (args->buffer_size < sizeof(sensor))
> + util_count = min_t(u32, ndev->total_col, 8);
> + sensors_count = 1 + util_count;
> +
> + if (args->buffer_size < sensors_count * sizeof(sensor))
> return -EINVAL;
>
> - ret = AIE2_GET_PMF_NPU_DATA(npu_power, sensor.input);
> + ret = AIE2_GET_PMF_NPU_METRICS(&npu_metrics);
> if (ret)
> return ret;
> +
> sensor.type = AMDXDNA_SENSOR_TYPE_POWER;
> + sensor.input = npu_metrics.npu_power;
> sensor.unitm = -3;
> scnprintf(sensor.label, sizeof(sensor.label), "Total Power");
> scnprintf(sensor.units, sizeof(sensor.units), "mW");
> @@ -804,7 +812,20 @@ static int aie2_get_sensors(struct amdxdna_client *client,
> if (copy_to_user(u64_to_user_ptr(args->buffer), &sensor, sizeof(sensor)))
> return -EFAULT;
>
> - args->buffer_size = sizeof(sensor);
> + for (i = 0; i < util_count; i++) {
> + memset(&sensor, 0, sizeof(sensor));
> + sensor.input = npu_metrics.npu_busy[i];
> + sensor.type = AMDXDNA_SENSOR_TYPE_COLUMN_UTILIZATION;
> + sensor.unitm = 0;
> + scnprintf(sensor.label, sizeof(sensor.label), "Column %d Utilization", i);
> + scnprintf(sensor.units, sizeof(sensor.units), "%%");
> +
> + if (copy_to_user(u64_to_user_ptr(args->buffer) + (i + 1) * sizeof(sensor),
> + &sensor, sizeof(sensor)))
> + return -EFAULT;
> + }
> +
> + args->buffer_size = sensors_count * sizeof(sensor);
>
> return 0;
> }
> diff --git a/drivers/accel/amdxdna/aie2_pci.h b/drivers/accel/amdxdna/aie2_pci.h
> index 1bb88711bedb3..424fd6d852191 100644
> --- a/drivers/accel/amdxdna/aie2_pci.h
> +++ b/drivers/accel/amdxdna/aie2_pci.h
> @@ -48,6 +48,7 @@
> })
>
> #if IS_ENABLED(CONFIG_AMD_PMF)
> +#define AIE2_GET_PMF_NPU_METRICS(metrics) amd_pmf_get_npu_data(metrics)
> #define AIE2_GET_PMF_NPU_DATA(field, val) \
> ({ \
> struct amd_pmf_npu_metrics _npu_metrics; \
> @@ -58,6 +59,7 @@
> (_ret); \
> })
> #else
> +#define AIE2_GET_PMF_NPU_METRICS(metrics) (-EOPNOTSUPP)
> #define SENSOR_DEFAULT_npu_power U32_MAX
> #define AIE2_GET_PMF_NPU_DATA(field, val) \
> ({ \
> diff --git a/include/uapi/drm/amdxdna_accel.h b/include/uapi/drm/amdxdna_accel.h
> index 9c44db2b3dcd4..5bd13f4435f55 100644
> --- a/include/uapi/drm/amdxdna_accel.h
> +++ b/include/uapi/drm/amdxdna_accel.h
> @@ -353,7 +353,8 @@ struct amdxdna_drm_query_clock_metadata {
> };
>
> enum amdxdna_sensor_type {
> - AMDXDNA_SENSOR_TYPE_POWER
> + AMDXDNA_SENSOR_TYPE_POWER,
> + AMDXDNA_SENSOR_TYPE_COLUMN_UTILIZATION
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
> };
>
> /**
next prev parent reply other threads:[~2026-02-28 19:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-28 6:10 [PATCH 0/2] Add some sensor data to amdxdna Mario Limonciello (AMD)
2026-02-28 6:10 ` [PATCH 1/2] accel/amdxdna: Add IOCTL to retrieve realtime NPU power estimate Mario Limonciello (AMD)
2026-03-03 4:37 ` Claude review: " Claude Code Review Bot
2026-02-28 6:10 ` [PATCH 2/2] accel/amdxdna: Support sensors for column utilization Mario Limonciello (AMD)
2026-02-28 19:56 ` Lizhi Hou [this message]
2026-03-03 4:37 ` Claude review: " Claude Code Review Bot
2026-03-03 4:37 ` Claude review: Add some sensor data to amdxdna Claude Code Review Bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85172fca-e400-c542-772e-704bcef0a5dc@amd.com \
--to=lizhi.hou@amd.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mamin506@gmail.com \
--cc=mario.limonciello@amd.com \
--cc=mripard@kernel.org \
--cc=ogabbay@kernel.org \
--cc=simona@ffwll.ch \
--cc=superm1@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox