tech-kern archive

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

Re: rbuf starvation in the iwn driver



Hi,

Attached is a minimal patch that fixes the iwn lock-ups (at least for me :-).
Please test.

Regards,
Sverre
Index: sys/dev/pci/if_iwn.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_iwn.c,v
retrieving revision 1.38
diff -u -p -r1.38 if_iwn.c
--- sys/dev/pci/if_iwn.c        5 Apr 2010 07:20:26 -0000       1.38
+++ sys/dev/pci/if_iwn.c        9 Apr 2010 13:52:24 -0000
@@ -1932,6 +1932,8 @@ iwn_rx_done(struct iwn_softc *sc, struct
        /*
         * See comment in if_wpi.c:wpi_rx_intr() about locking
         * nb_free_entries here.  In short:  it's not required.
+        * XXX please verify that this section still does not
+        * require locking!
         */
        MGETHDR(m1, M_DONTWAIT, MT_DATA);
        if (m1 == NULL) {
@@ -1939,17 +1941,22 @@ iwn_rx_done(struct iwn_softc *sc, struct
                ifp->if_ierrors++;
                return;
        }
-       if (sc->rxq.nb_free_entries <= 0) {
+       if (sc->rxq.nb_free_entries > 0) {
+               rbuf = iwn_alloc_rbuf(sc);
+               /* Attach RX buffer to mbuf header. */
+               MEXTADD(m1, rbuf->vaddr, IWN_RBUF_SIZE, 0, iwn_free_rbuf,
+                   rbuf);
+               m1->m_flags |= M_EXT_RW;
+       }
+       else
+               MEXTMALLOC(m1, IWN_RBUF_SIZE, M_DONTWAIT);
+
+       if (m1 == NULL) {
                ic->ic_stats.is_rx_nobuf++;
                ifp->if_ierrors++;
                m_freem(m1);
                return;
        }
-       rbuf = iwn_alloc_rbuf(sc);
-       /* Attach RX buffer to mbuf header. */
-       MEXTADD(m1, rbuf->vaddr, IWN_RBUF_SIZE, 0, iwn_free_rbuf,
-           rbuf);
-       m1->m_flags |= M_EXT_RW;
        bus_dmamap_unload(sc->sc_dmat, data->map);
 
        error = bus_dmamap_load(sc->sc_dmat, data->map, m1->m_ext.ext_buf,


Home | Main Index | Thread Index | Old Index