Module Name:    src
Committed By:   jmcneill
Date:           Tue Oct 30 10:38:11 UTC 2018

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

Log Message:
Disable diagnostic assertions around timer jitter on Allwinner A64. It
seems the instability of CNTVCT can cause issues with the compare value,
and rather than applying a heavy workaround just skip the panics.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/sys/arch/arm/cortex/gtmr.c:1.37
--- src/sys/arch/arm/cortex/gtmr.c:1.36	Sun Sep 30 10:34:38 2018
+++ src/sys/arch/arm/cortex/gtmr.c	Tue Oct 30 10:38:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: gtmr.c,v 1.36 2018/09/30 10:34:38 skrll Exp $	*/
+/*	$NetBSD: gtmr.c,v 1.37 2018/10/30 10:38:11 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.36 2018/09/30 10:34:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.37 2018/10/30 10:38:11 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -272,11 +272,14 @@ gtmr_intr(void *arg)
 	uint64_t delta = now - ci->ci_lastintr;
 
 #ifdef DIAGNOSTIC
-	const uint64_t then = gtmr_cntv_cval_read();
-	struct gtmr_percpu * const pc = percpu_getref(sc->sc_percpu);
-	KASSERTMSG(then <= now, "%"PRId64, now - then);
-	KASSERTMSG(then + pc->pc_delta >= ci->ci_lastintr + sc->sc_autoinc,
-	    "%"PRId64, then + pc->pc_delta - ci->ci_lastintr - sc->sc_autoinc);
+	struct gtmr_percpu *pc = NULL;
+	if (!ISSET(sc->sc_flags, GTMR_FLAG_SUN50I_A64_UNSTABLE_TIMER)) {
+		const uint64_t then = gtmr_cntv_cval_read();
+		pc = percpu_getref(sc->sc_percpu);
+		KASSERTMSG(then <= now, "%"PRId64, now - then);
+		KASSERTMSG(then + pc->pc_delta >= ci->ci_lastintr + sc->sc_autoinc,
+		    "%"PRId64, then + pc->pc_delta - ci->ci_lastintr - sc->sc_autoinc);
+	}
 #endif
 
 	KASSERTMSG(delta > sc->sc_autoinc / 100,
@@ -298,9 +301,11 @@ gtmr_intr(void *arg)
 	ci->ci_lastintr = now;
 
 #ifdef DIAGNOSTIC
-	KASSERT(delta == (uint32_t) delta);
-	pc->pc_delta = delta;
-	percpu_putref(sc->sc_percpu);
+	if (!ISSET(sc->sc_flags, GTMR_FLAG_SUN50I_A64_UNSTABLE_TIMER)) {
+		KASSERT(delta == (uint32_t) delta);
+		pc->pc_delta = delta;
+		percpu_putref(sc->sc_percpu);
+	}
 #endif
 
 	hardclock(cf);

Reply via email to