# \[PATCH\] ipmi/powernv: Fix spurious warnings at boot

- Subsystems: IPMI SUBSYSTEM, THE REST
- Maintainers: Corey Minyard, Linus Torvalds
- List: linuxppc-dev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linuxppc-dev/2018/06/9504691/t

## \[PATCH\] ipmi/powernv: Fix spurious warnings at boot

- From: William A. Kennington III \<hidden\>
- Date: 2018-06-15 18:33:44 
- Message: https://ratatoskr.run/linuxppc-dev/2018/06/9504691.md

```text
Sometimes we have stale messages showing up in the recv queue that are
being processed by the pollers. We don't want to print out warnings for
these messages not having an outstanding request as they can be expected
when doing a kexec from the petitroot environment or from another
running kernel.

Signed-off-by: William A. Kennington III <redacted>
---
 drivers/char/ipmi/ipmi_powernv.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
index e96500372ce20..36b07f26cebd9 100644
--- a/drivers/char/ipmi/ipmi_powernv.c
+++ b/drivers/char/ipmi/ipmi_powernv.c
@@ -31,6 +31,12 @@ struct ipmi_smi_powernv {
 	spinlock_t		msg_lock;
 	struct ipmi_smi_msg	*cur_msg;
 	struct opal_ipmi_msg	*opal_msg;
+
+	/**
+	 * Marker denoting if we should be draining the ipmi queue of any
+	 * outstanding messages
+	 */
+	bool			in_drain;
 };
 
 static int ipmi_powernv_start_processing(void *send_info, ipmi_smi_t intf)
@@ -96,6 +102,7 @@ static void ipmi_powernv_send(void *send_info, struct ipmi_smi_msg *msg)
 
 	if (!rc) {
 		smi->cur_msg = msg;
+		smi->in_drain = false;
 		spin_unlock_irqrestore(&smi->msg_lock, flags);
 		return;
 	}
@@ -121,8 +128,14 @@ static int ipmi_powernv_recv(struct ipmi_smi_powernv *smi)
 	spin_lock_irqsave(&smi->msg_lock, flags);
 
 	if (!smi->cur_msg) {
+		bool in_drain = READ_ONCE(smi->in_drain);
 		spin_unlock_irqrestore(&smi->msg_lock, flags);
-		pr_warn("no current message?\n");
+		/**
+		 * We don't want to print spurious errors if we are draining
+		 * leftover messages prior to sending our first message.
+		 */
+		if (!in_drain)
+			pr_warn("no current message?\n");
 		return 0;
 	}
 
@@ -226,6 +239,11 @@ static int ipmi_powernv_probe(struct platform_device *pdev)
 
 	spin_lock_init(&ipmi->msg_lock);
 
+	/* Our channel may have stale messages from a previous kernel
+	 * let the recv code know we haven't actually sent anything yet
+	 */
+	ipmi->in_drain = true;
+
 	rc = of_property_read_u32(dev->of_node, "ibm,ipmi-interface-id",
 			&prop);
 	if (rc) {
-- 
2.18.0.rc1.244.gcf134e6275-goog
```

## Re: \[PATCH\] ipmi/powernv: Fix spurious warnings at boot

- From: Jeremy Kerr \<jk@ozlabs.org\>
- Date: 2018-07-18 08:25:02 
- Message: https://ratatoskr.run/linuxppc-dev/2018/07/9505183.md

```text
Hi William,

> Sometimes we have stale messages showing up in the recv queue that are
> being processed by the pollers. We don't want to print out warnings for
> these messages not having an outstanding request as they can be expected
> when doing a kexec from the petitroot environment or from another
> running kernel.

OK, makes sense to do. The in_drain state partially shadows the value of
!smi->cur_msg; we may be able to use that instead.

This means that we'll no longer warn when getting an IPMI message after
the first successful send occurs, but do we really care about that
anyway? We could just drop those silently...

Cheers,


Jeremy
```
