aboutsummaryrefslogtreecommitdiff
path: root/hw/lpc-mbox.c
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-12-05 12:01:06 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-12-14 23:58:38 -0600
commitc3fc675285bc9542262e23c7330581eaf5a24de1 (patch)
treee86e118190767c4187bf5eef778c63d40419c752 /hw/lpc-mbox.c
parentf47de2b05f9dcda78df6b8717956fa8f23bcc22f (diff)
downloadskiboot-c3fc675285bc9542262e23c7330581eaf5a24de1.zip
skiboot-c3fc675285bc9542262e23c7330581eaf5a24de1.tar.gz
skiboot-c3fc675285bc9542262e23c7330581eaf5a24de1.tar.bz2
libflash/mbox-flash: Allow mbox-flash to tell the driver msg timeouts
Currently when mbox-flash decides that a message times out the driver has no way of knowing to drop the message and will continue waiting for a response indefinitely preventing more messages from ever being sent. This is a problem if the BMC crashes or has some other issue where it won't ever respond to our outstanding message. This patch provides a method for mbox-flash to tell the driver how long it should wait before it no longer needs to care about the response. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/lpc-mbox.c')
-rw-r--r--hw/lpc-mbox.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/hw/lpc-mbox.c b/hw/lpc-mbox.c
index 7421493..f303f4d 100644
--- a/hw/lpc-mbox.c
+++ b/hw/lpc-mbox.c
@@ -64,6 +64,7 @@ struct mbox {
struct lock lock; /* Protect in_flight */
struct bmc_mbox_msg *in_flight;
uint8_t sequence;
+ unsigned long timeout;
};
static struct mbox mbox;
@@ -115,7 +116,7 @@ static void bmc_mbox_send_message(struct bmc_mbox_msg *msg)
bmc_mbox_outb(MBOX_CTRL_INT_SEND, MBOX_HOST_CTRL);
}
-int bmc_mbox_enqueue(struct bmc_mbox_msg *msg)
+int bmc_mbox_enqueue(struct bmc_mbox_msg *msg, unsigned int timeout_sec)
{
if (!mbox.base) {
prlog(PR_CRIT, "Using MBOX without init!\n");
@@ -125,10 +126,15 @@ int bmc_mbox_enqueue(struct bmc_mbox_msg *msg)
lock(&mbox.lock);
if (mbox.in_flight) {
prlog(PR_DEBUG, "MBOX message already in flight\n");
- unlock(&mbox.lock);
- return OPAL_BUSY;
+ if (mftb() > mbox.timeout) {
+ prlog(PR_ERR, "In flight message dropped on the floor\n");
+ } else {
+ unlock(&mbox.lock);
+ return OPAL_BUSY;
+ }
}
+ mbox.timeout = mftb() + secs_to_tb(timeout_sec);
mbox.in_flight = msg;
unlock(&mbox.lock);
msg->seq = ++mbox.sequence;