Source-Changes-HG archive

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

[src/netbsd-3]: src/sys/arch/xen/xen Pull up revision 1.24 (requested by bouy...



details:   https://anonhg.NetBSD.org/src/rev/21688a57df79
branches:  netbsd-3
changeset: 575883:21688a57df79
user:      riz <riz%NetBSD.org@localhost>
date:      Fri May 27 23:03:59 2005 +0000

description:
Pull up revision 1.24 (requested by bouyer in ticket #326):
Reorder the receive code to avoid a possible race with the sc_rx->event
stuff, and fix a possible infinite loop in case of ressource shortage.

diffstat:

 sys/arch/xen/xen/if_xennet.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (53 lines):

diff -r e9cb69ef0041 -r 21688a57df79 sys/arch/xen/xen/if_xennet.c
--- a/sys/arch/xen/xen/if_xennet.c      Fri May 27 23:00:34 2005 +0000
+++ b/sys/arch/xen/xen/if_xennet.c      Fri May 27 23:03:59 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_xennet.c,v 1.13.2.8 2005/04/28 10:28:53 tron Exp $  */
+/*     $NetBSD: if_xennet.c,v 1.13.2.9 2005/05/27 23:03:59 riz Exp $   */
 
 /*
  *
@@ -33,7 +33,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.13.2.8 2005/04/28 10:28:53 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet.c,v 1.13.2.9 2005/05/27 23:03:59 riz Exp $");
 
 #include "opt_inet.h"
 #include "rnd.h"
@@ -648,7 +648,7 @@
        struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        netif_rx_response_t *rx;
        paddr_t pa;
-       NETIF_RING_IDX ringidx;
+       NETIF_RING_IDX ringidx, resp_prod;
        mmu_update_t *mmu = rx_mmu;
        multicall_entry_t *mcl = rx_mcl;
        struct mbuf *m;
@@ -660,8 +660,10 @@
 #endif
 
  again:
+       resp_prod = sc->sc_rx->resp_prod;
+       x86_lfence(); /* ensure we see all requests up to resp_prod */
        for (ringidx = sc->sc_rx_resp_cons;
-            ringidx != sc->sc_rx->resp_prod;
+            ringidx != resp_prod;
             ringidx++) {
                rx = &sc->sc_rx->ring[MASK_NETIF_RX_IDX(ringidx)].resp;
 
@@ -764,9 +766,11 @@
        }
 
        sc->sc_rx_resp_cons = ringidx;
-       sc->sc_rx->event = sc->sc_rx_resp_cons + 1;
+       sc->sc_rx->event = resp_prod + 1;
+       x86_lfence();
+         /* ensure backend see the new sc_rx->event before we start again */
 
-       if (sc->sc_rx->resp_prod != ringidx)
+       if (sc->sc_rx->resp_prod != resp_prod)
                goto again;
 
        return 0;



Home | Main Index | Thread Index | Old Index