From owner-freebsd-current@FreeBSD.ORG Sun Apr 6 11:19:15 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 F06EF37B404; Sun, 6 Apr 2003 11:19:14 -0700 (PDT) Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id 828E243FAF; Sun, 6 Apr 2003 11:19:13 -0700 (PDT) (envelope-from des@ofug.org) Received: by flood.ping.uio.no (Postfix, from userid 2602) id B6E09530A; Sun, 6 Apr 2003 20:19:11 +0200 (CEST) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: current@freebsd.org From: des@ofug.org (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Sun, 06 Apr 2003 20:19:10 +0200 In-Reply-To: (des@ofug.org's message of "Sun, 06 Apr 2003 18:49:00 +0200") Message-ID: User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2 References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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 18:19:15 -0000 --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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. > - switching the timecounter hardware manually to PIIX when if_fxp and > miibus are loaded causes the machine to lock up. This problem seems to have disappeared now that the PIIX timecounter only gets initialized once. DES --=20 Dag-Erling Sm=F8rgrav - des@ofug.org --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=timecounter.diff Index: sys/kern/kern_tc.c =================================================================== 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 18 Mar 2003 08:45:23 -0000 1.148 +++ sys/kern/kern_tc.c 6 Apr 2003 18:06:38 -0000 @@ -295,7 +295,8 @@ printf("\n"); (void)tc->tc_get_timecount(tc); (void)tc->tc_get_timecount(tc); - timecounter = tc; + if (timecounter == &dummy_timecounter) + timecounter = tc; } /* Report the frequency of the current timecounter. */ Index: sys/i386/i386/mp_clock.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/mp_clock.c,v retrieving revision 1.11 diff -u -r1.11 mp_clock.c --- sys/i386/i386/mp_clock.c 13 Nov 2002 17:50:59 -0000 1.11 +++ sys/i386/i386/mp_clock.c 6 Apr 2003 17:41:44 -0000 @@ -101,12 +101,11 @@ switch (pci_get_devid(dev)) { case 0x71138086: d = pci_read_config(dev, 0x4, 2); - if (!(d & 1)) - return 0; /* IO space not mapped */ - d = pci_read_config(dev, 0x40, 4); - piix_timecounter_address = (d & 0xffc0) + 8; - piix_timecounter.tc_frequency = piix_freq; - tc_init(&piix_timecounter); + if (d & 1) + return (0); + printf("PIIX I/O space not mapped\n"); + return (ENXIO); + default: return (ENXIO); }; return (ENXIO); @@ -115,8 +114,13 @@ static int piix_attach (device_t dev) { - - return 0; + u_int32_t d; + + d = pci_read_config(dev, 0x40, 4); + piix_timecounter_address = (d & 0xffc0) + 8; + piix_timecounter.tc_frequency = piix_freq; + tc_init(&piix_timecounter); + return (0); } static device_method_t piix_methods[] = { --=-=-=--