From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: sudeep.holla@kernel.org, james.quinlan@broadcom.com,
f.fainelli@gmail.com, vincent.guittot@linaro.org,
etienne.carriere@st.com, peng.fan@oss.nxp.com,
michal.simek@amd.com, d-gole@ti.com, jic23@kernel.org,
elif.topuz@arm.com, lukasz.luba@arm.com, philip.radford@arm.com,
david@kernel.org, souvik.chakravarty@arm.com, leitao@kernel.org,
kas@kernel.org, puranjay@kernel.org, usama.arif@linux.dev,
kernel-team@meta.com, Cristian Marussi <cristian.marussi@arm.com>
Subject: [PATCH v11 13/25] firmware: arm-scmi: Add telemetry generic event support
Date: Sun, 6 Sep 2026 11:06:11 +0100 [thread overview]
Message-ID: <20260906100623.3488327-14-cristian.marussi@arm.com> (raw)
In-Reply-To: <20260906100623.3488327-1-cristian.marussi@arm.com>
Add support to allow SCMI driver users to subscribe/unsubscribe to specific
Telemetry abstract (non protocol) events.
This enables SCMI drivers to subscribe to available events by registering
an eventfd context that the core SCMI stack will use as a signalling
mechanisms.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v10 --> v11
- move events cleanup into resource_free
v8 --> v9
- add a TLM_EVT_DUMMY placeholder (waiting for more events later on..)
---
drivers/firmware/arm_scmi/telemetry.c | 97 +++++++++++++++++++++++++++
include/linux/scmi_protocol.h | 16 +++++
2 files changed, 113 insertions(+)
diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c
index 6409ee727158..4bb2010c89b5 100644
--- a/drivers/firmware/arm_scmi/telemetry.c
+++ b/drivers/firmware/arm_scmi/telemetry.c
@@ -12,6 +12,7 @@
#include <linux/completion.h>
#include <linux/err.h>
#include <linux/delay.h>
+#include <linux/eventfd.h>
#include <linux/io.h>
#include <linux/limits.h>
#include <linux/minmax.h>
@@ -479,6 +480,11 @@ enum de_state {
ENA_MAX
};
+struct telemetry_event {
+ struct eventfd_ctx *ctx;
+ struct list_head item;
+};
+
struct telemetry_info {
bool streaming_mode;
unsigned int num_shmti;
@@ -505,6 +511,9 @@ struct telemetry_info {
struct list_head free_des;
struct list_head fcs_des;
struct scmi_telemetry_info info;
+ /* Mutex to protect access to @events */
+ struct mutex events_mtx;
+ struct list_head events[SCMI_TLM_EVT_MAX];
struct notifier_block telemetry_nb;
atomic_t rinfo_initializing;
struct completion rinfo_initdone;
@@ -524,6 +533,21 @@ static int scmi_telemetry_shmti_scan(struct telemetry_info *ti,
static inline void scmi_telemetry_uuid_link(struct telemetry_de *tde,
struct telemetry_uuid *uuid);
+static int scmi_telemetry_event_signal(struct telemetry_info *ti,
+ enum scmi_telemetry_event type)
+{
+ struct telemetry_event *evt;
+
+ if (type >= SCMI_TLM_EVT_MAX)
+ return -EINVAL;
+
+ guard(mutex)(&ti->events_mtx);
+ list_for_each_entry(evt, &ti->events[type], item)
+ eventfd_signal(evt->ctx);
+
+ return 0;
+}
+
static inline void
scmi_telemetry_de_state_update(struct telemetry_info *ti, enum de_state state,
bool *current_state, const bool next_state)
@@ -3330,6 +3354,54 @@ static int scmi_telemetry_reset(const struct scmi_protocol_handle *ph)
return ret;
}
+static int scmi_telemetry_event_subscribe(const struct scmi_protocol_handle *ph,
+ enum scmi_telemetry_event type,
+ struct eventfd_ctx *ctx)
+{
+ struct telemetry_info *ti = ph->get_priv(ph);
+ struct telemetry_event *evt;
+
+ if (type >= SCMI_TLM_EVT_MAX)
+ return -EINVAL;
+
+ evt = kzalloc_obj(*evt);
+ if (!evt)
+ return -ENOMEM;
+
+ evt->ctx = ctx;
+ guard(mutex)(&ti->events_mtx);
+ list_add(&evt->item, &ti->events[type]);
+
+ trace_scmi_tlm_access(0, "TLM_EVT_SUBS", 0, 0);
+
+ return 0;
+}
+
+static int scmi_telemetry_event_unsubscribe(const struct scmi_protocol_handle *ph,
+ enum scmi_telemetry_event type,
+ struct eventfd_ctx *ctx)
+{
+ struct telemetry_info *ti = ph->get_priv(ph);
+ struct telemetry_event *evt, *n;
+
+ if (type >= SCMI_TLM_EVT_MAX)
+ return -EINVAL;
+
+ guard(mutex)(&ti->events_mtx);
+ list_for_each_entry_safe(evt, n, &ti->events[type], item) {
+ if (evt->ctx == ctx) {
+ list_del(&evt->item);
+ kfree(evt);
+
+ trace_scmi_tlm_access(0, "TLM_EVT_UNSUBS", 0, 0);
+
+ break;
+ }
+ }
+
+ return 0;
+}
+
static const struct scmi_telemetry_proto_ops tlm_proto_ops = {
.info_get = scmi_telemetry_info_get,
.de_lookup = scmi_telemetry_de_lookup,
@@ -3341,6 +3413,8 @@ static const struct scmi_telemetry_proto_ops tlm_proto_ops = {
.des_bulk_read = scmi_telemetry_des_bulk_read,
.des_sample_get = scmi_telemetry_des_sample_get,
.reset = scmi_telemetry_reset,
+ .event_subscribe = scmi_telemetry_event_subscribe,
+ .event_unsubscribe = scmi_telemetry_event_unsubscribe,
};
static bool
@@ -3555,6 +3629,23 @@ __scmi_telemetry_resources_get(struct telemetry_info *ti)
return smp_load_acquire(&ti->rinfo);
}
+static void scmi_telemetry_event_cleanup(struct telemetry_info *ti)
+{
+ guard(mutex)(&ti->events_mtx);
+ /* Clear any residual events */
+ for (int type = 0; type < SCMI_TLM_EVT_MAX; type++) {
+ struct telemetry_event *evt, *n;
+
+ list_for_each_entry_safe(evt, n, &ti->events[type], item) {
+ dev_warn(ti->ph->dev,
+ "Found UN-SUBSCRIBED event type %d!\n", type);
+ list_del(&evt->item);
+ eventfd_ctx_put(evt->ctx);
+ kfree(evt);
+ }
+ }
+}
+
static void scmi_telemetry_resources_free(void *arg)
{
struct scmi_telemetry_res_info *rinfo;
@@ -3595,6 +3686,9 @@ static void scmi_telemetry_resources_free(void *arg)
scmi_telemetry_line_put(line);
xa_destroy(&ti->xa_lines);
+ /* Cleanup any still registered event */
+ scmi_telemetry_event_cleanup(ti);
+
kfree(ti->tdes);
kfree(rinfo->des);
kfree(rinfo->dei_store);
@@ -3750,6 +3844,9 @@ static int scmi_telemetry_instance_init(struct telemetry_info *ti)
if (ret)
return ret;
+ for (int i = 0; i < SCMI_TLM_EVT_MAX; i++)
+ INIT_LIST_HEAD(&ti->events[i]);
+ mutex_init(&ti->events_mtx);
atomic_set(&ti->des_enabled[ENA_STATE], 0);
atomic_set(&ti->des_enabled[ENA_TSTAMP], 0);
mutex_init(&ti->des_enabled_mtx);
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 2d571c78613b..06591b27f365 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -11,6 +11,7 @@
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/device.h>
+#include <linux/eventfd.h>
#include <linux/notifier.h>
#include <linux/types.h>
#include <linux/uuid.h>
@@ -994,6 +995,11 @@ struct scmi_telemetry_de_sample {
unsigned long long val;
};
+enum scmi_telemetry_event {
+ SCMI_TLM_EVT_DUMMY,
+ SCMI_TLM_EVT_MAX,
+};
+
/**
* struct scmi_telemetry_proto_ops - represents the various operations provided
* by SCMI Telemetry Protocol
@@ -1017,6 +1023,10 @@ struct scmi_telemetry_de_sample {
* This causes an immediate update platform-side of all the
* enabled DEs.
* @reset: reset configuration and telemetry data.
+ * @event_subscribe: subscribe to the specified event @type using the provided
+ * @eventfd_ctx.
+ * @event_unsubscribe: unsubscribe to the specified event @type the previously
+ * registered @eventfd_ctx.
*/
struct scmi_telemetry_proto_ops {
const struct scmi_telemetry_info __must_check *(*info_get)
@@ -1044,6 +1054,12 @@ struct scmi_telemetry_proto_ops {
int __must_check (*des_sample_get)(const struct scmi_protocol_handle *ph,
int grp_id, int *num_samples,
struct scmi_telemetry_de_sample *samples);
+ int (*event_subscribe)(const struct scmi_protocol_handle *ph,
+ enum scmi_telemetry_event type,
+ struct eventfd_ctx *ctx);
+ int (*event_unsubscribe)(const struct scmi_protocol_handle *ph,
+ enum scmi_telemetry_event type,
+ struct eventfd_ctx *ctx);
int (*reset)(const struct scmi_protocol_handle *ph);
};
--
2.54.0
next prev parent reply other threads:[~2026-09-06 10:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 10:05 [PATCH v11 00/25] Introduce SCMI Telemetry support Cristian Marussi
2026-09-06 10:05 ` [PATCH v11 01/25] firmware: arm_scmi: Add new SCMIv4.0 error codes definitions Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 02/25] firmware: arm_scmi: Allow registration of unknown-size events/reports Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 03/25] firmware: arm_scmi: Introduce protocol instance notifiers Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 04/25] dt-bindings: firmware: arm,scmi: Add support for telemetry protocol Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 05/25] include: trace: Add Telemetry trace events Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 06/25] firmware: arm_scmi: Add basic Telemetry support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 07/25] firmware: arm_scmi: Add support to parse SHMTIs areas Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 08/25] firmware: arm_scmi: Add Telemetry configuration operations Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 09/25] firmware: arm_scmi: Add Telemetry DataEvent read capabilities Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 10/25] firmware: arm_scmi: Add support for Telemetry reset Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 11/25] firmware: arm_scmi: Add Telemetry notification support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 12/25] firmware: arm_scmi: Add support for boot-on Telemetry Cristian Marussi
2026-09-06 10:06 ` Cristian Marussi [this message]
2026-09-06 10:06 ` [PATCH v11 14/25] firmware: arm_scmi: Add Telemetry generation counter event Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 15/25] firmware: arm_scmi: Add common per-protocol debugfs support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 16/25] firmware: arm_scmi: Add Telemetry debugfs SHMTI dump support Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 17/25] firmware: arm_scmi: Add Telemetry debugfs ABI documentation Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 18/25] firmware: arm_scmi: Expose per-instance identifier Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 19/25] firmware: arm_scmi: Add un-managed methods to get/put protocols operations Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 20/25] uapi: Add ARM SCMI Telemetry definitions Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 21/25] firmware: arm_scmi: Add System Telemetry driver Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 22/25] docs: ioctl-number: Add SCMI Ioctls Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 23/25] [RFC] Documentation: Add SCMI System Telemetry documentation Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 24/25] [RFC] tools/scmi: Add SCMI Telemetry testing tool Cristian Marussi
2026-09-06 10:06 ` [PATCH v11 25/25] [RFC] kselftest/arm64: Add SCMI Telemetry UAPI compliance testcases Cristian Marussi
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=20260906100623.3488327-14-cristian.marussi@arm.com \
--to=cristian.marussi@arm.com \
--cc=arm-scmi@vger.kernel.org \
--cc=d-gole@ti.com \
--cc=david@kernel.org \
--cc=elif.topuz@arm.com \
--cc=etienne.carriere@st.com \
--cc=f.fainelli@gmail.com \
--cc=james.quinlan@broadcom.com \
--cc=jic23@kernel.org \
--cc=kas@kernel.org \
--cc=kernel-team@meta.com \
--cc=leitao@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=philip.radford@arm.com \
--cc=puranjay@kernel.org \
--cc=souvik.chakravarty@arm.com \
--cc=sudeep.holla@kernel.org \
--cc=usama.arif@linux.dev \
--cc=vincent.guittot@linaro.org \
/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