public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Potin Lai <potin.lai.pt@gmail.com>
To: Corey Minyard <minyard@acm.org>, Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Quan Nguyen <quan@os.amperecomputing.com>
Cc: openipmi-developer@lists.sourceforge.net,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Patrick Williams <patrick@stwcx.xyz>,
	Cosmo Chou <cosmo.chou@quantatw.com>,
	Potin Lai <potin.lai@quantatw.com>,
	Potin Lai <potin.lai.pt@gmail.com>
Subject: [PATCH 2/2] ipmi: ssif_bmc: support skipping ARM SBMR bootprogress response
Date: Wed, 12 Jun 2024 12:32:55 +0800	[thread overview]
Message-ID: <20240612043255.1849007-3-potin.lai.pt@gmail.com> (raw)
In-Reply-To: <20240612043255.1849007-1-potin.lai.pt@gmail.com>

In ARM SBMR document, the host can chosse to not read back the response of
“Send Boot Progress Code” command.

To avoid SSIF being in a wrong state due to host not read back the
response, add the implementation of "arm-sbmr,skip-bootprogress-response"
property for skipping the response of "Send Boot Progress Code" command
from userspace.

Signed-off-by: Potin Lai <potin.lai.pt@gmail.com>
---
 drivers/char/ipmi/ssif_bmc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/char/ipmi/ssif_bmc.c b/drivers/char/ipmi/ssif_bmc.c
index 56346fb328727..3386a8bd18afd 100644
--- a/drivers/char/ipmi/ssif_bmc.c
+++ b/drivers/char/ipmi/ssif_bmc.c
@@ -39,6 +39,11 @@
 #define SSIF_IPMI_MULTIPART_READ_START          0x3
 #define SSIF_IPMI_MULTIPART_READ_MIDDLE         0x9
 
+#define GET_NETFN(netfn_lun)                    ((netfn_lun >> 2) & 0xfe)
+#define IPMI_GROUP_EXT_NETFN                    0x2C
+#define IPMI_SBMR_GROUP                         0xAE
+#define IPMI_SBMR_BOOTPROGRESS_CMD              0x02
+
 /*
  * IPMI 2.0 Spec, section 12.7 SSIF Timing,
  * Request-to-Response Time is T6max(250ms) - T1max(20ms) - 3ms = 227ms
@@ -102,6 +107,8 @@ struct ssif_bmc_ctx {
 	struct ssif_part_buffer part_buf;
 	struct ipmi_ssif_msg    response;
 	struct ipmi_ssif_msg    request;
+	/* Flag to skip response of Send Boot Progress Code */
+	bool                    skip_bootprogress_resp;
 };
 
 static inline struct ssif_bmc_ctx *to_ssif_bmc(struct file *file)
@@ -187,6 +194,20 @@ static ssize_t ssif_bmc_write(struct file *file, const char __user *buf, size_t
 		return -EINVAL;
 
 	spin_lock_irqsave(&ssif_bmc->lock, flags);
+	if (ssif_bmc->skip_bootprogress_resp &&
+	    GET_NETFN(msg.payload[0]) == IPMI_GROUP_EXT_NETFN &&
+	    msg.payload[1] == IPMI_SBMR_BOOTPROGRESS_CMD &&
+	    msg.payload[3] == IPMI_SBMR_GROUP) {
+		if (ssif_bmc->response_timer_inited) {
+			del_timer(&ssif_bmc->response_timer);
+			ssif_bmc->response_timer_inited = false;
+		}
+		ssif_bmc->busy = false;
+		memset(&ssif_bmc->request, 0, sizeof(struct ipmi_ssif_msg));
+		spin_unlock_irqrestore(&ssif_bmc->lock, flags);
+		return count;
+	}
+
 	while (ssif_bmc->response_in_progress) {
 		spin_unlock_irqrestore(&ssif_bmc->lock, flags);
 		if (file->f_flags & O_NONBLOCK)
@@ -806,6 +827,10 @@ static int ssif_bmc_probe(struct i2c_client *client)
 	if (!ssif_bmc)
 		return -ENOMEM;
 
+	if (of_property_read_bool(client->dev.of_node,
+				  "arm-sbmr,skip-bootprogress-response"))
+		ssif_bmc->skip_bootprogress_resp = true;
+
 	spin_lock_init(&ssif_bmc->lock);
 
 	init_waitqueue_head(&ssif_bmc->wait_queue);
-- 
2.31.1


  parent reply	other threads:[~2024-06-12  4:35 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  4:32 [PATCH 0/2] ipmi: ssif_bmc: add support of skipping ARM SBMR boot progress response Potin Lai
2024-06-12  4:32 ` [PATCH 1/2] bindings: ipmi: Add property for skipping " Potin Lai
2024-06-13 17:59   ` Rob Herring
2024-06-13 18:55     ` Corey Minyard
2024-06-12  4:32 ` Potin Lai [this message]
2024-06-14  2:29   ` [PATCH 2/2] ipmi: ssif_bmc: support skipping ARM SBMR bootprogress response Quan Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240612043255.1849007-3-potin.lai.pt@gmail.com \
    --to=potin.lai.pt@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=cosmo.chou@quantatw.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minyard@acm.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    --cc=patrick@stwcx.xyz \
    --cc=potin.lai@quantatw.com \
    --cc=quan@os.amperecomputing.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox