Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci attach the rnd source only once even with dual-p...



details:   https://anonhg.NetBSD.org/src/rev/61c534ba8812
branches:  trunk
changeset: 362962:61c534ba8812
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Tue Jul 03 18:07:36 2018 +0000

description:
attach the rnd source only once even with dual-port adapters

diffstat:

 sys/dev/pci/if_msk.c    |  14 +++++++++-----
 sys/dev/pci/if_mskvar.h |   5 +++--
 sys/dev/pci/if_sk.c     |  11 +++++++----
 sys/dev/pci/if_skvar.h  |   5 +++--
 4 files changed, 22 insertions(+), 13 deletions(-)

diffs (127 lines):

diff -r a19654b49737 -r 61c534ba8812 sys/dev/pci/if_msk.c
--- a/sys/dev/pci/if_msk.c      Tue Jul 03 16:30:13 2018 +0000
+++ b/sys/dev/pci/if_msk.c      Tue Jul 03 18:07:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_msk.c,v 1.68 2018/07/02 06:03:13 jdolecek Exp $ */
+/* $NetBSD: if_msk.c,v 1.69 2018/07/03 18:07:36 jdolecek Exp $ */
 /*     $OpenBSD: if_msk.c,v 1.79 2009/10/15 17:54:56 deraadt Exp $     */
 
 /*
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.68 2018/07/02 06:03:13 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_msk.c,v 1.69 2018/07/03 18:07:36 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1199,8 +1199,10 @@
        else
                aprint_error_dev(self, "couldn't establish power handler\n");
 
-       rnd_attach_source(&sc->rnd_source, device_xname(sc->sk_dev),
-               RND_TYPE_NET, RND_FLAG_DEFAULT);
+       if (sc->rnd_attached++ == 0) {
+               rnd_attach_source(&sc->rnd_source, device_xname(sc->sk_dev),
+                       RND_TYPE_NET, RND_FLAG_DEFAULT);
+       }
 
        DPRINTFN(2, ("msk_attach: end\n"));
        return;
@@ -1227,7 +1229,8 @@
 
        msk_stop(ifp, 0);
 
-       rnd_detach_source(&sc->rnd_source);
+       if (--sc->rnd_attached == 0)
+               rnd_detach_source(&sc->rnd_source);
 
        callout_halt(&sc_if->sk_tick_ch, NULL);
        callout_destroy(&sc_if->sk_tick_ch);
@@ -2148,6 +2151,7 @@
        if (ifp1 != NULL && !IFQ_IS_EMPTY(&ifp1->if_snd))
                if_schedule_deferred_start(ifp1);
 
+       KASSERT(sc->rnd_attached > 0);
        rnd_add_uint32(&sc->rnd_source, status);
 
        if (sc->sk_int_mod_pending)
diff -r a19654b49737 -r 61c534ba8812 sys/dev/pci/if_mskvar.h
--- a/sys/dev/pci/if_mskvar.h   Tue Jul 03 16:30:13 2018 +0000
+++ b/sys/dev/pci/if_mskvar.h   Tue Jul 03 18:07:36 2018 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: if_mskvar.h,v 1.3 2006/12/28 16:34:42 kettenis Exp $  */
-/*     $NetBSD: if_mskvar.h,v 1.15 2018/07/02 06:03:13 jdolecek Exp $  */
+/*     $NetBSD: if_mskvar.h,v 1.16 2018/07/03 18:07:36 jdolecek Exp $  */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -209,7 +209,8 @@
        int                     sk_status_nseg;
        int                     sk_status_idx;
        int                     sk_status_own_idx;
-       krndsource_t     rnd_source;
+       u_int8_t                rnd_attached;
+       krndsource_t            rnd_source;
 };
 
 /* Softc for each logical interface */
diff -r a19654b49737 -r 61c534ba8812 sys/dev/pci/if_sk.c
--- a/sys/dev/pci/if_sk.c       Tue Jul 03 16:30:13 2018 +0000
+++ b/sys/dev/pci/if_sk.c       Tue Jul 03 18:07:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_sk.c,v 1.87 2018/06/26 06:48:01 msaitoh Exp $       */
+/*     $NetBSD: if_sk.c,v 1.88 2018/07/03 18:07:36 jdolecek Exp $      */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -115,7 +115,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.87 2018/06/26 06:48:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.88 2018/07/03 18:07:36 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1462,8 +1462,10 @@
 
        ether_ifattach(ifp, sc_if->sk_enaddr);
 
-        rnd_attach_source(&sc->rnd_source, device_xname(sc->sk_dev),
-            RND_TYPE_NET, RND_FLAG_DEFAULT);
+       if (sc->rnd_attached++ == 0) {
+               rnd_attach_source(&sc->rnd_source, device_xname(sc->sk_dev),
+                   RND_TYPE_NET, RND_FLAG_DEFAULT);
+       }
 
        if (pmf_device_register(self, NULL, sk_resume))
                pmf_class_network_register(self, ifp);
@@ -2400,6 +2402,7 @@
        if (ifp1 != NULL)
                if_schedule_deferred_start(ifp1);
 
+       KASSERT(sc->rnd_attached > 0);
        rnd_add_uint32(&sc->rnd_source, status);
 
        if (sc->sk_int_mod_pending)
diff -r a19654b49737 -r 61c534ba8812 sys/dev/pci/if_skvar.h
--- a/sys/dev/pci/if_skvar.h    Tue Jul 03 16:30:13 2018 +0000
+++ b/sys/dev/pci/if_skvar.h    Tue Jul 03 18:07:36 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_skvar.h,v 1.18 2015/04/13 16:33:25 riastradh Exp $ */
+/* $NetBSD: if_skvar.h,v 1.19 2018/07/03 18:07:36 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -200,7 +200,8 @@
        int                     sk_int_mod_pending;
        bus_dma_tag_t           sc_dmatag;
        struct sk_if_softc      *sk_if[2];
-       krndsource_t     rnd_source;
+       u_int8_t                rnd_attached;
+       krndsource_t            rnd_source;
 };
 
 /* Softc for each logical interface */



Home | Main Index | Thread Index | Old Index