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 attach rndsource until it's actually ready...



details:   https://anonhg.NetBSD.org/src/rev/bf8309280451
branches:  trunk
changeset: 1009651:bf8309280451
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Apr 30 03:24:15 2020 +0000

description:
Don't attach rndsource until it's actually ready to run.

diffstat:

 sys/dev/pci/amdpm.c    |  14 +++++++-------
 sys/dev/pci/hifn7751.c |  18 +++++++++---------
 sys/dev/pci/ubsec.c    |  16 +++++++++-------
 3 files changed, 25 insertions(+), 23 deletions(-)

diffs (134 lines):

diff -r 9485d8c7d866 -r bf8309280451 sys/dev/pci/amdpm.c
--- a/sys/dev/pci/amdpm.c       Thu Apr 30 01:52:08 2020 +0000
+++ b/sys/dev/pci/amdpm.c       Thu Apr 30 03:24:15 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amdpm.c,v 1.39 2015/04/13 16:33:25 riastradh Exp $     */
+/*     $NetBSD: amdpm.c,v 1.40 2020/04/30 03:24:15 riastradh Exp $     */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amdpm.c,v 1.39 2015/04/13 16:33:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amdpm.c,v 1.40 2020/04/30 03:24:15 riastradh Exp $");
 
 #include "opt_amdpm.h"
 
@@ -191,11 +191,6 @@
                            "random number generator enabled (apprx. %dms)\n",
                            i);
                        callout_init(&sc->sc_rnd_ch, CALLOUT_MPSAFE);
-                       rndsource_setcb(&sc->sc_rnd_source,
-                                       amdpm_rnd_get, sc);
-                       rnd_attach_source(&sc->sc_rnd_source,
-                           device_xname(self), RND_TYPE_RNG,
-                           RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
 #ifdef AMDPM_RND_COUNTERS
                        evcnt_attach_dynamic(&sc->sc_rnd_hits, EVCNT_TYPE_MISC,
                            NULL, device_xname(self), "rnd hits");
@@ -207,6 +202,11 @@
                                    "rnd data");
                        }
 #endif
+                       rndsource_setcb(&sc->sc_rnd_source,
+                                       amdpm_rnd_get, sc);
+                       rnd_attach_source(&sc->sc_rnd_source,
+                           device_xname(self), RND_TYPE_RNG,
+                           RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
                        sc->sc_rnd_need = RND_POOLBITS / NBBY;
                        amdpm_rnd_callout(sc);
                }
diff -r 9485d8c7d866 -r bf8309280451 sys/dev/pci/hifn7751.c
--- a/sys/dev/pci/hifn7751.c    Thu Apr 30 01:52:08 2020 +0000
+++ b/sys/dev/pci/hifn7751.c    Thu Apr 30 03:24:15 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hifn7751.c,v 1.65 2020/02/29 16:36:25 mlelstv Exp $    */
+/*     $NetBSD: hifn7751.c,v 1.66 2020/04/30 03:24:15 riastradh Exp $  */
 /*     $FreeBSD: hifn7751.c,v 1.5.2.7 2003/10/08 23:52:00 sam Exp $ */
 /*     $OpenBSD: hifn7751.c,v 1.140 2003/08/01 17:55:54 deraadt Exp $  */
 
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.65 2020/02/29 16:36:25 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hifn7751.c,v 1.66 2020/04/30 03:24:15 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -595,13 +595,6 @@
                 */
                DELAY(4000);
 
-#ifdef __NetBSD__
-               rndsource_setcb(&sc->sc_rnd_source, hifn_rng_get, sc);
-               rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv),
-                                 RND_TYPE_RNG,
-                                 RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-#endif
-
                if (hz >= 100)
                        sc->sc_rnghz = hz / 100;
                else
@@ -611,6 +604,13 @@
 #else  /* !__OpenBSD__ */
                callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
 #endif /* !__OpenBSD__ */
+
+#ifdef __NetBSD__
+               rndsource_setcb(&sc->sc_rnd_source, hifn_rng_get, sc);
+               rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dv),
+                                 RND_TYPE_RNG,
+                                 RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
+#endif
        }
 
        /* Enable public key engine, if available */
diff -r 9485d8c7d866 -r bf8309280451 sys/dev/pci/ubsec.c
--- a/sys/dev/pci/ubsec.c       Thu Apr 30 01:52:08 2020 +0000
+++ b/sys/dev/pci/ubsec.c       Thu Apr 30 03:24:15 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ubsec.c,v 1.48 2020/03/16 21:20:09 pgoyette Exp $      */
+/*     $NetBSD: ubsec.c,v 1.49 2020/04/30 03:24:15 riastradh Exp $     */
 /* $FreeBSD: src/sys/dev/ubsec/ubsec.c,v 1.6.2.6 2003/01/23 21:06:43 sam Exp $ */
 /*     $OpenBSD: ubsec.c,v 1.143 2009/03/27 13:31:30 reyk Exp$ */
 
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.48 2020/03/16 21:20:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ubsec.c,v 1.49 2020/04/30 03:24:15 riastradh Exp $");
 
 #undef UBSEC_DEBUG
 
@@ -501,11 +501,6 @@
                        ubsec_dma_free(sc, &sc->sc_rng.rng_q.q_mcr);
                        goto skip_rng;
                }
-
-               rndsource_setcb(&sc->sc_rnd_source, ubsec_rng_get, sc);
-               rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
-                                 RND_TYPE_RNG,
-                                 RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
                if (hz >= 100)
                        sc->sc_rnghz = hz / 100;
                else
@@ -516,8 +511,15 @@
 #else
                callout_init(&sc->sc_rngto, 0);
                callout_setfunc(&sc->sc_rngto, ubsec_rng, sc);
+#endif
+               rndsource_setcb(&sc->sc_rnd_source, ubsec_rng_get, sc);
+               rnd_attach_source(&sc->sc_rnd_source, device_xname(sc->sc_dev),
+                                 RND_TYPE_RNG,
+                                 RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
+#ifdef __NetBSD__
                callout_schedule(&sc->sc_rngto, sc->sc_rnghz);
 #endif
+
  skip_rng:
                if (sc->sc_rnghz)
                        aprint_normal_dev(self,



Home | Main Index | Thread Index | Old Index