[PATCH 2/3] Track basic SCMI statistics
Luke Parkin
luke.parkin at arm.com
Mon Jul 1 07:28:50 PDT 2024
Add scmi_debug_stats struct with atomic_t types to prevent racing.
Add tracking of 5 initial statistics
- sent_ok & sent_fail
- response_ok & dlyd_response_ok
- xfers_response_timeout
Signed-off-by: Luke Parkin <luke.parkin at arm.com>
---
drivers/firmware/arm_scmi/driver.c | 46 +++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 6b6957f4743f..f69dff699d48 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -125,6 +125,22 @@ struct scmi_debug_info {
bool is_atomic;
};
+/**
+ * struct scmi_debug_stats - Debug statistics
+ * @sent_ok: Count of successful sends
+ * @sent_fail: Count of failed sends
+ * @response_ok: Count of successful responses
+ * @dlyd_response_ok: Count of successful delayed responses
+ * @xfers_response_timeout: Count of xfer response timeouts
+ */
+struct scmi_debug_stats {
+ atomic_t sent_ok;
+ atomic_t sent_fail;
+ atomic_t response_ok;
+ atomic_t dlyd_response_ok;
+ atomic_t xfers_response_timeout;
+};
+
/**
* struct scmi_info - Structure representing a SCMI instance
*
@@ -141,6 +157,7 @@ struct scmi_debug_info {
* @protocols: IDR for protocols' instance descriptors initialized for
* this SCMI instance: populated on protocol's first attempted
* usage.
+ * @stats: Contains several atomic_t's for tracking various statistics
* @protocols_mtx: A mutex to protect protocols instances initialization.
* @protocols_imp: List of protocols implemented, currently maximum of
* scmi_revision_info.num_protocols elements allocated by the
@@ -174,6 +191,7 @@ struct scmi_info {
struct idr tx_idr;
struct idr rx_idr;
struct idr protocols;
+ struct scmi_debug_stats stats;
/* Ensure mutual exclusive access to protocols instance array */
struct mutex protocols_mtx;
u8 *protocols_imp;
@@ -1143,7 +1161,12 @@ static void scmi_handle_response(struct scmi_chan_info *cinfo,
SCMI_RAW_REPLY_QUEUE,
cinfo->id);
}
-
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) {
+ if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP)
+ atomic_inc(&info->stats.dlyd_response_ok);
+ else
+ atomic_inc(&info->stats.response_ok);
+ }
scmi_xfer_command_release(info, xfer);
}
@@ -1279,6 +1302,12 @@ static int scmi_wait_for_reply(struct device *dev, const struct scmi_desc *desc,
}
}
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS) && ret == -ETIMEDOUT) {
+ struct scmi_info *info =
+ handle_to_scmi_info(cinfo->handle);
+ atomic_inc(&info->stats.xfers_response_timeout);
+ }
+
return ret;
}
@@ -1414,6 +1443,13 @@ static int do_xfer(const struct scmi_protocol_handle *ph,
trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id,
xfer->hdr.protocol_id, xfer->hdr.seq, ret);
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) {
+ if (ret == 0)
+ atomic_inc(&info->stats.sent_ok);
+ else
+ atomic_inc(&info->stats.sent_fail);
+ }
+
return ret;
}
@@ -2994,6 +3030,14 @@ static int scmi_probe(struct platform_device *pdev)
handle->devm_protocol_get = scmi_devm_protocol_get;
handle->devm_protocol_put = scmi_devm_protocol_put;
+ if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) {
+ atomic_set(&info->stats.response_ok, 0);
+ atomic_set(&info->stats.sent_fail, 0);
+ atomic_set(&info->stats.sent_ok, 0);
+ atomic_set(&info->stats.dlyd_response_ok, 0);
+ atomic_set(&info->stats.xfers_response_timeout, 0);
+ }
+
/* System wide atomic threshold for atomic ops .. if any */
if (!of_property_read_u32(np, "atomic-threshold-us",
&info->atomic_threshold))
--
2.34.1
More information about the linux-arm-kernel
mailing list