From: Sidong Yang <sidong.yang@furiosa.ai>
To: Tomeu Vizoso <tomeu@tomeuvizoso.net>,
Oded Gabbay <ogabbay@kernel.org>,
Philipp Stanner <phasta@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Matthew Brost <matthew.brost@intel.com>,
ckoenig.leichtzumerken@gmail.com
Cc: Tvrtko Ursulin <tursulin@ursulin.net>,
mcanal@igalia.com, Heiko Stuebner <heiko@sntech.de>,
Gyeyoung Baek <gye976@gmail.com>,
dri-devel@lists.freedesktop.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Sidong Yang <sidong.yang@furiosa.ai>,
Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Subject: [PATCH v6 2/2] accel/rocket: Report NPU usage through fdinfo
Date: Fri, 20 Nov 2026 23:12:25 +0900 [thread overview]
Message-ID: <20261120141225.789350-3-sidong.yang@furiosa.ai> (raw)
In-Reply-To: <20261120141225.789350-1-sidong.yang@furiosa.ai>
There is no way to tell how much of the NPU a client uses. Implement the
DRM usage stats: report the runtime of the client's scheduler entity as
drm-engine-npu, along with drm_show_memory_stats() for the BOs.
The cores are identical, so they are reported as a single engine with
drm-engine-capacity-npu set to rdev->num_cores, the number of cores
bound to the driver.
Document the keys in the rocket driver documentation.
Signed-off-by: Sidong Yang <sidong.yang@furiosa.ai>
Acked-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
---
Documentation/accel/rocket/index.rst | 29 +++++++++++++++++++++++++++
Documentation/gpu/drm-usage-stats.rst | 1 +
drivers/accel/rocket/rocket_drv.c | 25 ++++++++++++++++++++++-
3 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/Documentation/accel/rocket/index.rst b/Documentation/accel/rocket/index.rst
index 70f97bccf100..d633502c8f15 100644
--- a/Documentation/accel/rocket/index.rst
+++ b/Documentation/accel/rocket/index.rst
@@ -17,3 +17,32 @@ project.
Hardware currently supported:
* RK3588
+
+.. _rocket-usage-stats:
+
+Rocket DRM client usage stats implementation
+============================================
+
+The accel/rocket driver implements the DRM client usage stats specification as
+documented in :ref:`drm-client-usage-stats`.
+
+The NPU cores are reported as a single engine, npu, with a capacity equal to the
+number of cores bound to the driver. The time is summed over all cores and is
+accounted by the DRM GPU scheduler, from when a job is handed to a core until
+its fence signals.
+
+Example of the output showing the implemented key value pairs:
+
+::
+
+ pos: 0
+ flags: 02400002
+ mnt_id: 33
+ ino: 755
+ drm-driver: rocket
+ drm-client-id: 263
+ drm-engine-npu: 2384122043 ns
+ drm-engine-capacity-npu: 3
+ drm-total-memory: 24216 KiB
+ drm-shared-memory: 0
+ drm-active-memory: 3000 KiB
diff --git a/Documentation/gpu/drm-usage-stats.rst b/Documentation/gpu/drm-usage-stats.rst
index 70b7cfcc194f..288764730d23 100644
--- a/Documentation/gpu/drm-usage-stats.rst
+++ b/Documentation/gpu/drm-usage-stats.rst
@@ -218,3 +218,4 @@ Driver specific implementations
* :ref:`panthor-usage-stats`
* :ref:`xe-usage-stats`
* :ref:`amdxdna-usage-stats`
+* :ref:`rocket-usage-stats`
diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
index 5d7805c41dc3..b5fd800f500f 100644
--- a/drivers/accel/rocket/rocket_drv.c
+++ b/drivers/accel/rocket/rocket_drv.c
@@ -3,8 +3,10 @@
#include <drm/drm_accel.h>
#include <drm/drm_drv.h>
+#include <drm/drm_file.h>
#include <drm/drm_gem.h>
#include <drm/drm_ioctl.h>
+#include <drm/drm_print.h>
#include <drm/rocket_accel.h>
#include <linux/clk.h>
#include <linux/err.h>
@@ -139,7 +141,27 @@ static const struct drm_ioctl_desc rocket_drm_driver_ioctls[] = {
ROCKET_IOCTL(FINI_BO, fini_bo),
};
-DEFINE_DRM_ACCEL_FOPS(rocket_accel_driver_fops);
+static void rocket_show_fdinfo(struct drm_printer *p, struct drm_file *file)
+{
+ struct rocket_device *rdev = to_rocket_device(file->minor->dev);
+ struct rocket_file_priv *rocket_priv = file->driver_priv;
+ unsigned int num_cores = rdev->num_cores;
+
+ drm_printf(p, "drm-engine-npu:\t%llu ns\n",
+ drm_sched_entity_get_runtime_ns(&rocket_priv->sched_entity));
+
+ /* A capacity of zero is not allowed, skip it once all cores are gone. */
+ if (num_cores)
+ drm_printf(p, "drm-engine-capacity-npu:\t%u\n", num_cores);
+
+ drm_show_memory_stats(p, file);
+}
+
+static const struct file_operations rocket_accel_driver_fops = {
+ .owner = THIS_MODULE,
+ DRM_ACCEL_FOPS,
+ .show_fdinfo = drm_show_fdinfo,
+};
/*
* Rocket driver version:
@@ -150,6 +172,7 @@ static const struct drm_driver rocket_drm_driver = {
.open = rocket_open,
.postclose = rocket_postclose,
.gem_create_object = rocket_gem_create_object,
+ .show_fdinfo = rocket_show_fdinfo,
.ioctls = rocket_drm_driver_ioctls,
.num_ioctls = ARRAY_SIZE(rocket_drm_driver_ioctls),
.fops = &rocket_accel_driver_fops,
--
2.53.0
next prev parent reply other threads:[~2026-11-20 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 14:12 [PATCH v6 0/2] " Sidong Yang
2026-11-20 14:12 ` [PATCH v6 1/2] drm/sched: Add drm_sched_entity_get_runtime_ns() Sidong Yang
2026-11-20 14:12 ` Sidong Yang [this message]
2026-11-20 15:31 ` [PATCH v6 0/2] accel/rocket: Report NPU usage through fdinfo Maíra Canal
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=20261120141225.789350-3-sidong.yang@furiosa.ai \
--to=sidong.yang@furiosa.ai \
--cc=ckoenig.leichtzumerken@gmail.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gye976@gmail.com \
--cc=heiko@sntech.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.brost@intel.com \
--cc=mcanal@igalia.com \
--cc=ogabbay@kernel.org \
--cc=phasta@kernel.org \
--cc=tomeu@tomeuvizoso.net \
--cc=tursulin@ursulin.net \
--cc=tvrtko.ursulin@igalia.com \
/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
all inboxes | Powered by JetHome®