From owner-freebsd-hackers@FreeBSD.ORG Fri Jan 12 14:37:41 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 DD7CD16A50B for ; Fri, 12 Jan 2007 14:37:41 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe09.swip.net [212.247.155.1]) by mx1.freebsd.org (Postfix) with ESMTP id 7A5BC13C45E for ; Fri, 12 Jan 2007 14:37:41 +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 mailfe09.swip.net (CommuniGate Pro SMTP 5.0.12) with ESMTPA id 211859336 for freebsd-hackers@freebsd.org; Fri, 12 Jan 2007 14:37:34 +0100 From: Hans Petter Selasky To: freebsd-hackers@freebsd.org Date: Fri, 12 Jan 2007 14:37:09 +0100 User-Agent: KMail/1.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701121437.10273.hselasky@c2i.net> Subject: 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: Fri, 12 Jan 2007 14:37:41 -0000 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. My ifmedia status callback looks like this: static void aue_ifmedia_sts_cb(struct ifnet *ifp, struct ifmediareq *ifmr) { printf("%s:%d\n", __FUNCTION__, __LINE__); struct aue_softc *sc = ifp->if_softc; mtx_lock(&(sc->sc_mtx)); //mii_pollstat(mii); I don't want this here hence it sleeps! ifmr->ifm_active = sc->sc_media_active; ifmr->ifm_status = sc->sc_media_status; mtx_unlock(&(sc->sc_mtx)); return; } The question is, is it at all possible to poll the MII status outside the ifmedia status callback ? And if yes, how? Thanks --HPS