summaryrefslogtreecommitdiff
path: root/common/acpi.c
diff options
context:
space:
mode:
authorChiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>2015-06-18 23:47:43 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-25 17:21:50 +0000
commitddf77bbe785a5ae1c701ef70fb6e41a89168e341 (patch)
tree9b47d735af60c1a5a34224189885f72666539184 /common/acpi.c
parent331db691c418e607b9830ba96e6ca1b634c7cea4 (diff)
downloadchrome-ec-ddf77bbe785a5ae1c701ef70fb6e41a89168e341.tar.gz
Fix assertion crash in __wait_evt()
mutex_lock() is called from MEC1322_IRQ_ACPIEC0_IBF interrupt context, causing deadlock and assertion in __wait_evt(). In the interrupt context it now checks for mutex lock first. If the mutex is already locked,, it will disable ACPI interrupts and defer the memmap mutex lock. Added LPC interrupt disable/enable functions as needed. Increased deferred function count where needed. BRANCH=None BUG=chrome-os-partner:40820 TEST=Test for suspend-resume, cold, warm reboots and other general stability. Change-Id: I3dda0d4635a6b6281faf200c8c7b6fcba8877254 Signed-off-by: Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com> Reviewed-on: https://chromium-review.googlesource.com/280418 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org> Commit-Queue: Divya Jyothi <divya.jyothi@intel.com> Tested-by: Divya Jyothi <divya.jyothi@intel.com>
Diffstat (limited to 'common/acpi.c')
-rw-r--r--common/acpi.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/common/acpi.c b/common/acpi.c
index 425f7e2337..b5cb763c40 100644
--- a/common/acpi.c
+++ b/common/acpi.c
@@ -42,6 +42,17 @@ static void acpi_unlock_memmap_deferred(void)
DECLARE_DEFERRED(acpi_unlock_memmap_deferred);
/*
+ * Deferred function to lock memmap and to enable LPC interrupts.
+ * This is due to LPC interrupt was unable to acquire memmap mutex.
+ */
+static void deferred_host_lock_memmap(void)
+{
+ host_lock_memmap();
+ lpc_enable_acpi_interrupts();
+}
+DECLARE_DEFERRED(deferred_host_lock_memmap);
+
+/*
* This handles AP writes to the EC via the ACPI I/O port. There are only a few
* ACPI commands (EC_CMD_ACPI_*), but they are all handled here.
*/
@@ -180,8 +191,29 @@ int acpi_ap_to_ec(int is_cmd, uint8_t value, uint8_t *resultptr)
*resultptr = evt_index;
retval = 1;
} else if (acpi_cmd == EC_CMD_ACPI_BURST_ENABLE && !acpi_data_count) {
+ /*
+ * TODO: The kernel only enables BURST when doing multi-byte
+ * value reads over the ACPI port. We don't do such reads
+ * when our memmap data can be accessed directly over LPC,
+ * so on LM4, for example, this is dead code. We might want
+ * to re-add the CONFIG, now that we have overhead of one
+ * deferred function.
+ */
+ if (host_memmap_is_locked()) {
+ /*
+ * If already locked by a task, we can not acquire
+ * the mutex and will have to wait in the interrupt
+ * context. But then the task will not get chance to
+ * release the mutex. This will create deadlock
+ * situation. To avoid the deadlock, disable ACPI
+ * interrupts and defer locking.
+ */
+ lpc_disable_acpi_interrupts();
+ hook_call_deferred(deferred_host_lock_memmap, 0);
+ } else {
+ host_lock_memmap();
+ }
/* Enter burst mode */
- host_lock_memmap();
lpc_set_acpi_status_mask(EC_LPC_STATUS_BURST_MODE);
/*