From owner-freebsd-drivers@FreeBSD.ORG Tue Jul 15 02:11:36 2008 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52662106564A for ; Tue, 15 Jul 2008 02:11:36 +0000 (UTC) (envelope-from mirnshi@gmail.com) Received: from yw-out-2324.google.com (yw-out-2324.google.com [74.125.46.28]) by mx1.freebsd.org (Postfix) with ESMTP id EA74A8FC1F for ; Tue, 15 Jul 2008 02:11:35 +0000 (UTC) (envelope-from mirnshi@gmail.com) Received: by yw-out-2324.google.com with SMTP id 9so2165333ywe.13 for ; Mon, 14 Jul 2008 19:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type:references; bh=EzgMo10+7GT5Jue3+d4Cpsb2U5yf7//KfXkVgX82O6M=; b=PyEnWfEhZqEivtfGrj8zrBMbEpQXSJS2tOQ8qK5F8Ws7Bj5/txvAyaLFSLyFCxsThj Q/3AekN9ZB+/D0esa5YMqj150EzRTUCY55YYOs5bfK2Z3JEf/zNimyRFWIiQJXz3lA9r E+bBabkbYB+RLaJP0OYFn4HMqiyDJ9F0p1Yng= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:references; b=iw564bp//Rr1uru97yuXE+fWD6EMEveRAdxxhpTOpEYk1NcLikdkhsIctkISBVD9ho boOSXArr/1bvc4SfLmT8FC4L4tQTIM5jxDmXzG5Wjg8vo9s1OCj9XC/nXuvaIBQZVeCS Ml4NZFPlcpZxoQYtUWA6tdCpV9pvEgrEsSGkY= Received: by 10.151.12.4 with SMTP id p4mr16801862ybi.76.1216087883988; Mon, 14 Jul 2008 19:11:23 -0700 (PDT) Received: by 10.150.157.5 with HTTP; Mon, 14 Jul 2008 19:11:23 -0700 (PDT) Message-ID: Date: Tue, 15 Jul 2008 10:11:23 +0800 From: mirnshi@gmail.com To: pyunyh@gmail.com In-Reply-To: <20080715004301.GB40212@cdnetworks.co.kr> MIME-Version: 1.0 References: <20080715004301.GB40212@cdnetworks.co.kr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-drivers@freebsd.org Subject: Re: patch for Attansic L2 FastEthernet X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jul 2008 02:11:36 -0000 2008/7/15 Pyun YongHyeon : > On Mon, Jul 14, 2008 at 10:30:36PM +0800, mirnshi@gmail.com wrote: > > Recently, I got an eeepc 701. And I installed FreeBSD 7.0 on it . The > url > > http://wiki.freebsd.org/AsusEee gives me a big hand. But, the driver of > lan > > did not work. The problem is that the driver can be loaded by kldload, > but > > the interrupt storm caused the system to stop responding when I use > ifconfig > > to mark the nic 'up'. BTW, I used 10MB hub. > > Sound like interrupts are enabled in taskqueue handler. > > > > > The driver uses taskqueue_enqueue. 'ae_intr' reads nic register, but > > 'ae_int_task' reads it again. So I merge them into the new 'ae_intr'. > > I test 'ping' and 'ftp', it works well. > > > > You can't hold a mutex in fast interrupt handler. Do you mean the driver will slow down? Many GB driver use LOCK in their xxx_intr. > Since there is no documentation for L2 controller I'm not sure but > ae_int_task() seems to have a code that reenables interrupts which > was already disabled in ae_intr(). How about nuking AE_ISR_DISABLE > in ae_int_task()? > > From: > /* Clear interrupts and disable them. */ > AE_WRITE_4(sc, AE_ISR_REG, val | AE_ISR_DISABLE); > > To: > /* Clear interrupts. */ > AE_WRITE_4(sc, AE_ISR_REG, val); enable or disable the interrupt? I think this code enable the interrupt, right? Stanislav did not write the status word back, just disable the interrupt. AE_WRITE_4(sc, AE_ISR_REG, AE_ISR_DISABLE); but, the linux does it AT_WRITE_REG(hw, REG_ISR, status|ISR_DIS_INT); In 'ae_int_task', Stanislav read the status word again, like in linux, write back. val = AE_READ_4(sc, AE_ISR_REG); AE_WRITE_4(sc, AE_ISR_REG, val | AE_ISR_DISABLE); Is the status word still there ? > CCed to Stanislav Sedov, the author of driver. > > > Please refer to the patch for details. > > > > --- if_ae.c 2008-06-27 20:19:43.000000000 +0800 > > +++ /sys/dev/if_ae/if_ae.c 2008-07-14 21:54:06.000000000 +0800 > > @@ -1450,20 +1450,56 @@ > > { > > ae_softc_t *sc; > > uint32_t val; > > + struct ifnet *ifp; > > + struct mii_data *mii; > > > > sc = (ae_softc_t *)arg; > > + AE_LOCK(sc); > > KASSERT(sc != NULL, ("[ae, %d]: sc is null", __LINE__)); > > > > val = AE_READ_4(sc, AE_ISR_REG); > > - if (val == 0 || (val & AE_IMR_DEFAULT) == 0) > > + if (val == 0 || (val & AE_IMR_DEFAULT) == 0) { > > + AE_UNLOCK(sc); > > return FILTER_STRAY; > > + } > > > > - /* Disable interrupts. */ > > - AE_WRITE_4(sc, AE_ISR_REG, AE_ISR_DISABLE); > > + /* Clear interrupts and disable them. */ > > + AE_WRITE_4(sc, AE_ISR_REG, val | AE_ISR_DISABLE); > > > > - /* Schedule interrupt processing. */ > > - taskqueue_enqueue(sc->tq, &sc->int_task); > > + ifp = sc->ifp; > > > > + if ((val & AE_ISR_PHY) != 0) { > > + /* > > + * Clear PHY interrupt. Not sure if it needed. From Linux. > > + */ > > + ae_miibus_readreg(sc->miibus, 1, 19); > > + } > > + > > +#ifdef AE_DEBUG > > + if_printf(ifp, "Interrupt received: 0x%08x\n", val); > > +#endif > > + > > + if ((val & (AE_ISR_PHY | AE_ISR_MANUAL)) != 0) { > > + mii = device_get_softc(sc->miibus); > > + mii_mediachg(mii); > > + } > > + > > + if ((val & (AE_ISR_DMAR_TIMEOUT | AE_ISR_DMAW_TIMEOUT | > > + AE_ISR_PHY_LINKDOWN)) != 0) { > > + ae_init_locked(sc); > > + } > > + if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { > > + if ((val & AE_ISR_TX_EVENT) != 0) > > + ae_tx_intr(sc); > > + > > + if ((val & AE_ISR_RX_EVENT) != 0) > > + ae_rx_intr(sc); > > + } > > + > > + /* Re-enable interrupts. */ > > + AE_WRITE_4(sc, AE_ISR_REG, 0); > > + > > + AE_UNLOCK(sc); > > return (FILTER_HANDLED); > > } > > -- > Regards, > Pyun YongHyeon >