diff mbox series

[v2,1/2] platform/x86/amd/hsmp: Add new error code and error logs

Message ID 20241112120450.2407125-1-suma.hegde@amd.com (mailing list archive)
State Accepted, archived
Headers show
Series [v2,1/2] platform/x86/amd/hsmp: Add new error code and error logs | expand

Commit Message

Suma Hegde Nov. 12, 2024, 12:04 p.m. UTC
Firmware is updated to send HSMP_ERR_PREREQ_NOT_SATISFIED(0xFD) and
HSMP_ERR_SMU_BUSY(0xFC) error codes. Add them here.

Add error logs to make it easy to understand the failure reason for
different error conditions.

Replace pr_err() with dev_err() to identify the driver printing the
error.

Signed-off-by: Suma Hegde <suma.hegde@amd.com>
Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
---
Changes from v1:
EPERM error return code is moved to next patch as per Ilpo's suggestion.

 drivers/platform/x86/amd/hsmp/hsmp.c | 34 ++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 10 deletions(-)

Comments

Ilpo Järvinen Nov. 13, 2024, 1:52 p.m. UTC | #1
On Tue, 12 Nov 2024 12:04:49 +0000, Suma Hegde wrote:

> Firmware is updated to send HSMP_ERR_PREREQ_NOT_SATISFIED(0xFD) and
> HSMP_ERR_SMU_BUSY(0xFC) error codes. Add them here.
> 
> Add error logs to make it easy to understand the failure reason for
> different error conditions.
> 
> Replace pr_err() with dev_err() to identify the driver printing the
> error.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo branch. Note it will show up in the public
platform-drivers-x86/review-ilpo branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/2] platform/x86/amd/hsmp: Add new error code and error logs
      commit: 996b318e6fce255035efd555837d1250433bb0e7
[2/2] platform/x86/amd/hsmp: Change the error type
      commit: 8560b2775a08bf511576a18922c3bde920e69494

--
 i.
diff mbox series

Patch

diff --git a/drivers/platform/x86/amd/hsmp/hsmp.c b/drivers/platform/x86/amd/hsmp/hsmp.c
index 82d8ba2e1204..ce91b2cefca2 100644
--- a/drivers/platform/x86/amd/hsmp/hsmp.c
+++ b/drivers/platform/x86/amd/hsmp/hsmp.c
@@ -7,8 +7,6 @@ 
  * This file provides a device implementation for HSMP interface
  */
 
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
 #include <asm/amd_hsmp.h>
 #include <asm/amd_nb.h>
 
@@ -25,6 +23,8 @@ 
 #define HSMP_STATUS_OK		0x01
 #define HSMP_ERR_INVALID_MSG	0xFE
 #define HSMP_ERR_INVALID_INPUT	0xFF
+#define HSMP_ERR_PREREQ_NOT_SATISFIED	0xFD
+#define HSMP_ERR_SMU_BUSY		0xFC
 
 /* Timeout in millsec */
 #define HSMP_MSG_TIMEOUT	100
@@ -61,7 +61,7 @@  static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
 	mbox_status = HSMP_STATUS_NOT_READY;
 	ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_WR);
 	if (ret) {
-		pr_err("Error %d clearing mailbox status register\n", ret);
+		dev_err(sock->dev, "Error %d clearing mailbox status register\n", ret);
 		return ret;
 	}
 
@@ -71,7 +71,7 @@  static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
 		ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2),
 					  &msg->args[index], HSMP_WR);
 		if (ret) {
-			pr_err("Error %d writing message argument %d\n", ret, index);
+			dev_err(sock->dev, "Error %d writing message argument %d\n", ret, index);
 			return ret;
 		}
 		index++;
@@ -80,7 +80,7 @@  static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
 	/* Write the message ID which starts the operation */
 	ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_id_off, &msg->msg_id, HSMP_WR);
 	if (ret) {
-		pr_err("Error %d writing message ID %u\n", ret, msg->msg_id);
+		dev_err(sock->dev, "Error %d writing message ID %u\n", ret, msg->msg_id);
 		return ret;
 	}
 
@@ -97,7 +97,7 @@  static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
 	while (time_before(jiffies, timeout)) {
 		ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_resp_off, &mbox_status, HSMP_RD);
 		if (ret) {
-			pr_err("Error %d reading mailbox status\n", ret);
+			dev_err(sock->dev, "Error %d reading mailbox status\n", ret);
 			return ret;
 		}
 
@@ -110,14 +110,28 @@  static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
 	}
 
 	if (unlikely(mbox_status == HSMP_STATUS_NOT_READY)) {
+		dev_err(sock->dev, "Message ID 0x%X failure : SMU tmeout (status = 0x%X)\n",
+			msg->msg_id, mbox_status);
 		return -ETIMEDOUT;
 	} else if (unlikely(mbox_status == HSMP_ERR_INVALID_MSG)) {
+		dev_err(sock->dev, "Message ID 0x%X failure : Invalid message (status = 0x%X)\n",
+			msg->msg_id, mbox_status);
 		return -ENOMSG;
 	} else if (unlikely(mbox_status == HSMP_ERR_INVALID_INPUT)) {
+		dev_err(sock->dev, "Message ID 0x%X failure : Invalid arguments (status = 0x%X)\n",
+			msg->msg_id, mbox_status);
 		return -EINVAL;
+	} else if (unlikely(mbox_status == HSMP_ERR_PREREQ_NOT_SATISFIED)) {
+		dev_err(sock->dev, "Message ID 0x%X failure : Prerequisite not satisfied (status = 0x%X)\n",
+			msg->msg_id, mbox_status);
+		return -EREMOTEIO;
+	} else if (unlikely(mbox_status == HSMP_ERR_SMU_BUSY)) {
+		dev_err(sock->dev, "Message ID 0x%X failure : SMU BUSY (status = 0x%X)\n",
+			msg->msg_id, mbox_status);
+		return -EBUSY;
 	} else if (unlikely(mbox_status != HSMP_STATUS_OK)) {
-		pr_err("Message ID %u unknown failure (status = 0x%X)\n",
-		       msg->msg_id, mbox_status);
+		dev_err(sock->dev, "Message ID 0x%X unknown failure (status = 0x%X)\n",
+			msg->msg_id, mbox_status);
 		return -EIO;
 	}
 
@@ -133,8 +147,8 @@  static int __hsmp_send_message(struct hsmp_socket *sock, struct hsmp_message *ms
 		ret = sock->amd_hsmp_rdwr(sock, mbinfo->msg_arg_off + (index << 2),
 					  &msg->args[index], HSMP_RD);
 		if (ret) {
-			pr_err("Error %d reading response %u for message ID:%u\n",
-			       ret, index, msg->msg_id);
+			dev_err(sock->dev, "Error %d reading response %u for message ID:%u\n",
+				ret, index, msg->msg_id);
 			break;
 		}
 		index++;