Date: Sun, 06 Apr 2003 20:19:10 +0200 From: des@ofug.org (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) To: current@freebsd.org Subject: Re: weird fxp / timecounter interaction in top-of-tree Message-ID: <xzpel4fmqu9.fsf@flood.ping.uio.no> In-Reply-To: <xzpu1dbeflv.fsf@flood.ping.uio.no> (des@ofug.org's message of "Sun, 06 Apr 2003 18:49:00 %2B0200") References: <xzpu1dbeflv.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-= 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[] = { --=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpel4fmqu9.fsf>