From owner-freebsd-current@FreeBSD.ORG Sat Sep 20 01:36:36 2008 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27FC31065674 for ; Sat, 20 Sep 2008 01:36:36 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from ti-out-0910.google.com (ti-out-0910.google.com [209.85.142.186]) by mx1.freebsd.org (Postfix) with ESMTP id 9B1538FC15 for ; Sat, 20 Sep 2008 01:36:35 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: by ti-out-0910.google.com with SMTP id d27so344013tid.3 for ; Fri, 19 Sep 2008 18:36:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:received:date:from :to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=WaqUaaBUcO2QqVwK1tdenDI9WXVlhJwL++yCmo4c9qo=; b=w1Pdx0mCInbbJzmuxFpTHJ/lKty+vibj1u5T1sg7TvlMkrFLYVQpLosWtqk1jSAxCW GZJsEBnLvNLkPY5WG6MJOZxnQXmZ7c5nHHnp+B0N4rKey6vjd70WIal6gVAjzT/pJ5pa 9Met++ap7s2n4FtKsg9M4uZQAs+WT6EFFff6w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=i61ddH+hUSveRfYA5MVxyMLhX25kD1+9FZoyTsHnQJz9M6Pve80mJPdDJDR4evoZgD +UnNax6zqWW4VEaKOFSlqALPiG5unaV0oU0OskW6n7ZKUOBkrwgempq1XIs9Zm+CSW18 N5v6AFZ5B1TK7HjndWYZwGKwx/h5RxuonyiwY= Received: by 10.110.52.1 with SMTP id z1mr1299181tiz.19.1221874594477; Fri, 19 Sep 2008 18:36:34 -0700 (PDT) Received: from michelle.cdnetworks.co.kr ( [211.53.35.84]) by mx.google.com with ESMTPS id i6sm6443826tid.16.2008.09.19.18.36.31 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 19 Sep 2008 18:36:32 -0700 (PDT) Received: from michelle.cdnetworks.co.kr (localhost.cdnetworks.co.kr [127.0.0.1]) by michelle.cdnetworks.co.kr (8.13.5/8.13.5) with ESMTP id m8K1YZYB019076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 20 Sep 2008 10:34:35 +0900 (KST) (envelope-from pyunyh@gmail.com) Received: (from yongari@localhost) by michelle.cdnetworks.co.kr (8.13.5/8.13.5/Submit) id m8K1YY6h019075; Sat, 20 Sep 2008 10:34:34 +0900 (KST) (envelope-from pyunyh@gmail.com) Date: Sat, 20 Sep 2008 10:34:34 +0900 From: Pyun YongHyeon To: Ian Freislich Message-ID: <20080920013434.GB18734@cdnetworks.co.kr> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Cc: current@freebsd.org Subject: Re: msk(4) issues X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Sep 2008 01:36:36 -0000 --+g7M9IMkV8truYOl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Sep 17, 2008 at 10:16:29AM +0200, Ian Freislich wrote: > Hi > > I'm having an issue with the msk hardware in my laptop. It stops > transmitting or recieving sometimes, always triggered by periods > of intense network load. > > Sep 16 18:39:31 apple kernel: msk0: watchdog timeout (missed Tx interrupts) -- recovering > Sep 16 18:40:35 apple kernel: msk0: watchdog timeout (missed Tx interrupts) -- recovering > Sep 16 18:41:41 apple kernel: msk0: watchdog timeout (missed Tx interrupts) -- recovering > > But it never recovers. > > mskc0@pci0:2:0:0: class=0x020000 card=0x532111ab chip=0x436211ab rev=0x22 hdr=0x00 > vendor = 'Marvell Semiconductor (Was: Galileo Technology Ltd)' > device = '88E8053 Marvell Yukon 88E8053 PCI-E Gigabit Ethernet Controller' > class = network > subclass = ethernet > > Ian > Would you try attached patch? -- Regards, Pyun YongHyeon --+g7M9IMkV8truYOl Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="msk.watchdog.diff" Index: if_msk.c =================================================================== --- if_msk.c (revision 183165) +++ if_msk.c (working copy) @@ -244,6 +244,9 @@ static int msk_handle_events(struct msk_softc *); static void msk_handle_hwerr(struct msk_if_softc *, uint32_t); static void msk_intr_hwerr(struct msk_softc *); +#ifndef __NO_STRICT_ALIGNMENT +static __inline void msk_fixup_rx(struct mbuf *); +#endif static void msk_rxeof(struct msk_if_softc *, uint32_t, int); static void msk_jumbo_rxeof(struct msk_if_softc *, uint32_t, int); static void msk_txeof(struct msk_if_softc *, int); @@ -783,7 +786,12 @@ return (ENOBUFS); m->m_len = m->m_pkthdr.len = MCLBYTES; - m_adj(m, ETHER_ALIGN); + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_rx_tag, sc_if->msk_cdata.msk_rx_sparemap, m, segs, &nsegs, @@ -840,7 +848,12 @@ return (ENOBUFS); } m->m_pkthdr.len = m->m_len = MSK_JLEN; - m_adj(m, ETHER_ALIGN); + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + m_adj(m, ETHER_ALIGN); +#ifndef __NO_STRICT_ALIGNMENT + else + m_adj(m, MSK_RX_BUF_ALIGN); +#endif if (bus_dmamap_load_mbuf_sg(sc_if->msk_cdata.msk_jumbo_rx_tag, sc_if->msk_cdata.msk_jumbo_rx_sparemap, m, segs, &nsegs, @@ -1041,14 +1054,16 @@ { int next; int i; - uint8_t val; /* Get adapter SRAM size. */ - val = CSR_READ_1(sc, B2_E_0); - sc->msk_ramsize = (val == 0) ? 128 : val * 4; + sc->msk_ramsize = CSR_READ_1(sc, B2_E_0) * 4; if (bootverbose) device_printf(sc->msk_dev, "RAM buffer size : %dKB\n", sc->msk_ramsize); + if (sc->msk_ramsize == 0) + return (0); + + sc->msk_pflags |= MSK_FLAG_RAMBUF; /* * Give receiver 2/3 of memory and round down to the multiple * of 1024. Tx/Rx RAM buffer size of Yukon II shoud be multiple @@ -1412,6 +1427,7 @@ sc_if->msk_if_dev = dev; sc_if->msk_port = port; sc_if->msk_softc = sc; + sc_if->msk_flags = sc->msk_pflags; sc->msk_if[port] = sc_if; /* Setup Tx/Rx queue register offsets. */ if (port == MSK_PORT_A) { @@ -1976,6 +1992,7 @@ struct msk_rxdesc *jrxd; struct msk_jpool_entry *entry; uint8_t *ptr; + bus_size_t rxalign; int error, i; mtx_init(&sc_if->msk_jlist_mtx, "msk_jlist_mtx", NULL, MTX_DEF); @@ -2107,9 +2124,16 @@ goto fail; } + rxalign = 1; + /* + * Workaround hardware hang which seems to happen when Rx buffer + * is not aligned on multiple of FIFO word(8 bytes). + */ + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + rxalign = MSK_RX_BUF_ALIGN; /* Create tag for Rx buffers. */ error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ - 1, 0, /* alignment, boundary */ + rxalign, 0, /* alignment, boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ @@ -2918,6 +2942,23 @@ return (0); } +#ifndef __NO_STRICT_ALIGNMENT +static __inline void +msk_fixup_rx(struct mbuf *m) +{ + int i; + uint16_t *src, *dst; + + src = mtod(m, uint16_t *); + dst = src - 3; + + for (i = 0; i < (m->m_len / sizeof(uint16_t) + 1); i++) + *dst++ = *src++; + + m->m_data -= (MSK_RX_BUF_ALIGN - ETHER_ALIGN); +} +#endif + static void msk_rxeof(struct msk_if_softc *sc_if, uint32_t status, int len) { @@ -2955,6 +2996,10 @@ } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; +#ifndef __NO_STRICT_ALIGNMENT + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + msk_fixup_rx(m); +#endif ifp->if_ipackets++; /* Check for VLAN tagged packets. */ if ((status & GMR_FS_VLAN) != 0 && @@ -3008,6 +3053,10 @@ } m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = m->m_len = len; +#ifndef __NO_STRICT_ALIGNMENT + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) != 0) + msk_fixup_rx(m); +#endif ifp->if_ipackets++; /* Check for VLAN tagged packets. */ if ((status & GMR_FS_VLAN) != 0 && @@ -3677,7 +3726,7 @@ /* Configure hardware VLAN tag insertion/stripping. */ msk_setvlan(sc_if, ifp); - if (sc->msk_hw_id == CHIP_ID_YUKON_EC_U) { + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) { /* Set Rx Pause threshould. */ CSR_WRITE_1(sc, MR_ADDR(sc_if->msk_port, RX_GMF_LP_THR), MSK_ECU_LLPP); @@ -3790,6 +3839,8 @@ int ltpp, utpp; sc = sc_if->msk_softc; + if ((sc_if->msk_flags & MSK_FLAG_RAMBUF) == 0) + return; /* Setup Rx Queue. */ CSR_WRITE_1(sc, RB_ADDR(sc_if->msk_rxq, RB_CTRL), RB_RST_CLR); Index: if_mskreg.h =================================================================== --- if_mskreg.h (revision 183165) +++ if_mskreg.h (working copy) @@ -2158,6 +2158,7 @@ #define MSK_TX_RING_CNT 256 #define MSK_RX_RING_CNT 256 +#define MSK_RX_BUF_ALIGN 8 #define MSK_JUMBO_RX_RING_CNT MSK_RX_RING_CNT #define MSK_STAT_RING_CNT ((1 + 3) * (MSK_TX_RING_CNT + MSK_RX_RING_CNT)) #define MSK_MAXTXSEGS 32 @@ -2307,6 +2308,7 @@ uint32_t msk_coppertype; uint32_t msk_intrmask; uint32_t msk_intrhwemask; + uint32_t msk_pflags; int msk_suspended; int msk_clock; int msk_msi; @@ -2348,6 +2350,8 @@ int msk_phytype; int msk_phyaddr; int msk_link; + uint32_t msk_flags; +#define MSK_FLAG_RAMBUF 0x0010 struct callout msk_tick_ch; int msk_watchdog_timer; uint32_t msk_txq; /* Tx. Async Queue offset */ --+g7M9IMkV8truYOl--