Module Name:    src
Committed By:   jmcneill
Date:           Thu Sep  9 21:39:03 UTC 2021

Modified Files:
        src/sys/arch/arm/cortex: gtmr.c

Log Message:
If we get a spurious interrupt, log a debug message and ignore it.

Otherwise we risk tripping an assertion later on due to an interrupt
firing before it is scheduled.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/arm/cortex/gtmr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/cortex/gtmr.c
diff -u src/sys/arch/arm/cortex/gtmr.c:1.44 src/sys/arch/arm/cortex/gtmr.c:1.45
--- src/sys/arch/arm/cortex/gtmr.c:1.44	Mon Aug 30 22:53:37 2021
+++ src/sys/arch/arm/cortex/gtmr.c	Thu Sep  9 21:39:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gtmr.c,v 1.44 2021/08/30 22:53:37 jmcneill Exp $	*/
+/*	$NetBSD: gtmr.c,v 1.45 2021/09/09 21:39:02 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.44 2021/08/30 22:53:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.45 2021/09/09 21:39:02 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -334,6 +334,12 @@ gtmr_intr(void *arg)
 	struct clockframe * const cf = arg;
 	struct gtmr_softc * const sc = &gtmr_sc;
 
+	const uint32_t ctl = gtmr_read_ctl(sc);
+	if ((ctl & (CNTCTL_ENABLE|CNTCTL_ISTATUS)) != (CNTCTL_ENABLE|CNTCTL_ISTATUS)) {
+		aprint_debug_dev(ci->ci_dev, "spurious timer interrupt (ctl=%#x)\n", ctl);
+		return 0;
+	}
+
 	const uint64_t now = gtmr_read_cntct(sc);
 	uint64_t delta = now - ci->ci_lastintr;
 

Reply via email to