Skip to content

Commit f8e6563

Browse files
include: trace: Add tracepoint support for inflight xfer count
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>
1 parent a9cd861 commit f8e6563

4 files changed

Lines changed: 34 additions & 14 deletions

File tree

drivers/firmware/arm_scmi/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,5 @@ static struct platform_driver __drv = { \
505505
void scmi_notification_instance_data_set(const struct scmi_handle *handle,
506506
void *priv);
507507
void *scmi_notification_instance_data_get(const struct scmi_handle *handle);
508+
int scmi_inflight_count(const struct scmi_handle *handle);
508509
#endif /* _SCMI_COMMON_H */

drivers/firmware/arm_scmi/driver.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,8 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
14431443

14441444
trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id,
14451445
xfer->hdr.protocol_id, xfer->hdr.seq,
1446-
xfer->hdr.poll_completion);
1446+
xfer->hdr.poll_completion,
1447+
scmi_inflight_count(&info->handle));
14471448

14481449
/* Clear any stale status */
14491450
xfer->hdr.status = SCMI_SUCCESS;
@@ -1479,7 +1480,8 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
14791480
info->desc->ops->mark_txdone(cinfo, ret, xfer);
14801481

14811482
trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id,
1482-
xfer->hdr.protocol_id, xfer->hdr.seq, ret);
1483+
xfer->hdr.protocol_id, xfer->hdr.seq, ret,
1484+
scmi_inflight_count(&info->handle));
14831485

14841486
return ret;
14851487
}
@@ -3416,6 +3418,17 @@ static struct dentry *scmi_debugfs_init(void)
34163418
return d;
34173419
}
34183420

3421+
int scmi_inflight_count(const struct scmi_handle *handle)
3422+
{
3423+
if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_COUNTERS)) {
3424+
struct scmi_info *info = handle_to_scmi_info(handle);
3425+
3426+
return atomic_read(&info->dbg->counters[XFERS_INFLIGHT]);
3427+
} else {
3428+
return 0;
3429+
}
3430+
}
3431+
34193432
static int __init scmi_driver_init(void)
34203433
{
34213434
scmi_quirks_initialize();

drivers/firmware/arm_scmi/raw_mode.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ static void scmi_xfer_raw_worker(struct work_struct *work)
475475
raw->desc->ops->mark_txdone(rw->cinfo, ret, xfer);
476476

477477
trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id,
478-
xfer->hdr.protocol_id, xfer->hdr.seq, ret);
478+
xfer->hdr.protocol_id, xfer->hdr.seq,
479+
ret, scmi_inflight_count(raw->handle));
479480

480481
/* Wait also for an async delayed response if needed */
481482
if (!ret && xfer->async_done) {
@@ -642,7 +643,8 @@ static int scmi_do_xfer_raw_start(struct scmi_raw_mode_info *raw,
642643

643644
trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id,
644645
xfer->hdr.protocol_id, xfer->hdr.seq,
645-
xfer->hdr.poll_completion);
646+
xfer->hdr.poll_completion,
647+
scmi_inflight_count(raw->handle));
646648

647649
ret = raw->desc->ops->send_message(rw->cinfo, xfer);
648650
if (ret) {

include/trace/events/scmi.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ TRACE_EVENT(scmi_fc_call,
3636

3737
TRACE_EVENT(scmi_xfer_begin,
3838
TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq,
39-
bool poll),
40-
TP_ARGS(transfer_id, msg_id, protocol_id, seq, poll),
39+
bool poll, int inflight),
40+
TP_ARGS(transfer_id, msg_id, protocol_id, seq, poll, inflight),
4141

4242
TP_STRUCT__entry(
4343
__field(int, transfer_id)
4444
__field(u8, msg_id)
4545
__field(u8, protocol_id)
4646
__field(u16, seq)
4747
__field(bool, poll)
48+
__field(int, inflight)
4849
),
4950

5051
TP_fast_assign(
@@ -53,11 +54,12 @@ TRACE_EVENT(scmi_xfer_begin,
5354
__entry->protocol_id = protocol_id;
5455
__entry->seq = seq;
5556
__entry->poll = poll;
57+
__entry->inflight = inflight;
5658
),
5759

58-
TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X poll=%u",
59-
__entry->protocol_id, __entry->msg_id, __entry->seq,
60-
__entry->transfer_id, __entry->poll)
60+
TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X poll=%u inflight=%d",
61+
__entry->protocol_id, __entry->msg_id, __entry->seq,
62+
__entry->transfer_id, __entry->poll, __entry->inflight)
6163
);
6264

6365
TRACE_EVENT(scmi_xfer_response_wait,
@@ -90,15 +92,16 @@ TRACE_EVENT(scmi_xfer_response_wait,
9092

9193
TRACE_EVENT(scmi_xfer_end,
9294
TP_PROTO(int transfer_id, u8 msg_id, u8 protocol_id, u16 seq,
93-
int status),
94-
TP_ARGS(transfer_id, msg_id, protocol_id, seq, status),
95+
int status, int inflight),
96+
TP_ARGS(transfer_id, msg_id, protocol_id, seq, status, inflight),
9597

9698
TP_STRUCT__entry(
9799
__field(int, transfer_id)
98100
__field(u8, msg_id)
99101
__field(u8, protocol_id)
100102
__field(u16, seq)
101103
__field(int, status)
104+
__field(int, inflight)
102105
),
103106

104107
TP_fast_assign(
@@ -107,11 +110,12 @@ TRACE_EVENT(scmi_xfer_end,
107110
__entry->protocol_id = protocol_id;
108111
__entry->seq = seq;
109112
__entry->status = status;
113+
__entry->inflight = inflight;
110114
),
111115

112-
TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X s=%d",
113-
__entry->protocol_id, __entry->msg_id, __entry->seq,
114-
__entry->transfer_id, __entry->status)
116+
TP_printk("pt=%02X msg_id=%02X seq=%04X transfer_id=%X s=%d inflight=%d",
117+
__entry->protocol_id, __entry->msg_id, __entry->seq,
118+
__entry->transfer_id, __entry->status, __entry->inflight)
115119
);
116120

117121
TRACE_EVENT(scmi_rx_done,

0 commit comments

Comments
 (0)