Module Name:    src
Committed By:   matt
Date:           Wed Jun 11 05:50:46 UTC 2014

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

Log Message:
Add a KASSERT to make sure the counter is running.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 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.7 src/sys/arch/arm/cortex/gtmr.c:1.8
--- src/sys/arch/arm/cortex/gtmr.c:1.7	Sun Apr 13 02:22:21 2014
+++ src/sys/arch/arm/cortex/gtmr.c	Wed Jun 11 05:50:46 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: gtmr.c,v 1.7 2014/04/13 02:22:21 matt Exp $	*/
+/*	$NetBSD: gtmr.c,v 1.8 2014/06/11 05:50:46 matt Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.7 2014/04/13 02:22:21 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.8 2014/06/11 05:50:46 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -140,6 +140,11 @@ gtmr_attach(device_t parent, device_t se
 		    "cp15 CNT_FRQ (%u) differs from supplied frequency\n",
 		    cnt_frq);
 	}
+
+	gtmr_timecounter.tc_name = device_xname(sc->sc_dev);
+	gtmr_timecounter.tc_frequency = sc->sc_freq;
+
+	tc_init(&gtmr_timecounter);
 }
 
 void
@@ -150,10 +155,14 @@ gtmr_init_cpu_clock(struct cpu_info *ci)
 	KASSERT(ci == curcpu());
 
 	int s = splsched();
+
 	/*
 	 * enable timer and stop masking the timer.
 	 */
 	armreg_cntv_ctl_write(ARM_CNTCTL_ENABLE);
+#if 0
+	printf("%s: cntctl=%#x\n", __func__, armreg_cntv_ctl_read());
+#endif
 
 	/*
 	 * Get now and update the compare timer.
@@ -166,6 +175,7 @@ gtmr_init_cpu_clock(struct cpu_info *ci)
 	    armreg_cntv_cval_read() - ci->ci_lastintr);
 #endif
 	splx(s);
+	KASSERT(armreg_cntv_ct_read() != 0);
 #if 0
 	printf("%s: %s: ctl %#x cmp %#"PRIx64" now %#"PRIx64"\n",
 	    __func__, ci->ci_data.cpu_name, armreg_cntv_ctl_read(),
@@ -210,11 +220,6 @@ cpu_initclocks(void)
 	sc->sc_autoinc = sc->sc_freq / hz;
 
 	gtmr_init_cpu_clock(curcpu());
-
-	gtmr_timecounter.tc_name = device_xname(sc->sc_dev);
-	gtmr_timecounter.tc_frequency = sc->sc_freq;
-
-	tc_init(&gtmr_timecounter);
 }
 
 void

Reply via email to