From f23d6c626bd657e967347bda872242427b0d9221 Mon Sep 17 00:00:00 2001 From: Stewart Smith Date: Tue, 19 Dec 2017 00:11:56 -0600 Subject: libflash/mbox-flash: fallback to requesting lower MBOX versions from BMC 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 --- libflash/mbox-flash.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libflash') diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c index d33a52c..4a3c53f 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; } -- cgit v1.1