mii_bus problem
Hans Petter Selasky
hselasky at c2i.net
Sat Jan 13 10:49:46 UTC 2007
On Friday 12 January 2007 14:37, Hans Petter Selasky wrote:
> Hi,
>
> Can someone here explain from where I can call "mii_pollstat()". I read
> somewhere on the internet that I cannot call this function from the so
> called "tick" routine, where "mii_tick()" is called. I currently have the
> following code:
>
> static void
> aue_cfg_tick(struct aue_softc *sc,
> struct aue_config_copy *cc, u_int16_t refcount)
> {
> printf("%s:%d\n", __FUNCTION__, __LINE__);
>
> struct ifnet * ifp = sc->sc_ifp;
> struct mii_data * mii = GET_MII(sc);
>
> if ((cc == NULL) ||
> (ifp == NULL) ||
> (mii == NULL)) {
> /* not ready */
> return;
> }
>
> mii_tick(mii);
>
> mii_pollstat(mii);
>
> if ((sc->sc_flags & AUE_FLAG_WAIT_LINK) &&
> (mii->mii_media_status & IFM_ACTIVE) &&
> (IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE)) {
> sc->sc_flags &= ~AUE_FLAG_WAIT_LINK;
> }
>
> sc->sc_media_active = mii->mii_media_active;
> sc->sc_media_status = mii->mii_media_status;
>
> /* start stopped transfers, if any */
>
> aue_start_transfers(sc);
>
> return;
> }
>
>
> But after this function returns, the kernel corrupts, and it pagefaults in
> the "swi6 taskqueue". Commenting out "mii_pollstat()" fixes the kernel
> panic.
After some debugging I found out that the kernel corrupted because there was
not a pointer to "struct ifnet" at the beginning of the softc. I see that
some parts of the MII code uses an "EVIL HACK" to get the "struct ifnet"
pointer. This should be fixed.
Now calling mii_pollstat() works.
--HPS
More information about the freebsd-hackers
mailing list