diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/bt.c | 11 | ||||
-rw-r--r-- | hw/lpc-uart.c | 4 | ||||
-rw-r--r-- | hw/lpc.c | 12 | ||||
-rw-r--r-- | hw/xscom.c | 5 |
4 files changed, 30 insertions, 2 deletions
@@ -350,7 +350,8 @@ static void print_debug_queue_info(void) {} static void bt_send_and_unlock(void) { - if (bt.state == BT_STATE_IDLE && !list_empty(&bt.msgq)) + if (lpc_ok() && + bt.state == BT_STATE_IDLE && !list_empty(&bt.msgq)) bt_send_msg(); unlock(&bt.lock); @@ -361,6 +362,10 @@ static void bt_poll(struct timer *t __unused, void *data __unused) { uint8_t bt_ctrl; + /* Don't do anything if the LPC bus is offline */ + if (!lpc_ok()) + return; + /* If we can't get the lock assume someone else will notice * the new message and process it. */ lock(&bt.lock); @@ -440,7 +445,9 @@ static int bt_add_ipmi_msg(struct ipmi_msg *ipmi_msg) void bt_irq(void) { - uint8_t ireg = bt_inb(BT_INTMASK); + uint8_t ireg; + + ireg = bt_inb(BT_INTMASK); bt.irq_ok = true; if (ireg & BT_INTMASK_B2H_IRQ) { diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index 2e6114a..7c3190e 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -135,6 +135,10 @@ static size_t uart_con_write(const char *buf, size_t len) { size_t written = 0; + /* If LPC bus is bad, we just swallow data */ + if (!lpc_ok()) + return written; + lock(&uart_lock); while(written < len) { if (tx_room == 0) { @@ -500,3 +500,15 @@ void lpc_used_by_console(void) unlock(&chip->lpc_lock); } } + +bool lpc_ok(void) +{ + struct proc_chip *chip; + + if (lpc_default_chip_id < 0) + return false; + if (!xscom_ok()) + return false; + chip = get_chip(lpc_default_chip_id); + return !lock_held_by_me(&chip->lpc_lock); +} @@ -527,3 +527,8 @@ void xscom_used_by_console(void) lock(&xscom_lock); unlock(&xscom_lock); } + +bool xscom_ok(void) +{ + return !lock_held_by_me(&xscom_lock); +} |