DragonFly BSD
DragonFly submit List (threaded) for 2005-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

if_iwi bugfix


From: Joerg Sonnenberger <joerg@xxxxxxxxxxxxxxxxx>
Date: Wed, 19 Oct 2005 22:51:37 +0200
Mail-followup-to: submit@crater.dragonflybsd.org

Hi all,
if you have an iwi(4) device, please test the attached bugfix. I plan to
commit this change the day after tomorrow.

Joerg
? if_iwi.c.diff
Index: if_iwi.c
===================================================================
RCS file: /cvs/src/sys/dev/netif/iwi/if_iwi.c,v
retrieving revision 1.7
diff -u -r1.7 if_iwi.c
--- if_iwi.c	12 Oct 2005 17:35:52 -0000	1.7
+++ if_iwi.c	19 Oct 2005 20:49:43 -0000
@@ -1138,7 +1138,7 @@
 {
 	struct ieee80211com *ic = &sc->sc_ic;
 	struct ifnet *ifp = &ic->ic_if;
-	struct mbuf *m;
+	struct mbuf *m, *m_new;
 	struct ieee80211_frame *wh;
 	struct ieee80211_node *ni;
 	int error;
@@ -1152,10 +1152,35 @@
 		return;
 	}
 
+	if ((m_new = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR)) == NULL) {
+		device_printf(sc->sc_dev, "could not allocate rx mbuf\n");
+		++ifp->if_ierrors;
+		return;
+	}
+
 	bus_dmamap_unload(sc->rx_buf_dmat, buf->map);
+	m = buf->m;
+
+	error = bus_dmamap_load(sc->rx_buf_dmat, buf->map, mtod(m_new, void *),
+	    MCLBYTES, iwi_dma_map_addr, &buf->physaddr, 0);
+	if (error != 0) {
+		error = bus_dmamap_load(sc->rx_buf_dmat, buf->map,
+		    mtod(m, void *), MCLBYTES, iwi_dma_map_addr,
+		    &buf->physaddr, 0);
+		if (error) {
+			panic("%s: could not reload rx buf",
+			    device_get_name(sc->sc_dev));
+		}
+		device_printf(sc->sc_dev, "could not load rx buf DMA map\n");
+		m_freem(m_new);
+		++ifp->if_ierrors;
+		return;
+	}
+
+	CSR_WRITE_4(sc, IWI_CSR_RX_BASE + i * 4, buf->physaddr);
+	buf->m = m_new;
 
 	/* Finalize mbuf */
-	m = buf->m;
 	m->m_pkthdr.rcvif = ifp;
 	m->m_pkthdr.len = m->m_len = sizeof (struct iwi_hdr) +
 	    sizeof (struct iwi_frame) + le16toh(frame->len);
@@ -1210,23 +1235,6 @@
 		ieee80211_unref_node(&ni);
 	else
 		ieee80211_free_node(ic, ni);
-
-	buf->m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
-	if (buf->m == NULL) {
-		device_printf(sc->sc_dev, "could not allocate rx mbuf\n");
-		return;
-	}
-
-	error = bus_dmamap_load(sc->rx_buf_dmat, buf->map, mtod(buf->m, void *),
-	    MCLBYTES, iwi_dma_map_addr, &buf->physaddr, 0);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not load rx buf DMA map\n");
-		m_freem(buf->m);
-		buf->m = NULL;
-		return;
-	}
-
-	CSR_WRITE_4(sc, IWI_CSR_RX_BASE + i * 4, buf->physaddr);
 }
 
 static void


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]