aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-12-05 12:01:05 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-12-14 23:58:38 -0600
commitf47de2b05f9dcda78df6b8717956fa8f23bcc22f (patch)
tree3f6682d1516b861011ec26831586af51ec1fa322
parent3e6c3b03bb4cc5d088fc3da7293274adaabf6c5c (diff)
downloadskiboot-f47de2b05f9dcda78df6b8717956fa8f23bcc22f.zip
skiboot-f47de2b05f9dcda78df6b8717956fa8f23bcc22f.tar.gz
skiboot-f47de2b05f9dcda78df6b8717956fa8f23bcc22f.tar.bz2
libflash/mbox-flash: Move sequence handling to driver level
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--hw/lpc-mbox.c9
-rw-r--r--libflash/mbox-flash.c10
2 files changed, 9 insertions, 10 deletions
diff --git a/hw/lpc-mbox.c b/hw/lpc-mbox.c
index 7a57f1e..7421493 100644
--- a/hw/lpc-mbox.c
+++ b/hw/lpc-mbox.c
@@ -63,6 +63,7 @@ struct mbox {
void *attn_data;
struct lock lock; /* Protect in_flight */
struct bmc_mbox_msg *in_flight;
+ uint8_t sequence;
};
static struct mbox mbox;
@@ -130,6 +131,7 @@ int bmc_mbox_enqueue(struct bmc_mbox_msg *msg)
mbox.in_flight = msg;
unlock(&mbox.lock);
+ msg->seq = ++mbox.sequence;
bmc_mbox_send_message(msg);
@@ -162,7 +164,13 @@ static void mbox_poll(struct timer *t __unused, void *data __unused,
prlog(PR_CRIT, "Couldn't find the message!!\n");
goto out_response;
}
+
bmc_mbox_recv_message(msg);
+ if (mbox.sequence != msg->seq) {
+ prlog(PR_ERR, "Got a response to a message we no longer care about\n");
+ goto out_response;
+ }
+
if (mbox.callback)
mbox.callback(msg, mbox.drv_data);
else
@@ -330,6 +338,7 @@ void mbox_init(void)
mbox.in_flight = NULL;
mbox.callback = NULL;
mbox.drv_data = NULL;
+ mbox.sequence = 0;
init_lock(&mbox.lock);
init_timer(&mbox.poller, mbox_poll, NULL);
diff --git a/libflash/mbox-flash.c b/libflash/mbox-flash.c
index c8a8dad..3615df7 100644
--- a/libflash/mbox-flash.c
+++ b/libflash/mbox-flash.c
@@ -59,7 +59,6 @@ struct mbox_flash_data {
bool pause;
bool busy;
bool ack;
- uint8_t seq;
/* Plus one, commands start at 1 */
void (*handlers[MBOX_COMMAND_COUNT + 1])(struct mbox_flash_data *, struct bmc_mbox_msg*);
struct bmc_mbox_msg msg_mem;
@@ -199,7 +198,6 @@ static struct bmc_mbox_msg *msg_alloc(struct mbox_flash_data *mbox_flash,
* really the performance optimisation you want to make.
*/
memset(&mbox_flash->msg_mem, 0, sizeof(mbox_flash->msg_mem));
- mbox_flash->msg_mem.seq = ++mbox_flash->seq;
mbox_flash->msg_mem.command = command;
return &mbox_flash->msg_mem;
}
@@ -900,14 +898,6 @@ static void mbox_flash_callback(struct bmc_mbox_msg *msg, void *priv)
goto out;
}
- if (msg->seq != mbox_flash->seq) {
- /* Uhoh */
- prlog(PR_ERR, "Sequence numbers don't match! Got: %02x Expected: %02x\n",
- msg->seq, mbox_flash->seq);
- mbox_flash->rc = MBOX_R_SYSTEM_ERROR;
- goto out;
- }
-
if (msg->command > MBOX_COMMAND_COUNT) {
prlog(PR_ERR, "Got response to unknown command %02x\n", msg->command);
mbox_flash->rc = -1;