From owner-freebsd-mips@FreeBSD.ORG Fri Sep 3 18:38:27 2010 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9FE4C10656A6 for ; Fri, 3 Sep 2010 18:38:27 +0000 (UTC) (envelope-from stas@FreeBSD.org) Received: from mx0.deglitch.com (backbone.deglitch.com [78.110.53.255]) by mx1.freebsd.org (Postfix) with ESMTP id 207358FC18 for ; Fri, 3 Sep 2010 18:38:26 +0000 (UTC) Received: from sputnik.SpringDaemons.com (c-98-234-104-113.hsd1.ca.comcast.net [98.234.104.113]) by mx0.deglitch.com (Postfix) with ESMTPA id B62828FC4E; Fri, 3 Sep 2010 22:13:18 +0400 (MSD) Received: from sputnik.SpringDaemons.com (localhost [127.0.0.1]) by sputnik.SpringDaemons.com (Postfix) with SMTP id C05D2B8F3; Fri, 3 Sep 2010 11:21:33 -0700 (PDT) Date: Fri, 3 Sep 2010 11:21:33 -0700 From: Stanislav Sedov To: Paul Heyman Message-Id: <20100903112133.dfcae3e5.stas@FreeBSD.org> In-Reply-To: <32AB5C9615CC494997D9ABB1DB12783C024C8C5A64@SJ-EXCH-1.adaranet.com> References: <4C81066B.9040902@multi-media-tech.com> <32AB5C9615CC494997D9ABB1DB12783C024C8C5A64@SJ-EXCH-1.adaranet.com> Organization: The FreeBSD Project X-XMPP: ssedov@jabber.ru X-Voice: +7 916 849 20 23 X-PGP-Fingerprin: F21E D6CC 5626 9609 6CE2 A385 2BF5 5993 EB26 9581 X-Mailer: carrier-pigeon Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "jmallett@FreeBSD.org" , Patrick Mahan , "freebsd-mips@freebsd.org" Subject: Re: Now partially booting on our CN58XX eval board X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2010 18:38:27 -0000 On Fri, 3 Sep 2010 08:17:16 -0700 Paul Heyman mentioned: > Juli > > Thanks for the pointer regarding limiting the bootmem to 512M. I modified what gets passed to cvmx_bootmem_phy_alloc in the max_addr parameter. > > That gets us past the panic and brings the kernel up to a prompt. > No failure conditions observed on the console > >From the shell prompt all seems well. > > But when we try and ping in or out we seem to get a panic from the ethernet controller. > It does not happen all of the time. It usually take 50 - 200 pings to cause the problem. > I have isolated it to a few places in cvm_oct_tasklet_rx function in ethernet-rx.c. > > 1. At line 293 . it looks like the entire packet is stored in the work entry. I can see the panic in the code, but on the console it also indicates a NULL ptr being passed to cvmx_phys_to_ptr. Not sure if the NULL pointer is caused by the panic. This is what is on the console > > root@-2-/root# WARNING: > cvmx_phys_to_ptr() passed a zero address > panic: cvm_oct_tasklet_rx: not yet implemented; copy in small packet. > KDB: enter: panic > [ thread pid 0 tid 100016 ] > Stopped at kdb_enter+0x50: lui at,0x8358 > db> > > 2. At line 406 of the same file. Calling cvm_oct_mem_fill_fpa results in a TLB miss (store). > Hey, Paul! Try the following patch. It fixed the problem for me, but I had no time to commit it yet. Index: sys/mips/cavium/octe/cavium-ethernet.h =================================================================== --- sys/mips/cavium/octe/cavium-ethernet.h (revision 208288) +++ sys/mips/cavium/octe/cavium-ethernet.h (working copy) @@ -119,6 +119,8 @@ struct ifmedia media; int if_flags; + + struct mtx tx_mtx; } cvm_oct_private_t; Index: sys/mips/cavium/octe/octe.c =================================================================== --- sys/mips/cavium/octe/octe.c (revision 208288) +++ sys/mips/cavium/octe/octe.c (working copy) @@ -78,6 +78,9 @@ #include "miibus_if.h" +#define OCTE_TX_LOCK(priv) mtx_lock(&(priv)->tx_mtx) +#define OCTE_TX_UNLOCK(priv) mtx_unlock(&(priv)->tx_mtx) + static int octe_probe(device_t); static int octe_attach(device_t); static int octe_detach(device_t); @@ -174,6 +177,8 @@ priv->if_flags = ifp->if_flags; + mtx_init(&priv->tx_mtx, ifp->if_xname, "octe tx send queue", MTX_DEF); + for (qos = 0; qos < 16; qos++) { mtx_init(&priv->tx_free_queue[qos].ifq_mtx, ifp->if_xname, "octe tx free queue", MTX_DEF); IFQ_SET_MAXLEN(&priv->tx_free_queue[qos], MAX_OUT_QUEUE_DEPTH); @@ -181,9 +186,11 @@ ether_ifattach(ifp, priv->mac); + OCTE_TX_LOCK(priv); IFQ_SET_MAXLEN(&ifp->if_snd, MAX_OUT_QUEUE_DEPTH); ifp->if_snd.ifq_drv_maxlen = MAX_OUT_QUEUE_DEPTH; IFQ_SET_READY(&ifp->if_snd); + OCTE_TX_UNLOCK(priv); return (0); } @@ -280,8 +287,11 @@ if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) return; + OCTE_TX_LOCK(priv); while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + if (m == NULL) + break; /* * XXX @@ -301,17 +311,21 @@ * (3) do the collapse here. */ + OCTE_TX_UNLOCK(priv); if (priv->queue != -1) { error = cvm_oct_xmit(m, ifp); } else { error = cvm_oct_xmit_pow(m, ifp); } + OCTE_TX_LOCK(priv); if (error != 0) { ifp->if_drv_flags |= IFF_DRV_OACTIVE; + OCTE_TX_UNLOCK(priv); return; } } + OCTE_TX_UNLOCK(priv); } static int -- Stanislav Sedov ST4096-RIPE