All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: xen-devel@lists.xensource.com
Subject: xen PIT timer
Date: Fri, 23 Sep 2005 14:49:07 -0500	[thread overview]
Message-ID: <20050923194907.GA330@us.ibm.com> (raw)


Still looking at bug #195 which shows up occasionally  upon boot, and
now, I can recreate by generating a lot of traffic over the serial line
into Xen (holding down 'r' to print the run queues).  

I started comparing how Xen sets up and calibrates the timers with
Linux and have a few questions where they differ.

In Linux, the i386 and x86_64 set up the pit timer using 
binary, mode 2, LSB/MSB, ch 0, and then periodically read PIT_CH0 to
obtain a count.  Linux also uses PIT CH2 to do some calibration.

Xen, in xen/arch/x86/i8259.c sets up the PIT in the same manner (binary,
mode 2, LSB/MSB, ch 0)  but as far as I can see, PIT_CH0 is never used
again, specifically, PIT_CH0 is not used when handling a timer
interrupt.  

Instead, in xen/arch/x86/time.c, when Xen uses PIT as the platform timer,
it runs pit_read_counter() which gets a count from PIT_CH2, which was
used during calibrate_boot_tsc() but in mode 0.

I don't fully understand the different modes of the PIT, but looking at
the some intel [1]documentation I see:

    MODE 0: INTERRUPT ON TERMINAL COUNT
    Mode 0 is typically used for event counting After the Control Word
    is written OUT is initially low and will remain low until the
    Counter reaches zero OUT then goes high and remains high until a new
    count or a new Mode 0 Control Word is written into the Counter 

    MODE 2 RATE GENERATOR 
    This Mode functions like a divide-by-N counter It is typicially used
    to generate a Real Time Clock interrupt OUT will initially be high
    When the initial count has decremented to 1 OUT goes low for one CLK
    pulse OUT then goes high again the Counter reloads the initial count
    and the process is repeated Mode 2 is periodic the same sequence is
    repeated indefinitely For an initial count of N the sequence repeats
    every N CLK cycles 

Why does Xen chose to use mode 0, on PIT CH2 for calculating how much
time has passed rather than how Linux using PIT_CH0 in mode 2?  Are
there some trade offs?

1. http://www.cs.utexas.edu/users/dahlin/Classes/UGOS/reading/82C54.pdf

-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
(512) 838-9253   T/L: 678-9253
ryanh@us.ibm.com

             reply	other threads:[~2005-09-23 19:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-23 19:49 Ryan Harper [this message]
2005-09-24  7:48 ` xen PIT timer Keir Fraser
2005-09-26 15:22   ` Ryan Harper
2005-09-26 15:49     ` Keir Fraser
2005-09-26 16:06       ` Ryan Harper

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=20050923194907.GA330@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.