Skip to content

Commit a9cd861

Browse files
firmware: arm_scmi: Track number of inflight SCMI transfers
Add a new debug counter, `XFERS_INFLIGHT`, to track the number of currently active in-flight SCMI message transfers. This helps in understanding system behavior and diagnosing potential issues with pending or stuck messages. The counter is incremented when a transfer is registered as in-flight, and decremented when it completes and is released. It is automatically added to debugfs for visibility through SCMI debugfs. Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Philip Radford <philip.radford@arm.com> Message-Id: <20250630105544.531723-3-philip.radford@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
1 parent 555e917 commit a9cd861

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/firmware/arm_scmi/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ enum debug_counters {
305305
ERR_MSG_INVALID,
306306
ERR_MSG_NOMEM,
307307
ERR_PROTOCOL,
308+
XFERS_INFLIGHT,
308309
SCMI_DEBUG_COUNTERS_LAST
309310
};
310311

drivers/firmware/arm_scmi/driver.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct scmi_info {
190190
};
191191

192192
#define handle_to_scmi_info(h) container_of(h, struct scmi_info, handle)
193+
#define tx_minfo_to_scmi_info(h) container_of(h, struct scmi_info, tx_minfo)
193194
#define bus_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, bus_nb)
194195
#define req_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, dev_req_nb)
195196

@@ -603,9 +604,14 @@ static inline void
603604
scmi_xfer_inflight_register_unlocked(struct scmi_xfer *xfer,
604605
struct scmi_xfers_info *minfo)
605606
{
607+
/* In this context minfo will be tx_minfo due to the xfer pending */
608+
struct scmi_info *info = tx_minfo_to_scmi_info(minfo);
609+
606610
/* Set in-flight */
607611
set_bit(xfer->hdr.seq, minfo->xfer_alloc_table);
608612
hash_add(minfo->pending_xfers, &xfer->node, xfer->hdr.seq);
613+
scmi_inc_count(info->dbg->counters, XFERS_INFLIGHT);
614+
609615
xfer->pending = true;
610616
}
611617

@@ -807,9 +813,13 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer)
807813
spin_lock_irqsave(&minfo->xfer_lock, flags);
808814
if (refcount_dec_and_test(&xfer->users)) {
809815
if (xfer->pending) {
816+
struct scmi_info *info = tx_minfo_to_scmi_info(minfo);
817+
810818
scmi_xfer_token_clear(minfo, xfer);
811819
hash_del(&xfer->node);
812820
xfer->pending = false;
821+
822+
scmi_dec_count(info->dbg->counters, XFERS_INFLIGHT);
813823
}
814824
hlist_add_head(&xfer->node, &minfo->free_xfers);
815825
}
@@ -2912,6 +2922,7 @@ static const char * const dbg_counter_strs[] = {
29122922
"err_msg_invalid",
29132923
"err_msg_nomem",
29142924
"err_protocol",
2925+
"xfers_inflight",
29152926
};
29162927

29172928
static ssize_t reset_all_on_write(struct file *filp, const char __user *buf,

0 commit comments

Comments
 (0)