diff mbox series

[2/4] firmware: arm_scmi: Add message dump traces for bad and unexpected replies

Message ID 20240228193238.2102157-3-cristian.marussi@arm.com (mailing list archive)
State New, archived
Headers show
Series SCMI misc small-updates | expand

Commit Message

Cristian Marussi Feb. 28, 2024, 7:32 p.m. UTC
Use trace_scmi_msg_dump also to account for late-timed-out, out-of-order
and unexpected replies.

Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
 drivers/firmware/arm_scmi/driver.c | 36 +++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 34d77802c990..a3182199f123 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -822,6 +822,13 @@  scmi_xfer_command_acquire(struct scmi_chan_info *cinfo, u32 msg_hdr)
 			"Message for %d type %d is not expected!\n",
 			xfer_id, msg_type);
 		spin_unlock_irqrestore(&minfo->xfer_lock, flags);
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr),
+				    !msg_type ? "_!RESP" : "_!DLYD",
+				    xfer_id, 0, NULL, 0);
+
 		return xfer;
 	}
 	refcount_inc(&xfer->users);
@@ -846,6 +853,13 @@  scmi_xfer_command_acquire(struct scmi_chan_info *cinfo, u32 msg_hdr)
 		dev_err(cinfo->dev,
 			"Invalid message type:%d for %d - HDR:0x%X  state:%d\n",
 			msg_type, xfer_id, msg_hdr, xfer->state);
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr),
+				    !msg_type ? "_!RESP" : "_!DLYD",
+				    xfer_id, 0, NULL, 0);
+
 		/* On error the refcount incremented above has to be dropped */
 		__scmi_xfer_put(minfo, xfer);
 		xfer = ERR_PTR(-EINVAL);
@@ -882,6 +896,12 @@  static void scmi_handle_notification(struct scmi_chan_info *cinfo,
 	if (IS_ERR(xfer)) {
 		dev_err(dev, "failed to get free message slot (%ld)\n",
 			PTR_ERR(xfer));
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr), "_!NOTI",
+				    MSG_XTRACT_TOKEN(msg_hdr), 0, NULL, 0);
+
 		scmi_clear_channel(info, cinfo);
 		return;
 	}
@@ -923,10 +943,18 @@  static void scmi_handle_response(struct scmi_chan_info *cinfo,
 
 	xfer = scmi_xfer_command_acquire(cinfo, msg_hdr);
 	if (IS_ERR(xfer)) {
+		u8 msg_type = MSG_XTRACT_TYPE(msg_hdr);
+
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr),
+				    !msg_type ? "_!RESP" : "_!DLYD",
+				    MSG_XTRACT_TOKEN(msg_hdr), 0, NULL, 0);
+
 		if (IS_ENABLED(CONFIG_ARM_SCMI_RAW_MODE_SUPPORT))
 			scmi_raw_error_report(info->raw, cinfo, msg_hdr, priv);
 
-		if (MSG_XTRACT_TYPE(msg_hdr) == MSG_TYPE_DELAYED_RESP)
+		if (msg_type == MSG_TYPE_DELAYED_RESP)
 			scmi_clear_channel(info, cinfo);
 		return;
 	}
@@ -990,6 +1018,7 @@  static void scmi_handle_response(struct scmi_chan_info *cinfo,
 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv)
 {
 	u8 msg_type = MSG_XTRACT_TYPE(msg_hdr);
+	struct scmi_info *info = handle_to_scmi_info(cinfo->handle);
 
 	switch (msg_type) {
 	case MSG_TYPE_NOTIFICATION:
@@ -1001,6 +1030,11 @@  void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv)
 		break;
 	default:
 		WARN_ONCE(1, "received unknown msg_type:%d\n", msg_type);
+		trace_scmi_msg_dump(info->id, cinfo->id,
+				    MSG_XTRACT_PROT_ID(msg_hdr),
+				    MSG_XTRACT_ID(msg_hdr), "_!UNKN",
+				    MSG_XTRACT_TOKEN(msg_hdr), 0, NULL, 0);
+
 		break;
 	}
 }