Module Name: src Committed By: bouyer Date: Thu May 19 21:11:15 UTC 2011
Modified Files: src/sys/arch/xen/xen [netbsd-5]: if_xennet_xenbus.c Log Message: Pull up following revision(s) (requested by jym in ticket #1608): sys/arch/xen/xen/if_xennet_xenbus.c: revision 1.49 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.29.2.4 -r1.29.2.5 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.29.2.4 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.5 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.29.2.4 Sun Nov 21 23:55:58 2010 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Thu May 19 21:11:15 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.4 2010/11/21 23:55:58 riz Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.29.2.5 2011/05/19 21:11:15 bouyer Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.4 2010/11/21 23:55:58 riz Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.29.2.5 2011/05/19 21:11:15 bouyer Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -203,6 +203,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 @@ -350,6 +351,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 @@ -410,13 +414,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; @@ -450,6 +451,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) @@ -529,7 +541,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;