summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2019-03-20 07:29:22 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-10 23:13:40 +0000
commit06c17e886958eeaf5afc0af4aa9bad691211879d (patch)
treed41e37b57f7030b119e618708695e788a4fe2602
parenta16638995b503e0444e403d350831b36a1941ef4 (diff)
downloadchrome-ec-06c17e886958eeaf5afc0af4aa9bad691211879d.tar.gz
BACKPORT: 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,b:139001152 TEST=Ran AIDA64 sensor tab for a long time without seeing ISH communication issue. cheets_CTS_P.9.0_r9.x86.CtsSensorTestCases passes on Rammus. Conflicts: common/mkbp_event.c : do not add HECI code. 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> (cherry picked from commit 7c91b658c6c0c1ef9a08f2409190bbda0c2a0140) Change-Id: Id6e63a7f7b494559bd38b4659a580fa57666ecf1 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1776838
-rw-r--r--common/mkbp_event.c27
-rw-r--r--include/mkbp_event.h29
2 files changed, 23 insertions, 33 deletions
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index b4b163121d..6530057c50 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -34,21 +34,27 @@ 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);
}
#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);
@@ -65,8 +71,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();
@@ -74,7 +90,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
diff --git a/include/mkbp_event.h b/include/mkbp_event.h
index c1f3a238dc..c451c53673 100644
--- a/include/mkbp_event.h
+++ b/include/mkbp_event.h
@@ -29,35 +29,6 @@ extern uint32_t mkbp_last_event_time;
int mkbp_send_event(uint8_t event_type);
/*
- * Set MKBP active event status on the AP.
- *
- * This communicates to the AP whether an MKBP event is currently available
- * for processing. It is used by mkbp_send_event().
- *
- * The default implementation in mkbp_event.c has weak linkage and can be
- * overridden by individual boards depending on their hardware configuration.
- *
- * @param active 1 if there is an event, 0 otherwise
- */
-void mkbp_set_host_active(int active);
-
-/*
- * Communicate an MKBP event to the host via a dedicated GPIO pin.
- *
- * This can be used if the board schematic has a pin reserved for this purpose.
- */
-void mkbp_set_host_active_via_gpio(int active);
-
-/*
- * Communicate an MKBP event to the AP via EC_HOST_EVENT.
- *
- * This can be used without a dedicated interrupt pin configured. It is the
- * default behavior of mkbp_set_host_active when CONFIG_MKBP_USE_HOST_EVENT
- * is defined in board.h.
- */
-void mkbp_set_host_active_via_event(int active);
-
-/*
* Communicate an MKBP event to the AP via custom method.
*
* This can be used if a board has a custom method.