svn commit: r210542 - head/sys/mips/rmi

Jayachandran C. jchandra at FreeBSD.org
Tue Jul 27 15:10:05 UTC 2010


Author: jchandra
Date: Tue Jul 27 15:10:05 2010
New Revision: 210542
URL: http://svn.freebsd.org/changeset/base/210542

Log:
  The count/compare values have to be tracked per CPU.
  
  Reviewed by:	mav

Modified:
  head/sys/mips/rmi/tick.c

Modified: head/sys/mips/rmi/tick.c
==============================================================================
--- head/sys/mips/rmi/tick.c	Tue Jul 27 14:35:17 2010	(r210541)
+++ head/sys/mips/rmi/tick.c	Tue Jul 27 15:10:05 2010	(r210542)
@@ -62,9 +62,8 @@ struct timecounter *platform_timecounter
 static DPCPU_DEFINE(uint32_t, cycles_per_tick);
 static uint32_t cycles_per_usec;
 
-static u_int32_t counter_upper = 0;
-static u_int32_t counter_lower_last = 0;
-
+static DPCPU_DEFINE(uint32_t, counter_upper);
+static DPCPU_DEFINE(uint32_t, counter_lower_last);
 static DPCPU_DEFINE(uint32_t, compare_ticks);
 static DPCPU_DEFINE(uint32_t, lost_ticks);
 
@@ -106,6 +105,7 @@ tick_ticker(void)
 {
 	uint64_t ret;
 	uint32_t ticktock;
+	uint32_t t_lower_last, t_upper;
 
 	/*
 	 * XXX: MIPS64 platforms can read 64-bits of counter directly.
@@ -115,12 +115,16 @@ tick_ticker(void)
 	 */
 	ticktock = mips_rd_count();
 	critical_enter();
-	if (ticktock < counter_lower_last)
-		counter_upper++;
-	counter_lower_last = ticktock;
+	t_lower_last = DPCPU_GET(counter_lower_last);
+	t_upper = DPCPU_GET(counter_upper);
+	if (ticktock < t_lower_last)
+		t_upper++;
+	t_lower_last = ticktock;
 	critical_exit();
 
-	ret = ((uint64_t) counter_upper << 32) | counter_lower_last;
+	DPCPU_SET(counter_upper, t_upper);
+	DPCPU_SET(counter_lower_last, t_lower_last);
+	ret = ((uint64_t)t_upper << 32) | t_lower_last;
 	return (ret);
 }
 
@@ -265,9 +269,9 @@ clock_intr(void *arg)
 		mips_wr_compare(0xffffffff);
 
 	critical_enter();
-	if (count < counter_lower_last) {
-		counter_upper++;
-		counter_lower_last = count;
+	if (count < DPCPU_GET(counter_lower_last)) {
+		DPCPU_SET(counter_upper, DPCPU_GET(counter_upper) + 1);
+		DPCPU_SET(counter_lower_last, count);
 	}
 
 	if (cycles_per_tick > 0) {


More information about the svn-src-head mailing list