summaryrefslogtreecommitdiff
path: root/common/mkbp_event.c
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-03-20 07:29:22 -0600
committerchrome-bot <chrome-bot@chromium.org>2019-03-26 04:43:27 -0700
commit7c91b658c6c0c1ef9a08f2409190bbda0c2a0140 (patch)
tree5d2557ff24e69ffd051ffa9196007e15a1132b77 /common/mkbp_event.c
parent45bb97a58126aa943412c343bc4847e972d3b707 (diff)
downloadchrome-ec-7c91b658c6c0c1ef9a08f2409190bbda0c2a0140.tar.gz
mkbp: non-gpio-based mkbp events, leave interrupts
For non-gpio-based mkbp event delivery, we do not want to temporarily disable interrupts as the code to send the mkbp events may use mutexes or task scheduling to perform the more complicated mkbp event delivery. For simple GPIO-based implementations, pausing interrupts gives the mkbp_last_event_time marker the best chance at matching the actual time the gpio was toggled on the EC. For other implementation, we are already at the mercy of bus delays and timing for delivery so it wasn't as reliable in that case to beginning with. BRANCH=none BUG=b:128862307 TEST=Ran AIDA64 sensor tab for a long time without seeing ISH communication issue. Change-Id: Id6e63a7f7b494559bd38b4659a580fa57666ecf1 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1531773 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Mathew King <mathewk@chromium.org>
Diffstat (limited to 'common/mkbp_event.c')
-rw-r--r--common/mkbp_event.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index fc70035a10..5807d6ba80 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -35,14 +35,14 @@ static int event_is_set(uint8_t event_type)
}
#ifdef CONFIG_MKBP_USE_GPIO
-void mkbp_set_host_active_via_gpio(int active)
+static void mkbp_set_host_active_via_gpio(int active)
{
gpio_set_level(GPIO_EC_INT_L, !active);
}
#endif
#ifdef CONFIG_MKBP_USE_HOST_EVENT
-void mkbp_set_host_active_via_event(int active)
+static void mkbp_set_host_active_via_event(int active)
{
if (active)
host_set_single_event(EC_HOST_EVENT_MKBP);
@@ -50,14 +50,20 @@ void mkbp_set_host_active_via_event(int active)
#endif
#ifdef CONFIG_MKBP_USE_HECI
-void mkbp_set_host_active_via_heci(int active)
+static void mkbp_set_host_active_via_heci(int active)
{
if (active)
heci_send_mkbp_event();
}
#endif
-void mkbp_set_host_active(int active)
+/*
+ * This communicates to the AP whether an MKBP event is currently available
+ * for processing.
+ *
+ * @param active 1 if there is an event, 0 otherwise
+ */
+static void mkbp_set_host_active(int active)
{
#if defined(CONFIG_MKBP_USE_CUSTOM)
mkbp_set_host_active_via_custom(active);
@@ -76,8 +82,18 @@ void mkbp_set_host_active(int active)
static void set_host_interrupt(int active)
{
static int old_active;
-
+ /*
+ * If we are going to perform a simple GPIO toggle, then pause
+ * interrupts to let last_event_time marker have the best chance of
+ * matching the time we toggle the GPIO pin.
+ *
+ * If we are passing mkbp events through host communication, then
+ * pausing interrupts can have unintended consequences (say if that code
+ * waits for a mutex and then de-schedules its tasks).
+ */
+#ifdef CONFIG_MKBP_USE_GPIO
interrupt_disable();
+#endif
if (old_active == 0 && active == 1)
mkbp_last_event_time = __hw_clock_source_read();
@@ -85,7 +101,10 @@ static void set_host_interrupt(int active)
mkbp_set_host_active(active);
old_active = active;
+
+#ifdef CONFIG_MKBP_USE_GPIO
interrupt_enable();
+#endif
}
#ifdef CONFIG_MKBP_WAKEUP_MASK