Module Name: src Committed By: jym Date: Mon Apr 25 00:00:50 UTC 2011
Modified Files: src/sys/arch/xen/xen: if_xennet_xenbus.c Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/xen/xen/if_xennet_xenbus.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.48 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.49 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.48 Wed Mar 30 18:33:05 2011 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Mon Apr 25 00:00:50 2011 @@ -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;