]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
firmware: arm_scmi: Track number of inflight SCMI transfers
authorPhilip Radford <philip.radford@arm.com>
Mon, 30 Jun 2025 10:55:42 +0000 (10:55 +0000)
committerSudeep Holla <sudeep.holla@arm.com>
Thu, 3 Jul 2025 15:15:44 +0000 (16:15 +0100)
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>
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c

index c6495c4a0e8a4bedfdae3093025752eb1ad9d8bd..ad9232c982ce774a9bf679e9d9cb1157fd3c27c9 100644 (file)
@@ -305,6 +305,7 @@ enum debug_counters {
        ERR_MSG_INVALID,
        ERR_MSG_NOMEM,
        ERR_PROTOCOL,
+       XFERS_INFLIGHT,
        SCMI_DEBUG_COUNTERS_LAST
 };
 
index 395fe928903576d9a5d7c552b8958a359697d7f0..5a4dac27afdf110b87d1cf21ecb798dbea55ea0c 100644 (file)
@@ -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,