From owner-freebsd-hackers@FreeBSD.ORG Sat Jan 13 10:49:46 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 33D6D16A412 for ; Sat, 13 Jan 2007 10:49:46 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe07.swip.net [212.247.154.193]) by mx1.freebsd.org (Postfix) with ESMTP id CAC0913C455 for ; Sat, 13 Jan 2007 10:49:45 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [193.217.102.48] (account mc467741@c2i.net HELO [10.0.0.249]) by mailfe07.swip.net (CommuniGate Pro SMTP 5.0.12) with ESMTPA id 382832843 for freebsd-hackers@freebsd.org; Sat, 13 Jan 2007 11:49:43 +0100 From: Hans Petter Selasky To: freebsd-hackers@freebsd.org Date: Sat, 13 Jan 2007 11:49:19 +0100 User-Agent: KMail/1.7 References: <200701121437.10273.hselasky@c2i.net> In-Reply-To: <200701121437.10273.hselasky@c2i.net> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701131149.20182.hselasky@c2i.net> Subject: Re: mii_bus problem X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Jan 2007 10:49:46 -0000 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