Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Apr 2003 08:25:27 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= <des@ofug.org>
Cc:        current@freebsd.org
Subject:   Re: weird fxp / timecounter interaction in top-of-tree
Message-ID:  <20030407081351.V2224@gamplex.bde.org>
In-Reply-To: <xzpel4fmqu9.fsf@flood.ping.uio.no>
References:  <xzpu1dbeflv.fsf@flood.ping.uio.no> <xzpel4fmqu9.fsf@flood.ping.uio.no>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030407081351.V2224>