diff mbox series

libflash/mbox-flash: fallback to requesting lower MBOX versions from BMC

Message ID 20171219061453.19941-1-stewart@linux.vnet.ibm.com
State Accepted
Headers show
Series libflash/mbox-flash: fallback to requesting lower MBOX versions from BMC | expand

Commit Message

Stewart Smith Dec. 19, 2017, 6:14 a.m. UTC
Some BMC mbox implementations seem to sometimes mysteriously fail when trying
to negotiate v3 when they only support v2. To work around this, we
can fall back to requesting lower mbox protocol versions until we find
one that works.

In theory, this should already "just work", but we have a counter example,
which this patch fixes.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 libflash/mbox-flash.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Stewart Smith Dec. 19, 2017, 11:46 p.m. UTC | #1
Stewart Smith <stewart@linux.vnet.ibm.com> writes:
> Some BMC mbox implementations seem to sometimes mysteriously fail when trying
> to negotiate v3 when they only support v2. To work around this, we
> can fall back to requesting lower mbox protocol versions until we find
> one that works.
>
> In theory, this should already "just work", but we have a counter example,
> which this patch fixes.
>
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
> ---
>  libflash/mbox-flash.c | 7 +++++++
>  1 file changed, 7 insertions(+)

merged to master as of f23d6c626bd657e967347bda872242427b0d9221
diff mbox series

Patch

diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index d33a52c0ebf0..4a3c53f5957f 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -1018,6 +1018,7 @@  static int protocol_init(struct mbox_flash_data *mbox_flash, uint8_t shift)
 	 */
 	mbox_flash->version = 3;
 
+negotiate_version:
 	msg_put_u8(&msg, 0, mbox_flash->version);
 	msg_put_u8(&msg, 1, shift);
 	rc = msg_send(mbox_flash, &msg, mbox_flash->timeout);
@@ -1029,6 +1030,12 @@  static int protocol_init(struct mbox_flash_data *mbox_flash, uint8_t shift)
 	rc = wait_for_bmc(mbox_flash, mbox_flash->timeout);
 	if (rc) {
 		prlog(PR_ERR, "Error waiting for BMC\n");
+		if (mbox_flash->version > 1) {
+			mbox_flash->version--;
+			prlog(PR_INFO, "Retrying MBOX negotiation with BMC"
+			      " with MBOXv%d\n", mbox_flash->version);
+			goto negotiate_version;
+		}
 		return rc;
 	}