diff mbox

[v2,02/11] libflash/mbox-flash: Always close windows before opening a new window

Message ID 20170803071808.7256-3-cyril.bur@au1.ibm.com
State Changes Requested
Headers show

Commit Message

Cyril Bur Aug. 3, 2017, 7:17 a.m. UTC
The MBOX protocol states that if an open window command fails then all
open windows are closed. Currently, if an open window command fails
mbox-flash will erroneously assume that the previously open window is
still open.

The solution to this is to mark all windows as closed before issuing an
open window command and then on success we'll mark the new window as
open.

Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
---
 libflash/mbox-flash.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox

Patch

diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index 7491d3b1..f9332415 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -617,6 +617,9 @@  static int mbox_window_move(struct mbox_flash_data *mbox_flash,
 		goto out;
 	}
 
+	mbox_flash->read.open = false;
+	mbox_flash->write.open = false;
+
 	rc = wait_for_bmc(mbox_flash, MBOX_DEFAULT_TIMEOUT);
 	if (rc) {
 		prlog(PR_ERR, "Error waiting for BMC\n");