9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Richard Miller <rm@hamnavoe.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] rio and acme scrolling
Date: Sat, 27 Mar 2004 15:22:57 +0000	[thread overview]
Message-ID: <78e57cf1aaa73ca03a1e3a5df2385bd8@hamnavoe.com> (raw)
In-Reply-To: <466a2993c3a0232a58065be590e2a716@plan9.bell-labs.com>

> The clock (timer 2) speeds up by a factor of 5 or so.
> I can only assume that the firmware uses it for something
> to do with detecting the lid opening again.

This seems to be a particular problem with thinkpads - and it's
not just closing the lid: screen blanking will reset the clock
period as well.

Fixing it with timesync is not good enough, because bad things
can still happen while the clock is racing until timesync notices.
In particular, the timeout waiting for a spun-down hard drive
to come up is much too short, resulting in spurious "disk errors" -
I've lost my fossil fs twice because of this.  (Thanks to venti,
this was an irritation rather than a disaster.)

Here's the workaround I use to detect the loss of the clock period
and repair it as soon as it happens.  You'll still lose the odd
millisecond but it's better than an ongoing 5x clock overrun:

term% diff /sys/src/9/pc/i8253.c i8253.c
268c269
< 	else
---
> 	else {
269a271,278
> 		if (x > 3*MaxPeriod) {
> 			outb(Tmode, Load2|Square);
> 			outb(T2cntr, 0);		/* low byte */
> 			outb(T2cntr, 0);		/* high byte */
> 			y = 0xFFFF;
> 			x = i8253.period;
> 		}
> 	}

Alternatively, why not use the TSC when there is one?  I note that
this is the default for the MP architecture, but only for CPU server
kernels -- does anyone know why?

Here's a one-line fix which also seems to work on my thinkpad:

term% diff /sys/src/9/pc/devarch.c devarch.c
692a693
> 		archgeneric.fastclock = tscticks;

-- Richard



  parent reply	other threads:[~2004-03-27 15:22 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-27  0:58 Micah Stetson
2004-03-27  1:51 ` Russ Cox
2004-03-27  5:07   ` Micah Stetson
2004-03-27 15:01     ` David Presotto
2004-03-27 15:07       ` Sape Mullender
2004-03-27 15:12         ` David Presotto
2004-03-27 20:58           ` Derek Fawcus
2004-03-27 15:22       ` Richard Miller [this message]
2004-03-27 15:36         ` Sape Mullender
2004-03-27 15:38         ` David Presotto
2004-03-27 15:38         ` Russ Cox
2004-03-27 17:03           ` Richard Miller
2004-03-27 16:07         ` andrey mirtchovski
2004-03-27 20:11         ` Micah Stetson
2004-03-27 20:45           ` thinkpads (was Re: [9fans] rio and acme scrolling) Axel Belinfante
2004-03-28 11:07           ` [9fans] rio and acme scrolling matt
2004-03-29 15:18             ` splite
2004-03-27 20:27       ` Micah Stetson
2004-03-27 23:57         ` Micah Stetson
2004-03-27  3:14 ` jmk
2004-03-27 10:21   ` a
2004-03-27 10:50     ` Dave Lukes
2004-03-29 13:41 ` blstuart
2004-03-29 14:33   ` Russ Cox
2004-03-29 14:36   ` matt
2004-03-29 15:57     ` Axel Belinfante
2004-03-29 17:31       ` Axel Belinfante
2004-03-29 18:42         ` [9fans] hget rog
2004-03-29 19:50           ` Russ Cox
2004-03-29 20:12             ` rog
2004-03-29 20:16               ` Russ Cox
2004-03-29 20:40                 ` rog
2004-03-29 20:42                   ` Russ Cox
2004-03-29 21:12                     ` rog
2004-03-29 22:23                       ` Charles Forsyth
2004-03-29 21:36                         ` rog
2004-03-29 23:39                           ` Charles Forsyth
2004-03-29 22:48                             ` rog
2004-03-29 21:46                               ` boyd, rounin
2004-03-29 23:01                                 ` rog
2004-03-29 22:17                                   ` boyd, rounin
2004-03-29 23:34                                     ` rog
2004-03-29 22:49                                       ` boyd, rounin
2004-03-30 10:19                                         ` Steve Simon
2004-03-30  0:02                                   ` Charles Forsyth
2004-03-29 23:22                                     ` rog
2004-03-29 19:58           ` David Tolpin
2004-03-29 20:08           ` David Tolpin
2004-03-29 20:18             ` rog

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=78e57cf1aaa73ca03a1e3a5df2385bd8@hamnavoe.com \
    --to=rm@hamnavoe.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).