Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/mips/adm5120/dev Adapt to usbmp. Compile tested only.
details: https://anonhg.NetBSD.org/src/rev/72f1ad76aedd
branches: trunk
changeset: 790152:72f1ad76aedd
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Sep 22 08:30:22 2013 +0000
description:
Adapt to usbmp. Compile tested only.
Did this ever work?
diffstat:
sys/arch/mips/adm5120/dev/ahci.c | 73 ++++++++++++++++++++++--------------
sys/arch/mips/adm5120/dev/ahcivar.h | 5 +-
2 files changed, 48 insertions(+), 30 deletions(-)
diffs (289 lines):
diff -r 30679a808b9a -r 72f1ad76aedd sys/arch/mips/adm5120/dev/ahci.c
--- a/sys/arch/mips/adm5120/dev/ahci.c Sun Sep 22 07:26:42 2013 +0000
+++ b/sys/arch/mips/adm5120/dev/ahci.c Sun Sep 22 08:30:22 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ahci.c,v 1.11 2013/09/22 07:26:42 skrll Exp $ */
+/* $NetBSD: ahci.c,v 1.12 2013/09/22 08:30:22 skrll Exp $ */
/*-
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.11 2013/09/22 07:26:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahci.c,v 1.12 2013/09/22 08:30:22 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -99,6 +99,8 @@
static usbd_xfer_handle ahci_allocx(struct usbd_bus *);
static void ahci_freex(struct usbd_bus *, usbd_xfer_handle);
+static void ahci_get_lock(struct usbd_bus *, kmutex_t **);
+
static int ahci_str(usb_string_descriptor_t *, int, const char *);
static usbd_status ahci_root_ctrl_transfer(usbd_xfer_handle);
@@ -178,6 +180,7 @@
.freem = ahci_freem,
.allocx = ahci_allocx,
.freex = ahci_freex,
+ .get_lock = ahci_get_lock,
};
struct usbd_pipe_methods ahci_root_ctrl_methods = {
@@ -277,7 +280,6 @@
sc->sc_bus.methods = &ahci_bus_methods;
sc->sc_bus.pipe_size = sizeof(struct ahci_pipe);
sc->sc_bus.dmatag = sc->sc_dmat;
- sc->busy = 0;
/* Map the device. */
if (bus_space_map(sc->sc_st, aa->oba_addr,
@@ -299,6 +301,9 @@
callout_init(&sc->sc_poll_handle, 0);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
+ mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_SCHED /* XXXNH */);
+
REG_WRITE(ADMHCD_REG_INTENABLE, 0); /* disable interrupts */
REG_WRITE(ADMHCD_REG_CONTROL, ADMHCD_SW_RESET); /* reset */
delay_ms(10);
@@ -432,7 +437,6 @@
usbd_xfer_handle xfer = arg;
usbd_pipe_handle pipe = xfer->pipe;
struct ahci_softc *sc = (struct ahci_softc *)pipe->device->bus;
- int s;
u_char *p;
static int p0_state=0;
static int p1_state=0;
@@ -459,9 +463,9 @@
xfer->actlen = 1;
xfer->status = USBD_NORMAL_COMPLETION;
- s = splusb();
+ mutex_enter(&sc->sc_lock);
usb_transfer_complete(xfer);
- splx(s);
+ mutex_exit(&sc->sc_lock);
}
usbd_status
@@ -531,6 +535,14 @@
SIMPLEQ_INSERT_HEAD(&sc->sc_free_xfers, xfer, next);
}
+static void
+ahci_get_lock(struct usbd_bus *bus, kmutex_t **lock)
+{
+ struct ahci_softc *sc = bus->hci_private;
+
+ *lock = &sc->sc_lock;
+}
+
void
ahci_noop(usbd_pipe_handle pipe)
{
@@ -623,12 +635,15 @@
usbd_status
ahci_root_ctrl_transfer(usbd_xfer_handle xfer)
{
+ struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
usbd_status error;
DPRINTF(D_TRACE, ("SLRCtrans "));
/* Insert last in queue */
+ mutex_enter(&sc->sc_lock);
error = usb_insert_transfer(xfer);
+ mutex_exit(&sc->sc_lock);
if (error) {
DPRINTF(D_MSG, ("usb_insert_transfer returns err! "));
return error;
@@ -646,7 +661,7 @@
{
struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
usb_device_request_t *req;
- int len, value, index, l, s, status;
+ int len, value, index, l, status;
int totlen = 0;
void *buf = NULL;
usb_port_status_t ps;
@@ -942,9 +957,9 @@
error = USBD_NORMAL_COMPLETION;
ret:
xfer->status = error;
- s = splusb();
+ mutex_enter(&sc->sc_lock);
usb_transfer_complete(xfer);
- splx(s);
+ mutex_exit(&sc->sc_lock);
return USBD_IN_PROGRESS;
}
@@ -969,12 +984,15 @@
static usbd_status
ahci_root_intr_transfer(usbd_xfer_handle xfer)
{
+ struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
usbd_status error;
DPRINTF(D_TRACE, ("SLRItransfer "));
/* Insert last in queue */
+ mutex_enter(&sc->sc_lock);
error = usb_insert_transfer(xfer);
+ mutex_exit(&sc->sc_lock);
if (error)
return error;
@@ -1025,11 +1043,14 @@
static usbd_status
ahci_device_ctrl_transfer(usbd_xfer_handle xfer)
{
+ struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
usbd_status error;
DPRINTF(D_TRACE, ("C"));
+ mutex_enter(&sc->sc_lock);
error = usb_insert_transfer(xfer);
+ mutex_exit(&sc->sc_lock);
if (error)
return error;
@@ -1053,10 +1074,7 @@
#if 0
struct ahci_pipe *apipe = (struct ahci_pipe *)xfer->pipe;
#endif
- while (sc->busy) {
- delay_ms(10);
- };
- sc->busy++;
+ mutex_enter(&sc->sc_lock);
/* printf("ctrl_start>>>\n"); */
#ifdef DIAGNOSTIC
@@ -1183,13 +1201,11 @@
xfer->actlen = len;
xfer->status = status;
- sc->busy--;
/* printf("ctrl_start<<<\n"); */
- s = splusb();
usb_transfer_complete(xfer);
- splx(s);
- return USBD_IN_PROGRESS;
+ mutex_exit(&sc->sc_lock);
+ return USBD_NORMAL_COMPLETION;
}
static void
@@ -1214,11 +1230,14 @@
static usbd_status
ahci_device_intr_transfer(usbd_xfer_handle xfer)
{
+ struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
usbd_status error;
DPRINTF(D_TRACE, ("INTRtrans "));
+ mutex_enter(&sc->sc_lock);
error = usb_insert_transfer(xfer);
+ mutex_exit(&sc->sc_lock);
if (error)
return error;
@@ -1263,7 +1282,6 @@
void *buf;
int pid;
int r;
- int s;
DPRINTF(D_TRACE, ("pldev"));
@@ -1286,9 +1304,9 @@
return;
xfer->status = USBD_NORMAL_COMPLETION;
- s = splusb();
+ mutex_enter(&sc->sc_lock);
usb_transfer_complete(xfer);
- splx(s);
+ mutex_exit(&sc->sc_lock);
}
static void
@@ -1356,11 +1374,14 @@
static usbd_status
ahci_device_bulk_transfer(usbd_xfer_handle xfer)
{
+ struct ahci_softc *sc = (struct ahci_softc *)xfer->pipe->device->bus;
usbd_status error;
DPRINTF(D_TRACE, ("B"));
+ mutex_enter(&sc->sc_lock);
error = usb_insert_transfer(xfer);
+ mutex_exit(&sc->sc_lock);
if (error)
return error;
@@ -1392,10 +1413,7 @@
}
#endif
- while (sc->busy) {
- delay_ms(10);
- };
- sc->busy++;
+ mutex_enter(&sc->sc_lock);
level++;
/* printf("bulk_start>>>\n"); */
@@ -1510,13 +1528,12 @@
xfer->status = status;
level--;
- sc->busy--;
/* printf("bulk_start<<<\n"); */
- s = splusb();
usb_transfer_complete(xfer);
- splx(s);
- return USBD_IN_PROGRESS;
+ mutex_exit(&sc->sc_lock);
+
+ return USBD_NORMAL_COMPLETION;
}
static void
diff -r 30679a808b9a -r 72f1ad76aedd sys/arch/mips/adm5120/dev/ahcivar.h
--- a/sys/arch/mips/adm5120/dev/ahcivar.h Sun Sep 22 07:26:42 2013 +0000
+++ b/sys/arch/mips/adm5120/dev/ahcivar.h Sun Sep 22 08:30:22 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ahcivar.h,v 1.4 2012/10/27 17:18:01 chs Exp $ */
+/* $NetBSD: ahcivar.h,v 1.5 2013/09/22 08:30:22 skrll Exp $ */
/*-
* Copyright (c) 2007 Ruslan Ermilov and Vsevolod Lobko.
@@ -81,6 +81,8 @@
bus_dma_tag_t sc_dmat;
void *sc_ih; /* interrupt cookie */
+ kmutex_t sc_lock;
+ kmutex_t sc_intr_lock;
void (*sc_enable_power)(void *, int);
void (*sc_enable_intr)(void *, int);
@@ -112,7 +114,6 @@
int sc_fullspeed;
int sc_connect; /* XXX */
int sc_change;
- int busy;
};
int ahci_intr(void *);
Home |
Main Index |
Thread Index |
Old Index