From owner-freebsd-current@FreeBSD.ORG Tue Nov 2 19:08:54 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 783CF16A4CE for ; Tue, 2 Nov 2004 19:08:54 +0000 (GMT) Received: from mail6.speakeasy.net (mail6.speakeasy.net [216.254.0.206]) by mx1.FreeBSD.org (Postfix) with ESMTP id 045C843D55 for ; Tue, 2 Nov 2004 19:08:54 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 22455 invoked from network); 2 Nov 2004 19:08:53 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail6.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 2 Nov 2004 19:08:53 -0000 Received: from hydrogen.funkthat.com (abufwd@localhost.funkthat.com [127.0.0.1])iA2J8qB6022730; Tue, 2 Nov 2004 11:08:53 -0800 (PST) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id iA2J8p8b022729; Tue, 2 Nov 2004 11:08:51 -0800 (PST) Date: Tue, 2 Nov 2004 11:08:51 -0800 From: John-Mark Gurney To: Peter Edwards Message-ID: <20041102190851.GR22681@funkthat.com> Mail-Followup-To: Peter Edwards , "Bjoern A. Zeeb" , peadar@freebsd.org, FreeBSD current mailing list , freebsd-amd64@freebsd.org References: <34cb7c8404110209563fc01498@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="wHh0aNzodMFDTGdO" Content-Disposition: inline In-Reply-To: <34cb7c8404110209563fc01498@mail.gmail.com> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: peadar@freebsd.org cc: "Bjoern A. Zeeb" cc: FreeBSD current mailing list cc: freebsd-amd64@freebsd.org Subject: Re: if_sk patch to get more info from people with problems X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Nov 2004 19:08:54 -0000 --wHh0aNzodMFDTGdO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Peter Edwards wrote this message on Tue, Nov 02, 2004 at 17:56 +0000: > A (very) quick look at the source reveals that buffers are allocated > via sk_rxeof()->sk_newbuf()->sk_jalloc() in the interrupt receive > function, with the softc lock held in sk_rxeof(). > > They're freed by the mbuf system via a call to sk_jfree(), but that > doesn't hold the SK_LOCK. Is this possibly the source of the > corruption problems? What am I missing? > This compiles, anyway :-) Well, try the attached patch (it also includes my changes from a previous diff) that will see what happens... Make sure you have your kernel compiled with WITNESS and INVARIANTS... If you hit one of these asserts, make sure you post the back trace... Thanks for the testing.. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." --wHh0aNzodMFDTGdO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="if_sk.diff" Index: if_sk.c =================================================================== RCS file: /home/ncvs/src/sys/pci/if_sk.c,v retrieving revision 1.87 diff -u -r1.87 if_sk.c --- if_sk.c 1 Nov 2004 17:21:04 -0000 1.87 +++ if_sk.c 2 Nov 2004 19:05:29 -0000 @@ -1076,6 +1076,8 @@ { struct sk_jpool_entry *entry; + SK_IF_LOCK_ASSERT(sc_if); + entry = SLIST_FIRST(&sc_if->sk_jfree_listhead); if (entry == NULL) { @@ -1108,6 +1110,8 @@ if (sc_if == NULL) panic("sk_jfree: didn't get softc pointer!"); + SK_IF_LOCK_ASSERT(sc_if); + /* calculate the slot this buffer belongs to */ i = ((vm_offset_t)buf - (vm_offset_t)sc_if->sk_cdata.sk_jumbo_buf) / SK_JLEN; @@ -1845,11 +1849,13 @@ } /* Transmit */ - sc_if->sk_cdata.sk_tx_prod = idx; - CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START); + if (idx != sc_if->sk_cdata.sk_tx_prod) { + sc_if->sk_cdata.sk_tx_prod = idx; + CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START); - /* Set a timeout in case the chip goes out to lunch. */ - ifp->if_timer = 5; + /* Set a timeout in case the chip goes out to lunch. */ + ifp->if_timer = 5; + } SK_IF_UNLOCK(sc_if); return; @@ -1989,13 +1995,15 @@ } sc_if->sk_cdata.sk_tx_cnt--; SK_INC(idx, SK_TX_RING_CNT); - ifp->if_timer = 0; } - sc_if->sk_cdata.sk_tx_cons = idx; - - if (cur_tx != NULL) + if (sc_if->sk_cdata.sk_tx_cnt == 0) { + ifp->if_timer = 0; ifp->if_flags &= ~IFF_OACTIVE; + } else /* nudge chip to keep tx ring moving */ + CSR_WRITE_4(sc, sc_if->sk_tx_bmu, SK_TXBMU_TX_START); + + sc_if->sk_cdata.sk_tx_cons = idx; return; } Index: if_skreg.h =================================================================== RCS file: /home/ncvs/src/sys/pci/if_skreg.h,v retrieving revision 1.22 diff -u -r1.22 if_skreg.h --- if_skreg.h 20 Aug 2004 06:22:04 -0000 1.22 +++ if_skreg.h 2 Nov 2004 19:05:29 -0000 @@ -1441,6 +1441,7 @@ #define SK_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sk_mtx, MA_OWNED) #define SK_IF_LOCK(_sc) SK_LOCK((_sc)->sk_softc) #define SK_IF_UNLOCK(_sc) SK_UNLOCK((_sc)->sk_softc) +#define SK_IF_LOCK_ASSERT(_sc) SK_LOCK_ASSERT((_sc)->sk_softc) /* Softc for each logical interface */ struct sk_if_softc { --wHh0aNzodMFDTGdO--