From owner-freebsd-current@FreeBSD.ORG Mon Jul 11 15:09:07 2005 Return-Path: X-Original-To: current@FreeBSD.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4FB3D16A41F for ; Mon, 11 Jul 2005 15:09:07 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from mv.twc.weather.com (mv.twc.weather.com [65.212.71.225]) by mx1.FreeBSD.org (Postfix) with ESMTP id A5C5543D48 for ; Mon, 11 Jul 2005 15:09:06 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: from [10.50.40.201] (Not Verified[65.202.103.25]) by mv.twc.weather.com with NetIQ MailMarshal (v6, 0, 3, 8) id ; Mon, 11 Jul 2005 11:23:09 -0400 From: John Baldwin To: Stefan Ehmann Date: Mon, 11 Jul 2005 11:01:28 -0400 User-Agent: KMail/1.8 References: <42C92DC5.3060101@gddsn.org.cn> <200507091517.57736.jhb@FreeBSD.org> <1120939825.937.11.camel@taxman.pepperland> In-Reply-To: <1120939825.937.11.camel@taxman.pepperland> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200507111101.29623.jhb@FreeBSD.org> Cc: current@FreeBSD.org, Fabian Keil Subject: Re: Suspend broken ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2005 15:09:07 -0000 On Saturday 09 July 2005 04:10 pm, Stefan Ehmann wrote: > On Sat, 2005-07-09 at 15:17 -0400, John Baldwin wrote: > > I think you just need to remove the extra { after the if statement on > > line 539 at the end of the line. > > This and changing timer0_max_real_count to timer0_real_max_count made it > compilable. > > But this time the system is immediately very slow (not just after > suspend) and I get this strange error message on startup: > > calcru: runtime went backwards from 68378390 usec to 67512958 usec for > pid 11 (idle: cpu0) I had never set timer0_real_max_count. :( One more time: --- //depot/vendor/freebsd/src/sys/amd64/isa/clock.c 2005/07/05 20:15:24 +++ //depot/user/jhb/acpipci/amd64/isa/clock.c 2005/07/11 14:46:07 @@ -101,6 +101,7 @@ #endif u_int timer_freq = TIMER_FREQ; int timer0_max_count; +int timer0_real_max_count; int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ struct mtx clock_lock; #define RTC_LOCK mtx_lock_spin(&clock_lock) @@ -108,7 +109,6 @@ static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; -static u_int hardclock_max_count; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; static u_int32_t i8254_offset; @@ -517,21 +517,24 @@ static void set_timer_freq(u_int freq, int intr_freq) { - int new_timer0_max_count; + int new_timer0_real_max_count; i8254_timecounter.tc_frequency = freq; mtx_lock_spin(&clock_lock); timer_freq = freq; - new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - if (using_lapic_timer) { + if (using_lapic_timer) + new_timer0_real_max_count = 0x10000; + else + new_timer0_real_max_count = TIMER_DIV(intr_freq); + if (new_timer0_real_max_count != timer0_real_max_count) { + timer0_real_max_count = new_timer0_real_max_count; + if (timer0_real_max_count == 0x10000) + timer0_max_count = 0xffff; + else + timer0_max_count = timer0_real_max_count; outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, 0); - outb(TIMER_CNTR0, 0); - } else if (new_timer0_max_count != timer0_max_count) { - timer0_max_count = new_timer0_max_count; - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, timer0_max_count & 0xff); - outb(TIMER_CNTR0, timer0_max_count >> 8); + outb(TIMER_CNTR0, timer0_real_max_count & 0xff); + outb(TIMER_CNTR0, timer0_real_max_count >> 8); } mtx_unlock_spin(&clock_lock); } @@ -826,19 +829,8 @@ static unsigned i8254_simple_get_timecount(struct timecounter *tc) { - u_int count; - u_int high, low; - mtx_lock_spin(&clock_lock); - - /* Select timer0 and latch counter value. */ - outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); - - low = inb(TIMER_CNTR0); - high = inb(TIMER_CNTR0); - count = 0xffff - ((high << 8) | low); - mtx_unlock_spin(&clock_lock); - return (count); + return (timer0_max_count - getit()); } static unsigned --- //depot/vendor/freebsd/src/sys/i386/isa/clock.c 2005/07/05 20:15:24 +++ //depot/user/jhb/acpipci/i386/isa/clock.c 2005/07/11 14:46:07 @@ -110,6 +110,7 @@ #endif u_int timer_freq = TIMER_FREQ; int timer0_max_count; +int timer0_real_max_count; int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ struct mtx clock_lock; #define RTC_LOCK mtx_lock_spin(&clock_lock) @@ -117,7 +118,6 @@ static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; -static u_int hardclock_max_count; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; static u_int32_t i8254_offset; @@ -531,21 +531,24 @@ static void set_timer_freq(u_int freq, int intr_freq) { - int new_timer0_max_count; + int new_timer0_real_max_count; i8254_timecounter.tc_frequency = freq; mtx_lock_spin(&clock_lock); timer_freq = freq; - new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - if (using_lapic_timer) { + if (using_lapic_timer) + new_timer0_real_max_count = 0x10000; + else + new_timer0_real_max_count = TIMER_DIV(intr_freq); + if (new_timer0_real_max_count != timer0_real_max_count) { + timer0_real_max_count = new_timer0_real_max_count; + if (timer0_real_max_count == 0x10000) + timer0_max_count = 0xffff; + else + timer0_max_count = timer0_real_max_count; outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, 0); - outb(TIMER_CNTR0, 0); - } else if (new_timer0_max_count != timer0_max_count) { - timer0_max_count = new_timer0_max_count; - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, timer0_max_count & 0xff); - outb(TIMER_CNTR0, timer0_max_count >> 8); + outb(TIMER_CNTR0, timer0_real_max_count & 0xff); + outb(TIMER_CNTR0, timer0_real_max_count >> 8); } mtx_unlock_spin(&clock_lock); } @@ -554,7 +557,11 @@ i8254_restore(void) { - set_timer_freq(timer_freq, hz); + mtx_lock_spin(&clock_lock); + outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); + outb(TIMER_CNTR0, timer0_real_max_count & 0xff); + outb(TIMER_CNTR0, timer0_real_max_count >> 8); + mtx_unlock_spin(&clock_lock); } static void @@ -876,19 +883,8 @@ static unsigned i8254_simple_get_timecount(struct timecounter *tc) { - u_int count; - u_int high, low; - mtx_lock_spin(&clock_lock); - - /* Select timer0 and latch counter value. */ - outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); - - low = inb(TIMER_CNTR0); - high = inb(TIMER_CNTR0); - count = 0xffff - ((high << 8) | low); - mtx_unlock_spin(&clock_lock); - return (count); + return (timer0_max_count - getit()); } static unsigned --- //depot/vendor/freebsd/src/sys/pc98/cbus/clock.c 2005/07/05 20:15:24 +++ //depot/user/jhb/acpipci/pc98/cbus/clock.c 2005/07/11 14:46:07 @@ -109,12 +109,12 @@ #endif u_int timer_freq = TIMER_FREQ; int timer0_max_count; +int timer0_real_max_count; int wall_cmos_clock; /* wall CMOS clock assumed if != 0 */ struct mtx clock_lock; static int beeping = 0; static const u_char daysinmonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; -static u_int hardclock_max_count; static struct intsrc *i8254_intsrc; static u_int32_t i8254_lastcount; static u_int32_t i8254_offset; @@ -472,21 +472,24 @@ static void set_timer_freq(u_int freq, int intr_freq) { - int new_timer0_max_count; + int new_timer0_real_max_count; i8254_timecounter.tc_frequency = freq; mtx_lock_spin(&clock_lock); timer_freq = freq; - new_timer0_max_count = hardclock_max_count = TIMER_DIV(intr_freq); - if (using_lapic_timer) { + if (using_lapic_timer) + new_timer0_real_max_count = 0x10000; + else + new_timer0_real_max_count = TIMER_DIV(intr_freq); + if (new_timer0_real_max_count != timer0_real_max_count) { + timer0_real_max_count = new_timer0_real_max_count; + if (timer0_real_max_count == 0x10000) + timer0_max_count = 0xffff; + else + timer0_max_count = timer0_real_max_count; outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, 0); - outb(TIMER_CNTR0, 0); - } else if (new_timer0_max_count != timer0_max_count) { - timer0_max_count = new_timer0_max_count; - outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); - outb(TIMER_CNTR0, timer0_max_count & 0xff); - outb(TIMER_CNTR0, timer0_max_count >> 8); + outb(TIMER_CNTR0, timer0_real_max_count & 0xff); + outb(TIMER_CNTR0, timer0_real_max_count >> 8); } mtx_unlock_spin(&clock_lock); } @@ -495,7 +498,11 @@ i8254_restore(void) { - set_timer_freq(timer_freq, hz); + mtx_lock_spin(&clock_lock); + outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); + outb(TIMER_CNTR0, timer0_real_max_count & 0xff); + outb(TIMER_CNTR0, timer0_real_max_count >> 8); + mtx_unlock_spin(&clock_lock); } @@ -815,19 +822,8 @@ static unsigned i8254_simple_get_timecount(struct timecounter *tc) { - u_int count; - u_int high, low; - mtx_lock_spin(&clock_lock); - - /* Select timer0 and latch counter value. */ - outb(TIMER_MODE, TIMER_SEL0 | TIMER_LATCH); - - low = inb(TIMER_CNTR0); - high = inb(TIMER_CNTR0); - count = 0xffff - ((high << 8) | low); - mtx_unlock_spin(&clock_lock); - return (count); + return (timer0_max_count - getit()); } static unsigned -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org