]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
include: trace: Add tracepoint support for inflight xfer count
authorPhilip Radford <philip.radford@arm.com>
Mon, 30 Jun 2025 10:55:43 +0000 (10:55 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Thu, 3 Jul 2025 15:18:09 +0000 (16:18 +0100)
Enhance the existing SCMI transfer tracepoints by including the current
in-flight transfer count in `scmi_xfer_begin` and `scmi_xfer_end`.

Introduce a new helper `scmi_inflight_count()` to retrieve the active
transfer count from the SCMI debug counters when debug is enabled.

This trace data is useful for visualizing transfer activity over time
and identifying congestion or unexpected behavior in SCMI messaging.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Philip Radford <philip.radford@arm.com>
Message-Id: <20250630105544.531723-4-philip.radford@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c
drivers/firmware/arm_scmi/raw_mode.c
include/trace/events/scmi.h

index ad9232c982ce774a9bf679e9d9cb1157fd3c27c9..07b9e629276d2a11c1b337e367095c6419ce2bc7 100644 (file)
@@ -505,4 +505,5 @@ static struct platform_driver __drv = {                                            \
 void scmi_notification_instance_data_set(const struct scmi_handle *handle,
                                         void *priv);
 void *scmi_notification_instance_data_get(const struct scmi_handle *handle);
+int scmi_inflight_count(const struct scmi_handle *handle);
 #endif /* _SCMI_COMMON_H */
index 5a4dac27afdf110b87d1cf21ecb798dbea55ea0c..bd56a877fdfc8edf6dcd3351c3132a1074d018d7 100644 (file)
@@ -1443,7 +1443,8 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
 
        trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id,
                              xfer->hdr.protocol_id, xfer->hdr.seq,
-                             xfer->hdr.poll_completion);
+                             xfer->hdr.poll_completion,
+                             scmi_inflight_count(&info->handle));
 
        /* Clear any stale status */
        xfer->hdr.status = SCMI_SUCCESS;
@@ -1479,7 +1480,8 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
                info->desc->ops->mark_txdone(cinfo, ret, xfer);
 
        trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id,
-                           xfer->hdr.protocol_id, xfer->hdr.seq, ret);
+                           xfer->hdr.protocol_id, xfer->hdr.seq, ret,
+                           scmi_inflight_count(&info->handle));
 
        return ret;
 }
@@ -3416,6 +3418,17 @@ static struct dentry *scmi_debugfs_init(void)
        return d;
 }
 
+int scmi_inflight_count(const struct scmi_handle *handle)
+{
+       if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
+               struct scmi_info *info = handle_to_scmi_info(handle);
+
+               return atomic_read(&info->dbg->counters[XFERS_INFLIGHT]);
+       } else {
+               return 0;
+       }
+}
+
 static int __init scmi_driver_init(void)
 {
        scmi_quirks_initialize();
index 3d543b1d89479ded5d7e260e5d1afda844264b57..73db5492ab44bd5067e390e60dfdfffb50d3f299 100644 (file)
@@ -475,7 +475,8 @@ static void scmi_xfer_raw_worker(struct work_struct *work)
                        raw->desc->ops->mark_txdone(rw->cinfo, ret, xfer);
 
                trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id,
-                                   xfer->hdr.protocol_id, xfer->hdr.seq, ret);
+                                   xfer->hdr.protocol_id, xfer->hdr.seq,
+                                   ret, scmi_inflight_count(raw->handle));
 
                /* Wait also for an async delayed response if needed */
                if (!ret && xfer->async_done) {
@@ -642,7 +643,8 @@ static int scmi_do_xfer_raw_start(struct scmi_raw_mode_info *raw,
 
        trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id,
                              xfer->hdr.protocol_id, xfer->hdr.seq,
-                             xfer->hdr.poll_completion);
+                             xfer->hdr.poll_completion,
+                             scmi_inflight_count(raw->handle));
 
        ret = raw->desc->ops->send_message(rw->cinfo, xfer);
        if (ret) {
index 1273004811234a139217bf6cfc1920a36ae41af1..703b7bb68e4429362e2136d0614b461848d4d693 100644 (file)
@@ -36,8 +36,8 @@ TRACE_EVENT(scmi_fc_call,
 
 TRACE_EVENT(scmi_xfer_begin,
        TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq,
-                bool poll),
-       TP_ARGS(transfer_id, msg_id, protocol_id, seq, poll),
+                bool poll, int inflight),
+       TP_ARGS(transfer_id, msg_id, protocol_id, seq, poll, inflight),
 
        TP_STRUCT__entry(
                __field(int, transfer_id)
@@ -45,6 +45,7 @@ TRACE_EVENT(scmi_xfer_begin,
                __field(u8, protocol_id)
                __field(u16, seq)
                __field(bool, poll)
+               __field(int, inflight)
        ),
 
        TP_fast_assign(
@@ -53,11 +54,12 @@ TRACE_EVENT(scmi_xfer_begin,
                __entry->protocol_id = protocol_id;
                __entry->seq = seq;
                __entry->poll = poll;
+               __entry->inflight = inflight;
        ),
 
-       TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X poll=%u",
-               __entry->protocol_id, __entry->msg_id, __entry->seq,
-               __entry->transfer_id, __entry->poll)
+       TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X poll=%u inflight=%d",
+                 __entry->protocol_id, __entry->msg_id, __entry->seq,
+                 __entry->transfer_id, __entry->poll, __entry->inflight)
 );
 
 TRACE_EVENT(scmi_xfer_response_wait,
@@ -90,8 +92,8 @@ TRACE_EVENT(scmi_xfer_response_wait,
 
 TRACE_EVENT(scmi_xfer_end,
        TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq,
-                int status),
-       TP_ARGS(transfer_id, msg_id, protocol_id, seq, status),
+                int status, int inflight),
+       TP_ARGS(transfer_id, msg_id, protocol_id, seq, status, inflight),
 
        TP_STRUCT__entry(
                __field(int, transfer_id)
@@ -99,6 +101,7 @@ TRACE_EVENT(scmi_xfer_end,
                __field(u8, protocol_id)
                __field(u16, seq)
                __field(int, status)
+               __field(int, inflight)
        ),
 
        TP_fast_assign(
@@ -107,11 +110,12 @@ TRACE_EVENT(scmi_xfer_end,
                __entry->protocol_id = protocol_id;
                __entry->seq = seq;
                __entry->status = status;
+               __entry->inflight = inflight;
        ),
 
-       TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X s=%d",
-               __entry->protocol_id, __entry->msg_id, __entry->seq,
-               __entry->transfer_id, __entry->status)
+       TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X s=%d inflight=%d",
+                 __entry->protocol_id, __entry->msg_id, __entry->seq,
+                 __entry->transfer_id, __entry->status, __entry->inflight)
 );
 
 TRACE_EVENT(scmi_rx_done,