From owner-freebsd-current@FreeBSD.ORG Sun Apr 6 15:25:38 2003 Return-Path: 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 4E4B737B401 for ; Sun, 6 Apr 2003 15:25:38 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id E882C43FBF for ; Sun, 6 Apr 2003 15:25:36 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id IAA12603; Mon, 7 Apr 2003 08:25:28 +1000 Date: Mon, 7 Apr 2003 08:25:27 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= In-Reply-To: Message-ID: <20030407081351.V2224@gamplex.bde.org> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=X-UNKNOWN Content-Transfer-Encoding: QUOTED-PRINTABLE cc: current@freebsd.org Subject: Re: weird fxp / timecounter interaction in top-of-tree X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 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: Sun, 06 Apr 2003 22:25:38 -0000 On Sun, 6 Apr 2003, Dag-Erling [iso-8859-1] Sm=F8rgrav wrote: > des@ofug.org (Dag-Erling Sm=F8rgrav) writes: > > - loading the if_fxp module (and miibus as a dependency) switches the > > timecounter hardware to PIIX. > > This turns out to be caused by a combination of bugs in tc_init() and > the piix driver. The piix driver initializes the PIIX timecounter in > piix_attach(), which is called whenever the PCI bus is rescanned (e.g. > when a driver for a PCI device such as fxp is loaded) instead of > piix_probe() which is only called once. The other problem is that > tc_init() will actually install the timecounter being initialized, so > in effect, unless you explicitly select one after boot, your machine > will use whichever timecounter was probed and attached last. > > I've modified the piix driver to only initialize the timecounter once, > and tc_init() to use the *first* timecounter it runs across (on i386, > this is generally the i8254), leaving the admin to pick another one if > the default does not suit her. See the attached patch. Do any other attach routines get called on rescan? I would expect most of them to do the wrong thing. > Index: sys/kern/kern_tc.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /home/ncvs/src/sys/kern/kern_tc.c,v > retrieving revision 1.148 > diff -u -r1.148 kern_tc.c > --- sys/kern/kern_tc.c=0918 Mar 2003 08:45:23 -0000=091.148 > +++ sys/kern/kern_tc.c=096 Apr 2003 18:06:38 -0000 > @@ -295,7 +295,8 @@ > =09printf("\n"); > =09(void)tc->tc_get_timecount(tc); > =09(void)tc->tc_get_timecount(tc); > -=09timecounter =3D tc; > +=09if (timecounter =3D=3D &dummy_timecounter) > +=09=09timecounter =3D tc; > } This is not quite right (see other replies), but tc_init() should be split up so that it never decides whether to start using the timecounter. Note that the tc_get_timecounter() calls are part of using it. Bruce