diff options
| author | Philip Radford <philip.radford@arm.com> | 2025-06-30 13:55:42 +0300 |
|---|---|---|
| committer | Sudeep Holla <sudeep.holla@arm.com> | 2025-07-03 18:15:44 +0300 |
| commit | a9cd861e61ae80b441af87f332bc3f44aa0b7c02 (patch) | |
| tree | c35026a47cbff72fa56dfef48d0f0780448a8a15 | |
| parent | 555e9174ef06b7bfc54a3127a8d8fc47d55d04f4 (diff) | |
| download | linux-a9cd861e61ae80b441af87f332bc3f44aa0b7c02.tar.xz | |
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>
| -rw-r--r-- | drivers/firmware/arm_scmi/common.h | 1 | ||||
| -rw-r--r-- | drivers/firmware/arm_scmi/driver.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h index c6495c4a0e8a..ad9232c982ce 100644 --- a/drivers/firmware/arm_scmi/common.h +++ b/drivers/firmware/arm_scmi/common.h @@ -305,6 +305,7 @@ enum debug_counters { ERR_MSG_INVALID, ERR_MSG_NOMEM, ERR_PROTOCOL, + XFERS_INFLIGHT, SCMI_DEBUG_COUNTERS_LAST }; diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 395fe9289035..5a4dac27afdf 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -190,6 +190,7 @@ struct scmi_info { }; #define handle_to_scmi_info(h) container_of(h, struct scmi_info, handle) +#define tx_minfo_to_scmi_info(h) container_of(h, struct scmi_info, tx_minfo) #define bus_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, bus_nb) #define req_nb_to_scmi_info(nb) container_of(nb, struct scmi_info, dev_req_nb) @@ -603,9 +604,14 @@ static inline void scmi_xfer_inflight_register_unlocked(struct scmi_xfer *xfer, struct scmi_xfers_info *minfo) { + /* In this context minfo will be tx_minfo due to the xfer pending */ + struct scmi_info *info = tx_minfo_to_scmi_info(minfo); + /* Set in-flight */ set_bit(xfer->hdr.seq, minfo->xfer_alloc_table); hash_add(minfo->pending_xfers, &xfer->node, xfer->hdr.seq); + scmi_inc_count(info->dbg->counters, XFERS_INFLIGHT); + xfer->pending = true; } @@ -807,9 +813,13 @@ __scmi_xfer_put(struct scmi_xfers_info *minfo, struct scmi_xfer *xfer) spin_lock_irqsave(&minfo->xfer_lock, flags); if (refcount_dec_and_test(&xfer->users)) { if (xfer->pending) { + struct scmi_info *info = tx_minfo_to_scmi_info(minfo); + scmi_xfer_token_clear(minfo, xfer); hash_del(&xfer->node); xfer->pending = false; + + scmi_dec_count(info->dbg->counters, XFERS_INFLIGHT); } hlist_add_head(&xfer->node, &minfo->free_xfers); } @@ -2912,6 +2922,7 @@ static const char * const dbg_counter_strs[] = { "err_msg_invalid", "err_msg_nomem", "err_protocol", + "xfers_inflight", }; static ssize_t reset_all_on_write(struct file *filp, const char __user *buf, |
