Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jul 2010 15:48:29 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r210298 - in head/sys: arm/mv dev/acpica kern x86/isa x86/x86
Message-ID:  <201007201548.o6KFmTLO037962@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Tue Jul 20 15:48:29 2010
New Revision: 210298
URL: http://svn.freebsd.org/changeset/base/210298

Log:
  Fix several un-/signedness bugs of r210290 and r210293. Add one more check.

Modified:
  head/sys/arm/mv/timer.c
  head/sys/dev/acpica/acpi_hpet.c
  head/sys/kern/kern_clocksource.c
  head/sys/x86/isa/atrtc.c
  head/sys/x86/isa/clock.c
  head/sys/x86/x86/local_apic.c

Modified: head/sys/arm/mv/timer.c
==============================================================================
--- head/sys/arm/mv/timer.c	Tue Jul 20 15:34:27 2010	(r210297)
+++ head/sys/arm/mv/timer.c	Tue Jul 20 15:48:29 2010	(r210298)
@@ -158,10 +158,10 @@ mv_timer_attach(device_t dev)
 	sc->et.et_frequency = get_tclk();
 	sc->et.et_min_period.sec = 0;
 	sc->et.et_min_period.frac =
-	    ((0xfLL << 60) / sc->et.et_frequency) << 4;
-	sc->et.et_max_period.sec = 0xfffffff0 / sc->et.et_frequency;
+	    ((0x00000002LLU << 32) / sc->et.et_frequency) << 32;
+	sc->et.et_max_period.sec = 0xfffffff0U / sc->et.et_frequency;
 	sc->et.et_max_period.frac =
-	    ((0xfffffff0LL << 32) / sc->et.et_frequency) << 32;
+	    ((0xfffffffeLLU << 32) / sc->et.et_frequency) << 32;
 	sc->et.et_start = mv_timer_start;
 	sc->et.et_stop = mv_timer_stop;
 	sc->et.et_priv = sc;

Modified: head/sys/dev/acpica/acpi_hpet.c
==============================================================================
--- head/sys/dev/acpica/acpi_hpet.c	Tue Jul 20 15:34:27 2010	(r210297)
+++ head/sys/dev/acpica/acpi_hpet.c	Tue Jul 20 15:48:29 2010	(r210298)
@@ -585,10 +585,10 @@ hpet_attach(device_t dev)
 			t->et.et_quality -= 10;
 		t->et.et_frequency = sc->freq;
 		t->et.et_min_period.sec = 0;
-		t->et.et_min_period.frac = 0x00004000LL << 32;
-		t->et.et_max_period.sec = 0xffffffff / sc->freq;
+		t->et.et_min_period.frac = 0x00004000LLU << 32;
+		t->et.et_max_period.sec = 0xfffffffeLLU / sc->freq;
 		t->et.et_max_period.frac =
-		    ((0xffffffffLL << 32) / sc->freq) << 32;
+		    ((0xfffffffeLLU << 32) / sc->freq) << 32;
 		t->et.et_start = hpet_start;
 		t->et.et_stop = hpet_stop;
 		t->et.et_priv = &sc->t[i];

Modified: head/sys/kern/kern_clocksource.c
==============================================================================
--- head/sys/kern/kern_clocksource.c	Tue Jul 20 15:34:27 2010	(r210297)
+++ head/sys/kern/kern_clocksource.c	Tue Jul 20 15:48:29 2010	(r210298)
@@ -299,14 +299,14 @@ round_freq(struct eventtimer *et, int fr
 	uint64_t div;
 
 	if (et->et_frequency != 0) {
-		div = (et->et_frequency + freq / 2) / freq;
+		div = lmax((et->et_frequency + freq / 2) / freq, 1);
 		if (et->et_flags & ET_FLAGS_POW2DIV)
 			div = 1 << (flsl(div + div / 2) - 1);
 		freq = (et->et_frequency + div / 2) / div;
 	}
 	if (et->et_min_period.sec > 0)
 		freq = 0;
-	else if (et->et_max_period.frac != 0)
+	else if (et->et_min_period.frac != 0)
 		freq = min(freq, BT2FREQ(&et->et_min_period));
 	if (et->et_max_period.sec == 0 && et->et_max_period.frac != 0)
 		freq = max(freq, BT2FREQ(&et->et_max_period));
@@ -365,6 +365,7 @@ cpu_initclocks_bsp(void)
 		stathz = round_freq(timer[1], 127);
 		profhz = round_freq(timer[1], stathz * 64);
 	}
+	tick = 1000000 / hz;
 	ET_LOCK();
 	cpu_restartclocks();
 	ET_UNLOCK();

Modified: head/sys/x86/isa/atrtc.c
==============================================================================
--- head/sys/x86/isa/atrtc.c	Tue Jul 20 15:34:27 2010	(r210297)
+++ head/sys/x86/isa/atrtc.c	Tue Jul 20 15:48:29 2010	(r210298)
@@ -280,9 +280,9 @@ atrtc_attach(device_t dev)
 		sc->et.et_quality = 0;
 		sc->et.et_frequency = 32768;
 		sc->et.et_min_period.sec = 0;
-		sc->et.et_min_period.frac = 0x0008LL << 48;
+		sc->et.et_min_period.frac = 0x0008LLU << 48;
 		sc->et.et_max_period.sec = 0;
-		sc->et.et_max_period.frac = 0x8000LL << 48;
+		sc->et.et_max_period.frac = 0x8000LLU << 48;
 		sc->et.et_start = rtc_start;
 		sc->et.et_stop = rtc_stop;
 		sc->et.et_priv = dev;

Modified: head/sys/x86/isa/clock.c
==============================================================================
--- head/sys/x86/isa/clock.c	Tue Jul 20 15:34:27 2010	(r210297)
+++ head/sys/x86/isa/clock.c	Tue Jul 20 15:48:29 2010	(r210298)
@@ -666,10 +666,11 @@ attimer_attach(device_t dev)
 		sc->et.et_quality = 100;
 		sc->et.et_frequency = i8254_freq;
 		sc->et.et_min_period.sec = 0;
-		sc->et.et_min_period.frac = ((1LL << 62) / i8254_freq) << 2;
+		sc->et.et_min_period.frac =
+		    ((0x0002LLU << 48) / i8254_freq) << 16;
 		sc->et.et_max_period.sec = 0xffff / i8254_freq;
 		sc->et.et_max_period.frac =
-		    ((0xffffLL << 48) / i8254_freq) << 16;
+		    ((0xfffeLLU << 48) / i8254_freq) << 16;
 		sc->et.et_start = attimer_start;
 		sc->et.et_stop = attimer_stop;
 		sc->et.et_priv = dev;

Modified: head/sys/x86/x86/local_apic.c
==============================================================================
--- head/sys/x86/x86/local_apic.c	Tue Jul 20 15:34:27 2010	(r210297)
+++ head/sys/x86/x86/local_apic.c	Tue Jul 20 15:48:29 2010	(r210298)
@@ -500,10 +500,10 @@ lapic_et_start(struct eventtimer *et,
 		et->et_frequency = value;
 		et->et_min_period.sec = 0;
 		et->et_min_period.frac =
-		    ((1LL << 63) / et->et_frequency) << 1;
-		et->et_max_period.sec = 0xffffffff / et->et_frequency;
+		    ((0x00000002LLU << 32) / et->et_frequency) << 32;
+		et->et_max_period.sec = 0xfffffffeLLU / et->et_frequency;
 		et->et_max_period.frac =
-		    ((0xffffffffLL << 32) / et->et_frequency) << 32;
+		    ((0xfffffffeLLU << 32) / et->et_frequency) << 32;
 	}
 	la = &lapics[lapic_id()];
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007201548.o6KFmTLO037962>