weird fxp / timecounter interaction in top-of-tree

Bruce Evans bde at zeta.org.au
Sun Apr 6 15:25:38 PDT 2003


On Sun, 6 Apr 2003, Dag-Erling [iso-8859-1] Sm=F8rgrav wrote:

> des at 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


More information about the freebsd-current mailing list