Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Don't use config_deferred_interrupts() for vioif...



details:   https://anonhg.NetBSD.org/src/rev/2d91e5475f41
branches:  trunk
changeset: 331520:2d91e5475f41
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Aug 13 14:35:46 2014 +0000

description:
Don't use config_deferred_interrupts() for vioif_deferred_init(),
just run it once as part of if_init().  The problem with the former
is that it will execute the deferred init routine in-place when !cold,
and since vioif_deferred_init() finishing depends on virtio interrupts
which are established only after config_deferred_interrupts() is called,
the vioif attach method would deadlock when !cold.

diffstat:

 sys/dev/pci/if_vioif.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r fb6687058c9e -r 2d91e5475f41 sys/dev/pci/if_vioif.c
--- a/sys/dev/pci/if_vioif.c    Wed Aug 13 14:13:04 2014 +0000
+++ b/sys/dev/pci/if_vioif.c    Wed Aug 13 14:35:46 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_vioif.c,v 1.7 2014/07/22 02:21:50 ozaki-r Exp $     */
+/*     $NetBSD: if_vioif.c,v 1.8 2014/08/13 14:35:46 pooka Exp $       */
 
 /*
  * Copyright (c) 2010 Minoura Makoto.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.7 2014/07/22 02:21:50 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.8 2014/08/13 14:35:46 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -155,7 +155,7 @@
 
        uint8_t                 sc_mac[ETHER_ADDR_LEN];
        struct ethercom         sc_ethercom;
-       short                   sc_ifflags;
+       short                   sc_deferred_init_done;
 
        /* bus_dmamem */
        bus_dma_segment_t       sc_hdr_segs[1];
@@ -602,8 +602,6 @@
 
        if (vioif_alloc_mems(sc) < 0)
                goto err;
-       if (vsc->sc_nvqs == 3)
-               config_interrupts(self, vioif_deferred_init);
 
        strlcpy(ifp->if_xname, device_xname(self), IFNAMSIZ);
        ifp->if_softc = sc;
@@ -670,6 +668,14 @@
 
        vioif_stop(ifp, 0);
 
+       if (!sc->sc_deferred_init_done) {
+               struct virtio_softc *vsc = sc->sc_virtio;
+
+               sc->sc_deferred_init_done = 1;
+               if (vsc->sc_nvqs == 3)
+                       vioif_deferred_init(sc->sc_dev);
+       }
+
        /* Have to set false before vioif_populate_rx_mbufs */
        sc->sc_stopping = false;
 



Home | Main Index | Thread Index | Old Index