Commit a9cd861e authored by Philip Radford's avatar Philip Radford Committed by Sudeep Holla
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: default avatarCristian Marussi <cristian.marussi@arm.com>
Signed-off-by: default avatarPhilip Radford <philip.radford@arm.com>
Message-Id: <20250630105544.531723-3-philip.radford@arm.com>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 555e9174
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -305,6 +305,7 @@ enum debug_counters {
	ERR_MSG_INVALID,
	ERR_MSG_NOMEM,
	ERR_PROTOCOL,
	XFERS_INFLIGHT,
	SCMI_DEBUG_COUNTERS_LAST
};

+11 −0
Original line number Diff line number Diff line
@@ -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,