summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-07-29 17:17:32 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-30 03:54:37 +0000
commit1691a707af5cc3dbd3e4353cf2d0773ef931b178 (patch)
treebf68f9187ff997d0ce253cf7841892743739eee2
parent73e3bc14c69b52207b0bd170f5fd1fa7d9c6bc9e (diff)
downloadchrome-ec-1691a707af5cc3dbd3e4353cf2d0773ef931b178.tar.gz
stm: rtc: Prevent locking a mutex in interrupt context
In the RTC interrupt, it calls host_set_single_event() directly, that eventually tries to lock a mutex. Trying to lock a mutex in the interrupt context should be forbidden. So move the call to a deferred function. BRANCH=None BUG=b:162434716 TEST=Build the board scarlet, which uses stm and enables RTC host command. Change-Id: I3f5ab85549a801f4f5d72cf5661a65c9f9d28e0c Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2327249 Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
-rw-r--r--chip/stm32/clock-f.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/chip/stm32/clock-f.c b/chip/stm32/clock-f.c
index f65716aa9e..0be765476d 100644
--- a/chip/stm32/clock-f.c
+++ b/chip/stm32/clock-f.c
@@ -313,6 +313,14 @@ void reset_rtc_alarm(struct rtc_time_reg *rtc)
rtc_lock_regs();
}
+#ifdef CONFIG_HOSTCMD_RTC
+static void set_rtc_host_event(void)
+{
+ host_set_single_event(EC_HOST_EVENT_RTC);
+}
+DECLARE_DEFERRED(set_rtc_host_event);
+#endif
+
test_mockable_static
void __rtc_alarm_irq(void)
{
@@ -323,7 +331,7 @@ void __rtc_alarm_irq(void)
/* Wake up the host if there is a saved rtc wake alarm. */
if (host_wake_time.ts.val) {
host_wake_time.ts.val = 0;
- host_set_single_event(EC_HOST_EVENT_RTC);
+ hook_call_deferred(&set_rtc_host_event_data, 0);
}
#endif
}