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 Use the hsotg->lock spin lock solely
details: https://anonhg.NetBSD.org/src/rev/3827fd133e47
branches: trunk
changeset: 790210:3827fd133e47
user: skrll <skrll%NetBSD.org@localhost>
date: Fri Sep 27 21:39:34 2013 +0000
description:
Use the hsotg->lock spin lock solely
diffstat:
sys/external/bsd/dwc2/dist/dwc2_coreintr.c | 5 +-
sys/external/bsd/dwc2/dist/dwc2_hcdintr.c | 9 +---
sys/external/bsd/dwc2/dwc2.c | 48 +++++++++++++----------------
sys/external/bsd/dwc2/dwc2var.h | 3 +-
4 files changed, 28 insertions(+), 37 deletions(-)
diffs (267 lines):
diff -r 8672f2694198 -r 3827fd133e47 sys/external/bsd/dwc2/dist/dwc2_coreintr.c
--- a/sys/external/bsd/dwc2/dist/dwc2_coreintr.c Fri Sep 27 13:34:48 2013 +0000
+++ b/sys/external/bsd/dwc2/dist/dwc2_coreintr.c Fri Sep 27 21:39:34 2013 +0000
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2_coreintr.c,v 1.3 2013/09/25 06:19:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_coreintr.c,v 1.4 2013/09/27 21:39:34 skrll Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -467,7 +467,7 @@
goto out;
}
- spin_lock(&hsotg->lock);
+ KASSERT(mutex_owned(&hsotg->lock));
gintsts = dwc2_read_common_intr(hsotg);
if (gintsts & ~GINTSTS_PRTINT)
@@ -502,7 +502,6 @@
}
}
- spin_unlock(&hsotg->lock);
out:
return retval;
}
diff -r 8672f2694198 -r 3827fd133e47 sys/external/bsd/dwc2/dist/dwc2_hcdintr.c
--- a/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c Fri Sep 27 13:34:48 2013 +0000
+++ b/sys/external/bsd/dwc2/dist/dwc2_hcdintr.c Fri Sep 27 21:39:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc2_hcdintr.c,v 1.3 2013/09/25 06:19:22 skrll Exp $ */
+/* $NetBSD: dwc2_hcdintr.c,v 1.4 2013/09/27 21:39:34 skrll Exp $ */
/*
* hcd_intr.c - DesignWare HS OTG Controller host-mode interrupt handling
@@ -40,7 +40,7 @@
* This file contains the interrupt handlers for Host mode
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr.c,v 1.3 2013/09/25 06:19:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2_hcdintr.c,v 1.4 2013/09/27 21:39:34 skrll Exp $");
#include <sys/types.h>
#include <sys/pool.h>
@@ -2071,13 +2071,12 @@
return retval;
}
- spin_lock(&hsotg->lock);
+ KASSERT(mutex_owned(&hsotg->lock));
/* Check if HOST Mode */
if (dwc2_is_host_mode(hsotg)) {
gintsts = dwc2_read_core_intr(hsotg);
if (!gintsts) {
- spin_unlock(&hsotg->lock);
return retval;
}
@@ -2120,7 +2119,5 @@
}
}
- spin_unlock(&hsotg->lock);
-
return retval;
}
diff -r 8672f2694198 -r 3827fd133e47 sys/external/bsd/dwc2/dwc2.c
--- a/sys/external/bsd/dwc2/dwc2.c Fri Sep 27 13:34:48 2013 +0000
+++ b/sys/external/bsd/dwc2/dwc2.c Fri Sep 27 21:39:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc2.c,v 1.2 2013/09/21 13:17:00 skrll Exp $ */
+/* $NetBSD: dwc2.c,v 1.3 2013/09/27 21:39:34 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.2 2013/09/21 13:17:00 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc2.c,v 1.3 2013/09/27 21:39:34 skrll Exp $");
#include "opt_usb.h"
@@ -326,11 +326,12 @@
{
struct usbd_bus *bus = v;
struct dwc2_softc *sc = DWC2_BUS2SC(bus);
+ struct dwc2_hsotg *hsotg = sc->sc_hsotg;
struct dwc2_xfer *dxfer;
KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_spin_enter(&hsotg->lock);
while ((dxfer = TAILQ_FIRST(&sc->sc_complete)) != NULL) {
/*
* dwc2_abort_xfer will remove this transfer from the
@@ -346,11 +347,11 @@
/* XXXNH Already done - can I assert this? */
callout_stop(&dxfer->xfer.timeout_handle);
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_spin_exit(&hsotg->lock);
usb_transfer_complete(&dxfer->xfer);
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_spin_enter(&hsotg->lock);
}
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_spin_exit(&hsotg->lock);
}
Static void
@@ -370,9 +371,9 @@
DPRINTFN(15, "0x%08x\n", intrs);
if (intrs) {
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_spin_enter(&hsotg->lock);
dwc2_interrupt(sc);
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_spin_exit(&hsotg->lock);
if (xfer->status != USBD_IN_PROGRESS)
return;
}
@@ -491,10 +492,11 @@
dwc2_poll(struct usbd_bus *bus)
{
struct dwc2_softc *sc = DWC2_BUS2SC(bus);
+ struct dwc2_hsotg *hsotg = sc->sc_hsotg;
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_spin_enter(&hsotg->lock);
dwc2_interrupt(sc);
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_spin_exit(&hsotg->lock);
}
/*
@@ -522,7 +524,6 @@
struct dwc2_softc *sc = DWC2_XFER2SC(xfer);
struct dwc2_hsotg *hsotg = sc->sc_hsotg;
struct dwc2_xfer *d, *tmp;
- unsigned long flags;
bool wake;
int err;
@@ -553,14 +554,12 @@
/*
* Step 1: Make the stack ignore it and stop the callout.
*/
- mutex_spin_enter(&sc->sc_intr_lock);
+ mutex_spin_enter(&hsotg->lock);
xfer->hcflags |= UXFER_ABORTING;
xfer->status = status; /* make software ignore it */
callout_stop(&xfer->timeout_handle);
- spin_lock_irqsave(&hsotg->lock, flags);
-
/* XXXNH suboptimal */
TAILQ_FOREACH_SAFE(d, &sc->sc_complete, xnext, tmp) {
if (d == dxfer) {
@@ -573,8 +572,7 @@
DPRINTF("dwc2_hcd_urb_dequeue failed\n");
}
- spin_unlock(&hsotg->lock);
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_spin_exit(&hsotg->lock);
/*
* Step 2: Execute callback.
@@ -1226,10 +1224,10 @@
if (xfertype == UE_ISOCHRONOUS ||
xfertype == UE_INTERRUPT) {
- spin_lock_irqsave(&hsotg->lock, flags);
+ mutex_spin_enter(&hsotg->lock);
if (!dwc2_hcd_is_bandwidth_allocated(hsotg, xfer))
alloc_bandwidth = 1;
- spin_unlock_irqrestore(&hsotg->lock, flags);
+ mutex_spin_exit(&hsotg->lock);
}
/*
@@ -1400,18 +1398,19 @@
int dwc2_intr(void *p)
{
struct dwc2_softc *sc = p;
+ struct dwc2_hsotg *hsotg;
int ret = 0;
if (sc == NULL)
return 0;
- mutex_spin_enter(&sc->sc_intr_lock);
+ hsotg = sc->sc_hsotg;
+ mutex_spin_enter(&hsotg->lock);
if (sc->sc_dying || !device_has_power(sc->sc_dev))
goto done;
if (sc->sc_bus.use_polling) {
- struct dwc2_hsotg *hsotg = sc->sc_hsotg;
uint32_t intrs;
intrs = dwc2_read_core_intr(hsotg);
@@ -1421,7 +1420,7 @@
}
done:
- mutex_spin_exit(&sc->sc_intr_lock);
+ mutex_spin_exit(&hsotg->lock);
return ret;
}
@@ -1514,7 +1513,6 @@
sc->sc_hcdenabled = false;
mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
- mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_USB);
TAILQ_INIT(&sc->sc_complete);
@@ -1719,11 +1717,9 @@
int
_dwc2_hcd_start(struct dwc2_hsotg *hsotg)
{
- unsigned long flags;
-
dev_dbg(hsotg->dev, "DWC OTG HCD START\n");
- spin_lock_irqsave(&hsotg->lock, flags);
+ mutex_spin_enter(&hsotg->lock);
hsotg->op_state = OTG_STATE_A_HOST;
@@ -1732,6 +1728,6 @@
/*XXXNH*/
delay(50);
- spin_unlock_irqrestore(&hsotg->lock, flags);
+ mutex_spin_exit(&hsotg->lock);
return 0;
}
diff -r 8672f2694198 -r 3827fd133e47 sys/external/bsd/dwc2/dwc2var.h
--- a/sys/external/bsd/dwc2/dwc2var.h Fri Sep 27 13:34:48 2013 +0000
+++ b/sys/external/bsd/dwc2/dwc2var.h Fri Sep 27 21:39:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc2var.h,v 1.1 2013/09/05 20:25:27 skrll Exp $ */
+/* $NetBSD: dwc2var.h,v 1.2 2013/09/27 21:39:34 skrll Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -87,7 +87,6 @@
struct dwc2_hsotg *sc_hsotg;
kmutex_t sc_lock;
- kmutex_t sc_intr_lock;
bool sc_hcdenabled;
void *sc_rhc_si;
Home |
Main Index |
Thread Index |
Old Index