Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/dwc2 - dwc2 need calling linux_workqueue_in...



details:   https://anonhg.NetBSD.org/src/rev/81c690c391b4
branches:  trunk
changeset: 997679:81c690c391b4
user:      ryo <ryo%NetBSD.org@localhost>
date:      Tue Mar 19 08:17:46 2019 +0000

description:
- dwc2 need calling linux_workqueue_init() to avoid panic.
- use INIT_ONCE/FINI_ONCE to linux_workqueue_{init,fini}() for being called from dwc2.

TODO: dwc2 should be written as kernel module depenging on a linux module.

diffstat:

 sys/external/bsd/common/linux/linux_work.c |  39 +++++++++++++++++++++++++----
 sys/external/bsd/dwc2/dwc2.c               |   8 ++++-
 2 files changed, 39 insertions(+), 8 deletions(-)

diffs (110 lines):

diff -r c569926073cb -r 81c690c391b4 sys/external/bsd/common/linux/linux_work.c
--- a/sys/external/bsd/common/linux/linux_work.c        Tue Mar 19 08:16:51 2019 +0000
+++ b/sys/external/bsd/common/linux/linux_work.c        Tue Mar 19 08:17:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_work.c,v 1.43 2018/08/27 15:25:43 riastradh Exp $        */
+/*     $NetBSD: linux_work.c,v 1.44 2019/03/19 08:17:46 ryo Exp $      */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.43 2018/08/27 15:25:43 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.44 2019/03/19 08:17:46 ryo Exp $");
 
 #include <sys/types.h>
 #include <sys/atomic.h>
@@ -41,6 +41,9 @@
 #include <sys/kthread.h>
 #include <sys/lwp.h>
 #include <sys/mutex.h>
+#ifndef _MODULE
+#include <sys/once.h>
+#endif
 #include <sys/queue.h>
 #include <sys/sdt.h>
 
@@ -130,8 +133,8 @@
  *     Initialize the Linux workqueue subsystem.  Return 0 on success,
  *     NetBSD error on failure.
  */
-int
-linux_workqueue_init(void)
+static int
+linux_workqueue_init0(void)
 {
        int error;
 
@@ -173,8 +176,8 @@
  *
  *     Destroy the Linux workqueue subsystem.  Never fails.
  */
-void
-linux_workqueue_fini(void)
+static void
+linux_workqueue_fini0(void)
 {
 
        destroy_workqueue(system_power_efficient_wq);
@@ -182,6 +185,30 @@
        destroy_workqueue(system_wq);
        lwp_specific_key_delete(workqueue_key);
 }
+
+#ifndef _MODULE
+static ONCE_DECL(linux_workqueue_init_once);
+#endif
+
+int
+linux_workqueue_init(void)
+{
+#ifdef _MODULE
+       return linux_workqueue_init0();
+#else
+       return INIT_ONCE(&linux_workqueue_init_once, &linux_workqueue_init0);
+#endif
+}
+
+void
+linux_workqueue_fini(void)
+{
+#ifdef _MODULE
+       return linux_workqueue_fini0();
+#else
+       return FINI_ONCE(&linux_workqueue_init_once, &linux_workqueue_fini0);
+#endif
+}
 
 /*
  * Workqueues
diff -r c569926073cb -r 81c690c391b4 sys/external/bsd/dwc2/dwc2.c
--- a/sys/external/bsd/dwc2/dwc2.c      Tue Mar 19 08:16:51 2019 +0000
+++ b/sys/external/bsd/dwc2/dwc2.c      Tue Mar 19 08:17:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dwc2.c,v 1.58 2019/02/17 04:17:52 rin Exp $    */
+/*     $NetBSD: dwc2.c,v 1.59 2019/03/19 08:17:46 ryo Exp $    */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.58 2019/02/17 04:17:52 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.59 2019/03/19 08:17:46 ryo Exp $");
 
 #include "opt_usb.h"
 
@@ -1273,6 +1273,10 @@
 {
        int err = 0;
 
+       err = linux_workqueue_init();
+       if (err)
+               return err;
+
        sc->sc_bus.ub_hcpriv = sc;
        sc->sc_bus.ub_revision = USBREV_2_0;
        sc->sc_bus.ub_methods = &dwc2_bus_methods;



Home | Main Index | Thread Index | Old Index