From a653df93b2d22691ac1583584c8292e6e421464f Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 29 Apr 2015 15:01:52 +1000 Subject: Add xscom_ok() and lpc_ok() to check XSCOM and LPC usability his primarily checks whether the caller already holds the corresponding locks to avoid re-entrancy in some of the deep error path such as when XSCOM itself triggers an error log. It will be extended in the case of LPC to also handle known HW error states. We use them to avoid queuing/polling in the BT driver and to discard characters in the UART driver. Note: This will not normally involve a loss of log to the UART as the UART driver is also protected by the console suspend mechanism. So this is a safety mechanism only. This fixes issues where the generation of error logs inside the LPC or XSCOM drivers could cause a re-entrancy (via the BT interface) causing deadlocks. Now, the error logs IPMI messages will be queued up and delivered later on the next poll handler. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Stewart Smith --- hw/lpc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'hw/lpc.c') diff --git a/hw/lpc.c b/hw/lpc.c index 0db674f..b287020 100644 --- a/hw/lpc.c +++ b/hw/lpc.c @@ -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); +} -- cgit v1.1