Module Name:    src
Committed By:   skrll
Date:           Fri May  6 13:03:06 UTC 2016

Modified Files:
        src/sys/dev/usb: ehci.c motg.c ohci.c uhci.c
        src/sys/external/bsd/dwc2: dwc2.c

Log Message:
usb is attached with config_interrupts so we can G/C the code to support
transfers when this wasn't the case.


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/usb/motg.c
cvs rdiff -u -r1.260 -r1.261 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.270 -r1.271 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.42 -r1.43 src/sys/external/bsd/dwc2/dwc2.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/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.249 src/sys/dev/usb/ehci.c:1.250
--- src/sys/dev/usb/ehci.c:1.249	Sat Apr 23 10:15:31 2016
+++ src/sys/dev/usb/ehci.c	Fri May  6 13:03:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ehci.c,v 1.249 2016/04/23 10:15:31 skrll Exp $ */
+/*	$NetBSD: ehci.c,v 1.250 2016/05/06 13:03:06 skrll Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.249 2016/04/23 10:15:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.250 2016/05/06 13:03:06 skrll Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -159,7 +159,6 @@ Static usbd_status	ehci_open(struct usbd
 Static void		ehci_poll(struct usbd_bus *);
 Static void		ehci_softintr(void *);
 Static int		ehci_intr1(ehci_softc_t *);
-Static void		ehci_waitintr(ehci_softc_t *, struct usbd_xfer *);
 Static void		ehci_check_qh_intr(ehci_softc_t *, struct ehci_xfer *,
 			    ex_completeq_t *);
 Static void		ehci_check_itd_intr(ehci_softc_t *, struct ehci_xfer *,
@@ -1279,48 +1278,6 @@ ehci_idone(struct ehci_xfer *ex, ex_comp
 	DPRINTF("ex=%p done", ex, 0, 0, 0);
 }
 
-/*
- * Wait here until controller claims to have an interrupt.
- * Then call ehci_intr and return.  Use timeout to avoid waiting
- * too long.
- */
-Static void
-ehci_waitintr(ehci_softc_t *sc, struct usbd_xfer *xfer)
-{
-	int timo;
-	uint32_t intrs;
-
-	EHCIHIST_FUNC(); EHCIHIST_CALLED();
-
-	xfer->ux_status = USBD_IN_PROGRESS;
-	for (timo = xfer->ux_timeout; timo >= 0; timo--) {
-		usb_delay_ms(&sc->sc_bus, 1);
-		if (sc->sc_dying)
-			break;
-		intrs = EHCI_STS_INTRS(EOREAD4(sc, EHCI_USBSTS)) &
-			sc->sc_eintrs;
-		DPRINTF("0x%04x", intrs, 0, 0, 0);
-#ifdef EHCI_DEBUG
-		if (ehcidebug >= 15)
-			ehci_dump_regs(sc);
-#endif
-		if (intrs) {
-			mutex_spin_enter(&sc->sc_intr_lock);
-			ehci_intr1(sc);
-			mutex_spin_exit(&sc->sc_intr_lock);
-			if (xfer->ux_status != USBD_IN_PROGRESS)
-				return;
-		}
-	}
-
-	/* Timeout */
-	DPRINTF("timeout", 0, 0, 0, 0);
-	xfer->ux_status = USBD_TIMEOUT;
-	mutex_enter(&sc->sc_lock);
-	usb_transfer_complete(xfer);
-	mutex_exit(&sc->sc_lock);
-}
-
 Static void
 ehci_poll(struct usbd_bus *bus)
 {
@@ -3704,9 +3661,6 @@ ehci_device_ctrl_start(struct usbd_xfer 
 #endif
 #endif
 
-	if (sc->sc_bus.ub_usepolling)
-		ehci_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -3909,9 +3863,6 @@ ehci_device_bulk_start(struct usbd_xfer 
 #endif
 #endif
 
-	if (sc->sc_bus.ub_usepolling)
-		ehci_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -4123,9 +4074,6 @@ ehci_device_intr_start(struct usbd_xfer 
 #endif
 #endif
 
-	if (sc->sc_bus.ub_usepolling)
-		ehci_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -4509,11 +4457,6 @@ ehci_device_fs_isoc_transfer(struct usbd
 
 	mutex_exit(&sc->sc_lock);
 
-	if (sc->sc_bus.ub_usepolling) {
-		printf("Starting ehci isoc xfer with polling. Bad idea?\n");
-		ehci_waitintr(sc, xfer);
-	}
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -4908,11 +4851,6 @@ ehci_device_isoc_transfer(struct usbd_xf
 
 	mutex_exit(&sc->sc_lock);
 
-	if (sc->sc_bus.ub_usepolling) {
-		printf("Starting ehci isoc xfer with polling. Bad idea?\n");
-		ehci_waitintr(sc, xfer);
-	}
-
 	return USBD_IN_PROGRESS;
 }
 

Index: src/sys/dev/usb/motg.c
diff -u src/sys/dev/usb/motg.c:1.15 src/sys/dev/usb/motg.c:1.16
--- src/sys/dev/usb/motg.c:1.15	Sat Apr 23 18:54:42 2016
+++ src/sys/dev/usb/motg.c	Fri May  6 13:03:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: motg.c,v 1.15 2016/04/23 18:54:42 skrll Exp $	*/
+/*	$NetBSD: motg.c,v 1.16 2016/05/06 13:03:06 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012, 2014 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.15 2016/04/23 18:54:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: motg.c,v 1.16 2016/05/06 13:03:06 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_motg.h"
@@ -179,7 +179,6 @@ static void		motg_device_intr_tx(struct 
 static void		motg_device_data_read(struct usbd_xfer *);
 static void		motg_device_data_write(struct usbd_xfer *);
 
-static void		motg_waitintr(struct motg_softc *, struct usbd_xfer *);
 static void		motg_device_clear_toggle(struct usbd_pipe *);
 static void		motg_device_xfer_abort(struct usbd_xfer *);
 
@@ -1286,8 +1285,6 @@ motg_device_ctrl_start(struct usbd_xfer 
 	mutex_exit(&sc->sc_lock);
 	if (err != USBD_IN_PROGRESS)
 		return err;
-	if (sc->sc_bus.ub_usepolling)
-		motg_waitintr(sc, xfer);
 	return USBD_IN_PROGRESS;
 }
 
@@ -1727,8 +1724,6 @@ motg_device_data_start(struct usbd_xfer 
 	mutex_exit(&sc->sc_lock);
 	if (err != USBD_IN_PROGRESS)
 		return err;
-	if (sc->sc_bus.ub_usepolling)
-		motg_waitintr(sc, xfer);
 	return USBD_IN_PROGRESS;
 }
 
@@ -2155,42 +2150,6 @@ motg_device_data_done(struct usbd_xfer *
 	KASSERT(otgpipe->hw_ep->xfer != xfer);
 }
 
-/*
- * Wait here until controller claims to have an interrupt.
- * Then call motg_intr and return.  Use timeout to avoid waiting
- * too long.
- * Only used during boot when interrupts are not enabled yet.
- */
-void
-motg_waitintr(struct motg_softc *sc, struct usbd_xfer *xfer)
-{
-	int timo = xfer->ux_timeout;
-	MOTGHIST_FUNC(); MOTGHIST_CALLED();
-
-	mutex_enter(&sc->sc_lock);
-
-	DPRINTF("timeout = %dms", timo, 0, 0, 0);
-
-	for (; timo >= 0; timo--) {
-		mutex_exit(&sc->sc_lock);
-		usb_delay_ms(&sc->sc_bus, 1);
-		mutex_spin_enter(&sc->sc_intr_lock);
-		motg_poll(&sc->sc_bus);
-		mutex_spin_exit(&sc->sc_intr_lock);
-		mutex_enter(&sc->sc_lock);
-		if (xfer->ux_status != USBD_IN_PROGRESS)
-			goto done;
-	}
-
-	/* Timeout */
-	DPRINTF("timeout", 0, 0, 0, 0);
-	panic("motg_waitintr: timeout");
-	/* XXX handle timeout ! */
-
-done:
-	mutex_exit(&sc->sc_lock);
-}
-
 void
 motg_device_clear_toggle(struct usbd_pipe *pipe)
 {

Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.260 src/sys/dev/usb/ohci.c:1.261
--- src/sys/dev/usb/ohci.c:1.260	Sat Apr 23 10:15:32 2016
+++ src/sys/dev/usb/ohci.c	Fri May  6 13:03:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ohci.c,v 1.260 2016/04/23 10:15:32 skrll Exp $	*/
+/*	$NetBSD: ohci.c,v 1.261 2016/05/06 13:03:06 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2005, 2012 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.260 2016/04/23 10:15:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.261 2016/05/06 13:03:06 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -146,7 +146,6 @@ Static void		ohci_reset_std_chain(ohci_s
 Static usbd_status	ohci_open(struct usbd_pipe *);
 Static void		ohci_poll(struct usbd_bus *);
 Static void		ohci_softintr(void *);
-Static void		ohci_waitintr(ohci_softc_t *, struct usbd_xfer *);
 Static void		ohci_rhsc(ohci_softc_t *, struct usbd_xfer *);
 Static void		ohci_rhsc_softint(void *);
 
@@ -1705,49 +1704,6 @@ ohci_root_intr_done(struct usbd_xfer *xf
 	sc->sc_intrxfer = NULL;
 }
 
-/*
- * Wait here until controller claims to have an interrupt.
- * Then call ohci_intr and return.  Use timeout to avoid waiting
- * too long.
- */
-void
-ohci_waitintr(ohci_softc_t *sc, struct usbd_xfer *xfer)
-{
-	int timo;
-	uint32_t intrs;
-	OHCIHIST_FUNC(); OHCIHIST_CALLED();
-
-	mutex_enter(&sc->sc_lock);
-
-	xfer->ux_status = USBD_IN_PROGRESS;
-	for (timo = xfer->ux_timeout; timo >= 0; timo--) {
-		usb_delay_ms(&sc->sc_bus, 1);
-		if (sc->sc_dying)
-			break;
-		intrs = OREAD4(sc, OHCI_INTERRUPT_STATUS) & sc->sc_eintrs;
-		DPRINTFN(15, "intrs 0x%04x", intrs, 0, 0, 0);
-#ifdef OHCI_DEBUG
-		if (ohcidebug > 15)
-			ohci_dumpregs(sc);
-#endif
-		if (intrs) {
-			mutex_spin_enter(&sc->sc_intr_lock);
-			ohci_intr1(sc);
-			mutex_spin_exit(&sc->sc_intr_lock);
-			if (xfer->ux_status != USBD_IN_PROGRESS)
-				goto done;
-		}
-	}
-
-	/* Timeout */
-	DPRINTF("timeout", 0, 0, 0, 0);
-	xfer->ux_status = USBD_TIMEOUT;
-	usb_transfer_complete(xfer);
-
-done:
-	mutex_exit(&sc->sc_lock);
-}
-
 void
 ohci_poll(struct usbd_bus *bus)
 {
@@ -2882,9 +2838,6 @@ ohci_device_ctrl_start(struct usbd_xfer 
 
 	mutex_exit(&sc->sc_lock);
 
-	if (sc->sc_bus.ub_usepolling)
-		ohci_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 

Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.270 src/sys/dev/usb/uhci.c:1.271
--- src/sys/dev/usb/uhci.c:1.270	Mon Apr 25 20:06:51 2016
+++ src/sys/dev/usb/uhci.c	Fri May  6 13:03:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhci.c,v 1.270 2016/04/25 20:06:51 joerg Exp $	*/
+/*	$NetBSD: uhci.c,v 1.271 2016/05/06 13:03:06 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998, 2004, 2011, 2012 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.270 2016/04/25 20:06:51 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.271 2016/05/06 13:03:06 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -188,7 +188,6 @@ Static void		uhci_reset_std_chain(uhci_s
 			    int, int, int *, uhci_soft_td_t **);
 
 Static void		uhci_poll_hub(void *);
-Static void		uhci_waitintr(uhci_softc_t *, struct usbd_xfer *);
 Static void		uhci_check_intr(uhci_softc_t *, struct uhci_xfer *,
 			    ux_completeq_t *);
 Static void		uhci_idone(struct uhci_xfer *, ux_completeq_t *);
@@ -1736,52 +1735,6 @@ uhci_timeout_task(void *addr)
 	mutex_exit(&sc->sc_lock);
 }
 
-/*
- * Wait here until controller claims to have an interrupt.
- * Then call uhci_intr and return.  Use timeout to avoid waiting
- * too long.
- * Only used during boot when interrupts are not enabled yet.
- */
-void
-uhci_waitintr(uhci_softc_t *sc, struct usbd_xfer *xfer)
-{
-	int timo = xfer->ux_timeout;
-	struct uhci_xfer *ux;
-
-	mutex_enter(&sc->sc_lock);
-
-	UHCIHIST_FUNC(); UHCIHIST_CALLED();
-	DPRINTFN(10, "timeout = %dms", timo, 0, 0, 0);
-
-	xfer->ux_status = USBD_IN_PROGRESS;
-	for (; timo >= 0; timo--) {
-		usb_delay_ms_locked(&sc->sc_bus, 1, &sc->sc_lock);
-		DPRINTFN(20, "0x%04x",
-		    UREAD2(sc, UHCI_STS), 0, 0, 0);
-		if (UREAD2(sc, UHCI_STS) & UHCI_STS_USBINT) {
-			mutex_spin_enter(&sc->sc_intr_lock);
-			uhci_intr1(sc);
-			mutex_spin_exit(&sc->sc_intr_lock);
-			if (xfer->ux_status != USBD_IN_PROGRESS)
-				goto done;
-		}
-	}
-
-	/* Timeout */
-	DPRINTF("timeout", 0, 0, 0, 0);
-	TAILQ_FOREACH(ux, &sc->sc_intrhead, ux_list)
-		if (&ux->ux_xfer == xfer)
-			break;
-
-	KASSERT(ux != NULL);
-
-	uhci_idone(ux, NULL);
-	usb_transfer_complete(&ux->ux_xfer);
-
-done:
-	mutex_exit(&sc->sc_lock);
-}
-
 void
 uhci_poll(struct usbd_bus *bus)
 {
@@ -2352,9 +2305,6 @@ uhci_device_bulk_start(struct usbd_xfer 
 	xfer->ux_status = USBD_IN_PROGRESS;
 	mutex_exit(&sc->sc_lock);
 
-	if (sc->sc_bus.ub_usepolling)
-		uhci_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -2699,9 +2649,6 @@ uhci_device_ctrl_start(struct usbd_xfer 
 	xfer->ux_status = USBD_IN_PROGRESS;
 	mutex_exit(&sc->sc_lock);
 
-	if (sc->sc_bus.ub_usepolling)
-		uhci_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 

Index: src/sys/external/bsd/dwc2/dwc2.c
diff -u src/sys/external/bsd/dwc2/dwc2.c:1.42 src/sys/external/bsd/dwc2/dwc2.c:1.43
--- src/sys/external/bsd/dwc2/dwc2.c:1.42	Sat Apr 23 10:15:30 2016
+++ src/sys/external/bsd/dwc2/dwc2.c	Fri May  6 13:03:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: dwc2.c,v 1.42 2016/04/23 10:15:30 skrll Exp $	*/
+/*	$NetBSD: dwc2.c,v 1.43 2016/05/06 13:03:06 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.42 2016/04/23 10:15:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.43 2016/05/06 13:03:06 skrll Exp $");
 
 #include "opt_usb.h"
 
@@ -82,7 +82,6 @@ int dwc2debug = 0;
 Static usbd_status	dwc2_open(struct usbd_pipe *);
 Static void		dwc2_poll(struct usbd_bus *);
 Static void		dwc2_softintr(void *);
-Static void		dwc2_waitintr(struct dwc2_softc *, struct usbd_xfer *);
 
 Static struct usbd_xfer *
 			dwc2_allocx(struct usbd_bus *, unsigned int);
@@ -314,40 +313,6 @@ dwc2_softintr(void *v)
 }
 
 Static void
-dwc2_waitintr(struct dwc2_softc *sc, struct usbd_xfer *xfer)
-{
-	struct dwc2_hsotg *hsotg = sc->sc_hsotg;
-	uint32_t intrs;
-	int timo;
-
-	xfer->ux_status = USBD_IN_PROGRESS;
-	for (timo = xfer->ux_timeout; timo >= 0; timo--) {
-		usb_delay_ms(&sc->sc_bus, 1);
-		if (sc->sc_dying)
-			break;
-		intrs = dwc2_read_core_intr(hsotg);
-
-		DPRINTFN(15, "0x%08x\n", intrs);
-
-		if (intrs) {
-			mutex_spin_enter(&hsotg->lock);
-			dwc2_interrupt(sc);
-			mutex_spin_exit(&hsotg->lock);
-			if (xfer->ux_status != USBD_IN_PROGRESS)
-				return;
-		}
-	}
-
-	/* Timeout */
-	DPRINTF("timeout\n");
-
-	mutex_enter(&sc->sc_lock);
-	xfer->ux_status = USBD_TIMEOUT;
-	usb_transfer_complete(xfer);
-	mutex_exit(&sc->sc_lock);
-}
-
-Static void
 dwc2_timeout(void *addr)
 {
 	struct usbd_xfer *xfer = addr;
@@ -742,9 +707,6 @@ dwc2_device_ctrl_start(struct usbd_xfer 
 	if (err)
 		return err;
 
-	if (sc->sc_bus.ub_usepolling)
-		dwc2_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -863,9 +825,6 @@ dwc2_device_intr_start(struct usbd_xfer 
 	if (err)
 		return err;
 
-	if (sc->sc_bus.ub_usepolling)
-		dwc2_waitintr(sc, xfer);
-
 	return USBD_IN_PROGRESS;
 }
 
@@ -921,9 +880,6 @@ dwc2_device_isoc_transfer(struct usbd_xf
 	err = dwc2_device_start(xfer);
 	mutex_exit(&sc->sc_lock);
 
-	if (sc->sc_bus.ub_usepolling)
-		dwc2_waitintr(sc, xfer);
-
 	return err;
 }
 

Reply via email to