summaryrefslogtreecommitdiff
path: root/include/uapi/drm
diff options
context:
space:
mode:
authorRob Herring (Arm) <robh@kernel.org>2026-05-23 10:37:22 +0200
committerTomeu Vizoso <tomeu@tomeuvizoso.net>2026-06-01 19:44:24 +0200
commit17cdb54644e7d92b62cff1c4d1bd3d1486515f68 (patch)
tree1e606a7c1a2fb5200b87a870429953842cf08001 /include/uapi/drm
parente84b07e0a30b371117f9a1120a4645c213f39cd9 (diff)
downloadlinux-next-17cdb54644e7d92b62cff1c4d1bd3d1486515f68.tar.gz
linux-next-17cdb54644e7d92b62cff1c4d1bd3d1486515f68.zip
accel: ethosu: Add performance counter support
The Arm Ethos-U NPUs have a PMU with performance counters. The PMU h/w supports up to 4 (U65) or 8 (U85) counters which can be programmed for different events. There is also a dedicated cycle counter. The ABI and implementation are copied from the V3D driver. The main difference in the ABI is there is no query API for the event list. The events differ between the U65 and U85, so the events lists are maintained in userspace along with other differences between the U65 and U85. The cycle counter is always enabled when the PMU is enabled. When the user requests N events, reading the counters will return the N events plus the cycle counter. Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Tomeu Vizoso <tomeu@tomeuvizoso.net> Reviewed-by: Maíra Canal <mcanal@igalia.com> Link: https://patch.msgid.link/20260601173814.250071-1-tomeu@tomeuvizoso.net --- v2: - Use XArray instead of idr - Rework locking to use per device spinlock to protect modifying active perfmon. Based on pending V3D changes: https://lore.kernel.org/all/20260508-v3d-perfmon-lifetime-v1-1-f5b5642c085f@igalia.com/ - Add missing perfmon puts in ethosu_ioctl_perfmon_set_global() and ethosu_ioctl_perfmon_get_values() error paths. - Fix reading number of counters on U85. - Add defines NPU_REG_PMCCNTR_CFG v3: - Add explicit padding to drm_ethosu_perfmon_destroy - Fix SPDX license expression - Fix comment typos - Convert perfmon lock from spinlock to mutex - Simplify switch_perfmon condition check - Remove unused ethosu_perfmon_init - Add lockdep_assert_held to ethosu_perfmon_stop_locked v4: - Use drmm_mutex_init() for perfmon lock - Add lockdep_assert_held() to ethosu_perfmon_start() - Fix a few style issues reported by Maíra
Diffstat (limited to 'include/uapi/drm')
-rw-r--r--include/uapi/drm/ethosu_accel.h60
1 files changed, 59 insertions, 1 deletions
diff --git a/include/uapi/drm/ethosu_accel.h b/include/uapi/drm/ethosu_accel.h
index af78bb4686d7..5b97d59a7806 100644
--- a/include/uapi/drm/ethosu_accel.h
+++ b/include/uapi/drm/ethosu_accel.h
@@ -43,6 +43,11 @@ enum drm_ethosu_ioctl_id {
/** @DRM_ETHOSU_SUBMIT: Submit a job and BOs to run. */
DRM_ETHOSU_SUBMIT,
+
+ DRM_ETHOSU_PERFMON_CREATE,
+ DRM_ETHOSU_PERFMON_DESTROY,
+ DRM_ETHOSU_PERFMON_GET_VALUES,
+ DRM_ETHOSU_PERFMON_SET_GLOBAL,
};
/**
@@ -79,6 +84,7 @@ struct drm_ethosu_npu_info {
__u32 config;
__u32 sram_size;
+ __u32 pmu_counters;
};
/**
@@ -220,10 +226,54 @@ struct drm_ethosu_submit {
/** Input: Number of jobs passed in. */
__u32 job_count;
- /** Reserved, must be zero. */
+ /** Input: Id returned by DRM_ETHOSU_PERFMON_CREATE */
+ __u32 perfmon_id;
+};
+
+#define DRM_ETHOSU_MAX_PERF_EVENT_COUNTERS 8
+#define DRM_ETHOSU_MAX_PERF_COUNTERS \
+ (DRM_ETHOSU_MAX_PERF_EVENT_COUNTERS + 1)
+
+struct drm_ethosu_perfmon_create {
+ __u32 id;
+ __u32 ncounters;
+ __u16 counters[DRM_ETHOSU_MAX_PERF_EVENT_COUNTERS];
+};
+
+struct drm_ethosu_perfmon_destroy {
+ __u32 id;
__u32 pad;
};
+/*
+ * Returns the values of the performance counters tracked by this
+ * perfmon (as an array of (ncounters + 1) u64 values).
+ *
+ * No implicit synchronization is performed, so the user has to
+ * guarantee that any jobs using this perfmon have already been
+ * completed.
+ */
+struct drm_ethosu_perfmon_get_values {
+ __u32 id;
+ __u32 pad;
+ __u64 values_ptr;
+};
+
+#define DRM_ETHOSU_PERFMON_CLEAR_GLOBAL 0x0001
+
+/**
+ * struct drm_ethosu_perfmon_set_global - ioctl to define a global performance
+ * monitor
+ *
+ * The global performance monitor will be used for all jobs. If a global
+ * performance monitor is defined, jobs with a self-defined performance
+ * monitor won't be allowed.
+ */
+struct drm_ethosu_perfmon_set_global {
+ __u32 flags;
+ __u32 id;
+};
+
/**
* DRM_IOCTL_ETHOSU() - Build a ethosu IOCTL number
* @__access: Access type. Must be R, W or RW.
@@ -252,6 +302,14 @@ enum {
DRM_IOCTL_ETHOSU(WR, CMDSTREAM_BO_CREATE, cmdstream_bo_create),
DRM_IOCTL_ETHOSU_SUBMIT =
DRM_IOCTL_ETHOSU(WR, SUBMIT, submit),
+ DRM_IOCTL_ETHOSU_PERFMON_CREATE =
+ DRM_IOCTL_ETHOSU(WR, PERFMON_CREATE, perfmon_create),
+ DRM_IOCTL_ETHOSU_PERFMON_DESTROY =
+ DRM_IOCTL_ETHOSU(WR, PERFMON_DESTROY, perfmon_destroy),
+ DRM_IOCTL_ETHOSU_PERFMON_GET_VALUES =
+ DRM_IOCTL_ETHOSU(WR, PERFMON_GET_VALUES, perfmon_get_values),
+ DRM_IOCTL_ETHOSU_PERFMON_SET_GLOBAL =
+ DRM_IOCTL_ETHOSU(WR, PERFMON_SET_GLOBAL, perfmon_set_global),
};
#if defined(__cplusplus)