Module Name:    src
Committed By:   skrll
Date:           Wed Feb 24 22:17:54 UTC 2016

Modified Files:
        src/sys/external/bsd/dwc2: dwc2.c dwc2.h
        src/sys/external/bsd/dwc2/conf: files.dwc2
        src/sys/external/bsd/dwc2/dist: dwc2_core.c dwc2_core.h dwc2_coreintr.c
            dwc2_hcd.c dwc2_hcd.h

Log Message:
Reduce diff to upstream by using

        sys/external/bsd/{include/workqueue.h,linux/linux_work.c}

This also fixes CI20 dwctwo start up as reported by macallan@


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/external/bsd/dwc2/dwc2.c
cvs rdiff -u -r1.8 -r1.9 src/sys/external/bsd/dwc2/dwc2.h
cvs rdiff -u -r1.2 -r1.3 src/sys/external/bsd/dwc2/conf/files.dwc2
cvs rdiff -u -r1.12 -r1.13 src/sys/external/bsd/dwc2/dist/dwc2_core.c \
    src/sys/external/bsd/dwc2/dist/dwc2_hcd.h
cvs rdiff -u -r1.7 -r1.8 src/sys/external/bsd/dwc2/dist/dwc2_core.h
cvs rdiff -u -r1.10 -r1.11 src/sys/external/bsd/dwc2/dist/dwc2_coreintr.c
cvs rdiff -u -r1.18 -r1.19 src/sys/external/bsd/dwc2/dist/dwc2_hcd.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/external/bsd/dwc2/dwc2.c
diff -u src/sys/external/bsd/dwc2/dwc2.c:1.40 src/sys/external/bsd/dwc2/dwc2.c:1.41
--- src/sys/external/bsd/dwc2/dwc2.c:1.40	Wed Feb 24 22:09:09 2016
+++ src/sys/external/bsd/dwc2/dwc2.c	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2.c,v 1.40 2016/02/24 22:09:09 skrll Exp $	*/
+/*	$NetBSD: dwc2.c,v 1.41 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.40 2016/02/24 22:09:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.41 2016/02/24 22:17:54 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -1453,45 +1453,6 @@ fail:
 
 }
 
-#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
-void
-dwc2_worker(struct work *wk, void *priv)
-{
-	struct dwc2_softc *sc = priv;
-	struct dwc2_hsotg *hsotg = sc->sc_hsotg;
-
-Debugger();
-#if 0
-	usbd_xfer_handle xfer = dwork->xfer;
-	struct dwc2_xfer *dxfer = DWC2_XFER2DXFER(xfer);
-
-	dwc2_hcd_endpoint_disable(sc->dwc_dev.hcd, dpipe->priv, 250);
-	dwc_free(NULL, dpipe->urb);
-#endif
-
-	mutex_enter(&sc->sc_lock);
-	if (wk == &hsotg->wf_otg) {
-		dwc2_conn_id_status_change(wk);
-	} else if (wk == &hsotg->start_work.work) {
-		dwc2_hcd_start_func(wk);
-	} else if (wk == &hsotg->reset_work.work) {
-		dwc2_hcd_reset_func(wk);
-	} else {
-#if 0
-		KASSERT(dwork->xfer != NULL);
-		KASSERT(dxfer->queued == true);
-
-		if (!(xfer->hcflags & UXFER_ABORTING)) {
-			dwc2_start_standard_chain(xfer);
-		}
-		dxfer->queued = false;
-		cv_broadcast(&xfer->hccv);
-#endif
-	}
-	mutex_exit(&sc->sc_lock);
-}
-#endif
-
 int dwc2_intr(void *p)
 {
 	struct dwc2_softc *sc = p;
@@ -1723,15 +1684,6 @@ static const char * const intnames[32] =
 
 #endif
 
-
-void
-dw_callout(void *arg)
-{
-	struct delayed_work *dw = arg;
-
-	workqueue_enqueue(dw->dw_wq, &dw->work, NULL);
-}
-
 void dwc2_host_hub_info(struct dwc2_hsotg *hsotg, void *context, int *hub_addr,
 			int *hub_port)
 {

Index: src/sys/external/bsd/dwc2/dwc2.h
diff -u src/sys/external/bsd/dwc2/dwc2.h:1.8 src/sys/external/bsd/dwc2/dwc2.h:1.9
--- src/sys/external/bsd/dwc2/dwc2.h:1.8	Fri Feb 19 21:10:18 2016
+++ src/sys/external/bsd/dwc2/dwc2.h	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2.h,v 1.8 2016/02/19 21:10:18 skrll Exp $	*/
+/*	$NetBSD: dwc2.h,v 1.9 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 #include <sys/workqueue.h>
 
 #include <linux/list.h>
+#include <linux/workqueue.h>
 
 #include "opt_usb.h"
 // #define VERBOSE_DEBUG
@@ -277,26 +278,4 @@ msleep(unsigned int msec)
 
 #define USB_RESUME_TIMEOUT	40 /* ms */
 
-void dw_callout(void *);
-void dwc2_worker(struct work *, void *);
-
-struct delayed_work {
-	struct work work;
-	struct callout dw_timer;
-
-	struct workqueue *dw_wq;
-};
-
-static inline void
-INIT_DELAYED_WORK(struct delayed_work *dw, void (*fn)(struct work *))
-{
-	callout_init(&dw->dw_timer, CALLOUT_MPSAFE);
-}
-
-static inline void
-queue_delayed_work(struct workqueue *wq, struct delayed_work *dw, int j)
-{
-	callout_reset(&dw->dw_timer, j, dw_callout, dw);
-}
-
 #endif

Index: src/sys/external/bsd/dwc2/conf/files.dwc2
diff -u src/sys/external/bsd/dwc2/conf/files.dwc2:1.2 src/sys/external/bsd/dwc2/conf/files.dwc2:1.3
--- src/sys/external/bsd/dwc2/conf/files.dwc2:1.2	Fri Sep 12 16:40:38 2014
+++ src/sys/external/bsd/dwc2/conf/files.dwc2	Wed Feb 24 22:17:54 2016
@@ -1,11 +1,12 @@
-#	$NetBSD: files.dwc2,v 1.2 2014/09/12 16:40:38 skrll Exp $
+#	$NetBSD: files.dwc2,v 1.3 2016/02/24 22:17:54 skrll Exp $
 
 # DesignWare HS OTG Controller
 #
-device dwctwo: usbus, usbroothub, usb_dma
+
+device dwctwo: usbus, usbroothub, usb_dma, linux
 file	external/bsd/dwc2/dwc2.c			dwctwo	needs-flag
 
-makeoptions	dwctwo	CPPFLAGS+=" -I$S/external/bsd/common/include -I$S/external/bsd -I$S/external/bsd/dwc2/dist"
+makeoptions	dwctwo	CPPFLAGS+="-I$S/external/bsd -I$S/external/bsd/dwc2/dist"
 
 file	external/bsd/dwc2/dist/dwc2_core.c		dwctwo
 file	external/bsd/dwc2/dist/dwc2_coreintr.c		dwctwo

Index: src/sys/external/bsd/dwc2/dist/dwc2_core.c
diff -u src/sys/external/bsd/dwc2/dist/dwc2_core.c:1.12 src/sys/external/bsd/dwc2/dist/dwc2_core.c:1.13
--- src/sys/external/bsd/dwc2/dist/dwc2_core.c:1.12	Wed Feb 24 22:14:39 2016
+++ src/sys/external/bsd/dwc2/dist/dwc2_core.c	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_core.c,v 1.12 2016/02/24 22:14:39 skrll Exp $	*/
+/*	$NetBSD: dwc2_core.c,v 1.13 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*
  * core.c - DesignWare HS OTG Controller common routines
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2_core.c,v 1.12 2016/02/24 22:14:39 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_core.c,v 1.13 2016/02/24 22:17:54 skrll Exp $");
 
 #include <sys/types.h>
 #include <sys/bus.h>
@@ -51,7 +51,6 @@ __KERNEL_RCSID(0, "$NetBSD: dwc2_core.c,
 #include <sys/callout.h>
 #include <sys/mutex.h>
 #include <sys/pool.h>
-#include <sys/workqueue.h>
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
Index: src/sys/external/bsd/dwc2/dist/dwc2_hcd.h
diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.12 src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.13
--- src/sys/external/bsd/dwc2/dist/dwc2_hcd.h:1.12	Sun Feb 14 10:53:30 2016
+++ src/sys/external/bsd/dwc2/dist/dwc2_hcd.h	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_hcd.h,v 1.12 2016/02/14 10:53:30 skrll Exp $	*/
+/*	$NetBSD: dwc2_hcd.h,v 1.13 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*
  * hcd.h - DesignWare HS OTG Controller host-mode declarations
@@ -777,10 +777,6 @@ int dwc2_hcd_urb_enqueue(struct dwc2_hso
 void dwc2_hcd_urb_set_pipeinfo(struct dwc2_hsotg *, struct dwc2_hcd_urb *,
 			       u8 ,u8, u8, u8, u16);
 
-void dwc2_conn_id_status_change(struct work *);
-void dwc2_hcd_start_func(struct work *);
-void dwc2_hcd_reset_func(struct work *);
-
 struct dwc2_hcd_urb * dwc2_hcd_urb_alloc(struct dwc2_hsotg *, int, gfp_t);
 void dwc2_hcd_urb_free(struct dwc2_hsotg *, struct dwc2_hcd_urb *, int);
 

Index: src/sys/external/bsd/dwc2/dist/dwc2_core.h
diff -u src/sys/external/bsd/dwc2/dist/dwc2_core.h:1.7 src/sys/external/bsd/dwc2/dist/dwc2_core.h:1.8
--- src/sys/external/bsd/dwc2/dist/dwc2_core.h:1.7	Sun Feb 14 10:53:30 2016
+++ src/sys/external/bsd/dwc2/dist/dwc2_core.h	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_core.h,v 1.7 2016/02/14 10:53:30 skrll Exp $	*/
+/*	$NetBSD: dwc2_core.h,v 1.8 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*
  * core.h - DesignWare HS OTG Controller common declarations
@@ -40,7 +40,6 @@
 #define __DWC2_CORE_H__
 
 #include <sys/stdint.h>
-#include <sys/workqueue.h>
 #include <sys/pool.h>
 #include <sys/queue.h>
 #include <sys/device.h>
@@ -723,8 +722,8 @@ struct dwc2_hsotg {
 	unsigned int queuing_high_bandwidth:1;
 	unsigned int srp_success:1;
 
-	struct workqueue *wq_otg;
-	struct work wf_otg;
+	struct workqueue_struct *wq_otg;
+	struct work_struct wf_otg;
 	struct callout wkp_timer;
 	enum dwc2_lx_state lx_state;
 	struct dwc2_gregs_backup gr_backup;

Index: src/sys/external/bsd/dwc2/dist/dwc2_coreintr.c
diff -u src/sys/external/bsd/dwc2/dist/dwc2_coreintr.c:1.10 src/sys/external/bsd/dwc2/dist/dwc2_coreintr.c:1.11
--- src/sys/external/bsd/dwc2/dist/dwc2_coreintr.c:1.10	Sun Feb 14 10:53:30 2016
+++ src/sys/external/bsd/dwc2/dist/dwc2_coreintr.c	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_coreintr.c,v 1.10 2016/02/14 10:53:30 skrll Exp $	*/
+/*	$NetBSD: dwc2_coreintr.c,v 1.11 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*
  * core_intr.c - DesignWare HS OTG Controller common interrupt handling
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2_coreintr.c,v 1.10 2016/02/14 10:53:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_coreintr.c,v 1.11 2016/02/24 22:17:54 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -307,7 +307,7 @@ static void dwc2_handle_conn_id_status_c
 	 */
 	if (hsotg->wq_otg) {
 		spin_unlock(&hsotg->lock);
-		workqueue_enqueue(hsotg->wq_otg, &hsotg->wf_otg, NULL);
+		queue_work(hsotg->wq_otg, &hsotg->wf_otg);
 		spin_lock(&hsotg->lock);
 	}
 }

Index: src/sys/external/bsd/dwc2/dist/dwc2_hcd.c
diff -u src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.18 src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.19
--- src/sys/external/bsd/dwc2/dist/dwc2_hcd.c:1.18	Sun Feb 14 10:53:30 2016
+++ src/sys/external/bsd/dwc2/dist/dwc2_hcd.c	Wed Feb 24 22:17:54 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2_hcd.c,v 1.18 2016/02/14 10:53:30 skrll Exp $	*/
+/*	$NetBSD: dwc2_hcd.c,v 1.19 2016/02/24 22:17:54 skrll Exp $	*/
 
 /*
  * hcd.c - DesignWare HS OTG Controller host-mode routines
@@ -42,13 +42,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v 1.18 2016/02/14 10:53:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v 1.19 2016/02/24 22:17:54 skrll Exp $");
 
 #include <sys/types.h>
 #include <sys/kmem.h>
 #include <sys/proc.h>
 #include <sys/pool.h>
-#include <sys/workqueue.h>
 
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
@@ -58,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: dwc2_hcd.c,v
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/err.h>
+#include <linux/workqueue.h>
 
 #include <dwc2/dwc2.h>
 #include <dwc2/dwc2var.h>
@@ -1365,8 +1365,7 @@ void dwc2_hcd_queue_transactions(struct 
 	}
 }
 
-void
-dwc2_conn_id_status_change(struct work *work)
+static void dwc2_conn_id_status_change(struct work_struct *work)
 {
 	struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
 						wf_otg);
@@ -1427,7 +1426,7 @@ dwc2_conn_id_status_change(struct work *
 	}
 }
 
-void dwc2_wakeup_detected(void * data)
+void dwc2_wakeup_detected(void *data)
 {
 	struct dwc2_hsotg *hsotg = (struct dwc2_hsotg *)data;
 	u32 hprt0;
@@ -2157,8 +2156,7 @@ void dwc2_host_disconnect(struct dwc2_hs
 /*
  * Work queue function for starting the HCD when A-Cable is connected
  */
-void
-dwc2_hcd_start_func(struct work *work)
+static void dwc2_hcd_start_func(struct work_struct *work)
 {
 	struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
 						start_work.work);
@@ -2170,8 +2168,7 @@ dwc2_hcd_start_func(struct work *work)
 /*
  * Reset work queue function
  */
-void
-dwc2_hcd_reset_func(struct work *work)
+static void dwc2_hcd_reset_func(struct work_struct *work)
 {
 	struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
 						reset_work.work);
@@ -2261,7 +2258,9 @@ static void dwc2_hcd_free(struct dwc2_hs
 	}
 
 	if (hsotg->wq_otg) {
-		workqueue_destroy(hsotg->wq_otg);
+		if (!cancel_work_sync(&hsotg->wf_otg))
+			flush_workqueue(hsotg->wq_otg);
+		destroy_workqueue(hsotg->wq_otg);
 	}
 
 	kmem_free(hsotg->core_params, sizeof(*hsotg->core_params));
@@ -2287,7 +2286,7 @@ int dwc2_hcd_init(struct dwc2_hsotg *hso
 {
 	struct dwc2_host_chan *channel;
 	int i, num_channels;
-	int err, retval;
+	int retval;
 
 	if (usb_disabled())
 		return -ENODEV;
@@ -2326,14 +2325,12 @@ int dwc2_hcd_init(struct dwc2_hsotg *hso
 
 	/* Create new workqueue and init work */
 	retval = -ENOMEM;
-	err = workqueue_create(&hsotg->wq_otg, "dwc2", dwc2_worker, hsotg,
-			 PRI_BIO, IPL_USB, WQ_MPSAFE);
-
-	retval = -err;
-	if (err) {
+	hsotg->wq_otg = create_singlethread_workqueue("dwc2");
+	if (!hsotg->wq_otg) {
 		dev_err(hsotg->dev, "Failed to create workqueue\n");
 		goto error2;
 	}
+	INIT_WORK(&hsotg->wf_otg, dwc2_conn_id_status_change);
 
 	callout_init(&hsotg->wkp_timer, CALLOUT_MPSAFE);
 	callout_setfunc(&hsotg->wkp_timer, dwc2_wakeup_detected, hsotg);

Reply via email to