Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen/xen Separate xennet(4) backend initialization c...



details:   https://anonhg.NetBSD.org/src/rev/45ed46221fcc
branches:  trunk
changeset: 764474:45ed46221fcc
user:      jym <jym%NetBSD.org@localhost>
date:      Mon Apr 25 00:00:50 2011 +0000

description:
Separate xennet(4) backend initialization code ("resume") from the part
that talks with Xenstore to query backend's information. Resuming is now
performed just after xennet(4) attachment instead of waiting for backend
to announce its features in Xenstore and change it state.

This fixes the race observed by Urban Boquist when the domU boots with
root on NFS.

FWIW, the boot code (when root is NFS-backed) can innit() the xennet(4)
interface very early: it tried to access ifnet structures that were not
yet allocated.

Will ask for a pullup. Thanks to Urban for reporting the issue and
investigate it. Confirmed fixed. No regression observed by me for
dynamic attach/detach of xvif(4) and xennet(4) interfaces.

See also http://mail-index.netbsd.org/port-xen/2011/04/18/msg006647.html

diffstat:

 sys/arch/xen/xen/if_xennet_xenbus.c |  24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diffs (77 lines):

diff -r bccfb68738eb -r 45ed46221fcc sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c       Sun Apr 24 22:24:14 2011 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c       Mon Apr 25 00:00:50 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.48 2011/03/30 18:33:05 jym Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.49 2011/04/25 00:00:50 jym Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -85,7 +85,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.48 2011/03/30 18:33:05 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.49 2011/04/25 00:00:50 jym Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -224,6 +224,7 @@
 static void xennet_tx_complete(struct xennet_xenbus_softc *);
 static void xennet_rx_mbuf_free(struct mbuf *, void *, size_t, void *);
 static int  xennet_handler(void *);
+static int  xennet_talk_to_backend(struct xennet_xenbus_softc *);
 #ifdef XENNET_DEBUG_DUMP
 static void xennet_hex_dump(const unsigned char *, size_t, const char *, int);
 #endif
@@ -372,6 +373,9 @@
        rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
            RND_TYPE_NET, 0);
 #endif
+
+       /* resume shared structures and tell backend that we are ready */
+       xennet_xenbus_resume(sc);
 }
 
 static int
@@ -432,13 +436,10 @@
 xennet_xenbus_resume(void *p)
 {
        struct xennet_xenbus_softc *sc = p;
-       struct xenbus_transaction *xbt;
-       unsigned long rx_copy;
        int error;
        netif_tx_sring_t *tx_ring;
        netif_rx_sring_t *rx_ring;
        paddr_t ma;
-       const char *errmsg;
 
        sc->sc_tx_ring_gntref = GRANT_INVALID_REF;
        sc->sc_rx_ring_gntref = GRANT_INVALID_REF;
@@ -472,6 +473,17 @@
        event_set_handler(sc->sc_evtchn, &xennet_handler, sc,
            IPL_NET, device_xname(sc->sc_dev));
 
+       return 0;
+}
+
+static int
+xennet_talk_to_backend(struct xennet_xenbus_softc *sc)
+{
+       int error;
+       unsigned long rx_copy;
+       struct xenbus_transaction *xbt;
+       const char *errmsg;
+
        error = xenbus_read_ul(NULL, sc->sc_xbusd->xbusd_otherend,
            "feature-rx-copy", &rx_copy, 10);
        if (error)
@@ -558,7 +570,7 @@
                xenbus_switch_state(sc->sc_xbusd, NULL, XenbusStateClosed);
                break;
        case XenbusStateInitWait:
-               if (xennet_xenbus_resume(sc) == 0)
+               if (xennet_talk_to_backend(sc) == 0)
                        xenbus_switch_state(sc->sc_xbusd, NULL,
                            XenbusStateConnected);
                break;



Home | Main Index | Thread Index | Old Index