Module Name: src Committed By: ozaki-r Date: Wed Dec 24 02:48:24 UTC 2014
Modified Files: src/sys/dev/pci: if_vioif.c Log Message: Take TX/RX locks when sc_stopping = true in if_stop Taking the locks is needed to ensure ongoing TX/RX operations finish. Otherwise, if_stop may run during TX/RX operations. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/pci/if_vioif.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/dev/pci/if_vioif.c diff -u src/sys/dev/pci/if_vioif.c:1.12 src/sys/dev/pci/if_vioif.c:1.13 --- src/sys/dev/pci/if_vioif.c:1.12 Fri Dec 19 06:54:40 2014 +++ src/sys/dev/pci/if_vioif.c Wed Dec 24 02:48:24 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: if_vioif.c,v 1.12 2014/12/19 06:54:40 ozaki-r Exp $ */ +/* $NetBSD: if_vioif.c,v 1.13 2014/12/24 02:48:24 ozaki-r Exp $ */ /* * Copyright (c) 2010 Minoura Makoto. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.12 2014/12/19 06:54:40 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.13 2014/12/24 02:48:24 ozaki-r Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -707,7 +707,12 @@ vioif_stop(struct ifnet *ifp, int disabl struct vioif_softc *sc = ifp->if_softc; struct virtio_softc *vsc = sc->sc_virtio; + /* Take the locks to ensure that ongoing TX/RX finish */ + VIOIF_TX_LOCK(sc); + VIOIF_RX_LOCK(sc); sc->sc_stopping = true; + VIOIF_RX_UNLOCK(sc); + VIOIF_TX_UNLOCK(sc); /* only way to stop I/O and DMA is resetting... */ virtio_reset(vsc);