Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys/dev/usb Collapse uhcl_intr_info into uhci_xfer and ...
details: https://anonhg.NetBSD.org/src/rev/bea3475d9cd3
branches: nick-nhusb
changeset: 334293:bea3475d9cd3
user: skrll <skrll%NetBSD.org@localhost>
date: Tue Oct 27 14:05:29 2015 +0000
description:
Collapse uhcl_intr_info into uhci_xfer and use TAILQ for list of
transfers that are active.
diffstat:
sys/dev/usb/uhci.c | 313 +++++++++++++++++++++++--------------------------
sys/dev/usb/uhcivar.h | 26 +---
2 files changed, 157 insertions(+), 182 deletions(-)
diffs (truncated from 845 to 300 lines):
diff -r 1081a611fc04 -r bea3475d9cd3 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c Tue Oct 27 08:02:31 2015 +0000
+++ b/sys/dev/usb/uhci.c Tue Oct 27 14:05:29 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.264.4.38 2015/10/27 08:02:31 skrll Exp $ */
+/* $NetBSD: uhci.c,v 1.264.4.39 2015/10/27 14:05:29 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.264.4.38 2015/10/27 08:02:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264.4.39 2015/10/27 14:05:29 skrll Exp $");
#include "opt_usb.h"
@@ -183,8 +183,8 @@
uhci_soft_td_t **, 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 *, uhci_intr_info_t *);
-Static void uhci_idone(uhci_intr_info_t *);
+Static void uhci_check_intr(uhci_softc_t *, struct uhci_xfer *);
+Static void uhci_idone(struct uhci_xfer *);
Static void uhci_abort_xfer(struct usbd_xfer *, usbd_status);
@@ -366,14 +366,14 @@
.upm_done = uhci_device_isoc_done,
};
-#define uhci_add_intr_info(sc, ii) \
- LIST_INSERT_HEAD(&(sc)->sc_intrhead, (ii), list)
-#define uhci_del_intr_info(ii) \
+#define uhci_add_intr_info(sc, ux) \
+ TAILQ_INSERT_TAIL(&(sc)->sc_intrhead, (ux), list)
+#define uhci_del_intr_info(sc, ux) \
do { \
- LIST_REMOVE((ii), list); \
- (ii)->list.le_prev = NULL; \
+ TAILQ_REMOVE(&(sc)->sc_intrhead, (ux), list); \
+ (ux)->list.tqe_prev = NULL; \
} while (0)
-#define uhci_active_intr_info(ii) ((ii)->list.le_prev != NULL)
+#define uhci_active_intr_info(ux) ((ux)->list.tqe_prev != NULL)
static inline uhci_soft_qh_t *
uhci_find_prev_qh(uhci_soft_qh_t *pqh, uhci_soft_qh_t *sqh)
@@ -538,7 +538,7 @@
BUS_DMASYNC_PREWRITE);
- LIST_INIT(&sc->sc_intrhead);
+ TAILQ_INIT(&sc->sc_intrhead);
sc->sc_xferpool = pool_cache_init(sizeof(struct uhci_xfer), 0, 0, 0,
"uhcixfer", NULL, IPL_USB, NULL, NULL, NULL);
@@ -625,7 +625,7 @@
struct uhci_xfer *uxfer = UHCI_XFER2UXFER(xfer);
#ifdef DIAGNOSTIC
- uxfer->iinfo.isdone = true;
+ uxfer->isdone = true;
xfer->ux_state = XFER_BUSY;
#endif
}
@@ -640,7 +640,7 @@
KASSERTMSG(xfer->ux_state == XFER_BUSY, "xfer %p state %d\n", xfer,
xfer->ux_state);
- KASSERTMSG(uxfer->iinfo.isdone, "xfer %p not done\n", xfer);
+ KASSERTMSG(uxfer->isdone, "xfer %p not done\n", xfer);
#ifdef DIAGNOSTIC
xfer->ux_state = XFER_FREE;
#endif
@@ -895,51 +895,45 @@
}
Static void
-uhci_dump_ii(uhci_intr_info_t *ii)
+uhci_dump_ii(uhci_intr_info_t *ux)
{
struct usbd_pipe *pipe;
usb_endpoint_descriptor_t *ed;
struct usbd_device *dev;
-#ifdef DIAGNOSTIC
-#define DONE ii->isdone
-#else
-#define DONE 0
-#endif
- if (ii == NULL) {
- printf("ii NULL\n");
+ if (ux == NULL) {
+ printf("ux NULL\n");
return;
}
- if (ii->xfer == NULL) {
- printf("ii %p: done=%d xfer=NULL\n",
- ii, DONE);
+ if (ux->xfer == NULL) {
+ printf("ux %p: done=%d xfer=NULL\n",
+ ux, ux->isdone);
return;
}
- pipe = ii->xfer->ux_pipe;
+ pipe = ux->xfer->ux_pipe;
if (pipe == NULL) {
- printf("ii %p: done=%d xfer=%p pipe=NULL\n",
- ii, DONE, ii->xfer);
+ printf("ux %p: done=%d xfer=%p pipe=NULL\n",
+ ux, ux->isdone, ux->xfer);
return;
}
if (pipe->up_endpoint == NULL) {
- printf("ii %p: done=%d xfer=%p pipe=%p pipe->up_endpoint=NULL\n",
- ii, DONE, ii->xfer, pipe);
+ printf("ux %p: done=%d xfer=%p pipe=%p pipe->up_endpoint=NULL\n",
+ ux, ux->isdone, ux->xfer, pipe);
return;
}
if (pipe->up_dev == NULL) {
- printf("ii %p: done=%d xfer=%p pipe=%p pipe->up_dev=NULL\n",
- ii, DONE, ii->xfer, pipe);
+ printf("ux %p: done=%d xfer=%p pipe=%p pipe->up_dev=NULL\n",
+ ux, ux->isdone, ux->xfer, pipe);
return;
}
ed = pipe->up_endpoint->ue_edesc;
dev = pipe->up_dev;
- printf("ii %p: done=%d xfer=%p dev=%p vid=0x%04x pid=0x%04x addr=%d pipe=%p ep=0x%02x attr=0x%02x\n",
- ii, DONE, ii->xfer, dev,
+ printf("ux %p: done=%d xfer=%p dev=%p vid=0x%04x pid=0x%04x addr=%d pipe=%p ep=0x%02x attr=0x%02x\n",
+ ux, ux->isdone, ux->xfer, dev,
UGETW(dev->ud_ddesc.idVendor),
UGETW(dev->ud_ddesc.idProduct),
dev->ud_addr, pipe,
ed->bEndpointAddress, ed->bmAttributes);
-#undef DONE
}
void uhci_dump_iis(struct uhci_softc *sc);
@@ -948,9 +942,9 @@
{
uhci_intr_info_t *ii;
- printf("intr_info list:\n");
- for (ii = LIST_FIRST(&sc->sc_intrhead); ii; ii = LIST_NEXT(ii, list))
- uhci_dump_ii(ii);
+ printf("interrupt list:\n");
+ for (ux = TAILQ_FIRST(&sc->sc_intrhead); ux; ux = TAILQ_NEXT(ux, list))
+ uhci_dump_ii(ux);
}
void iidump(void);
@@ -1363,7 +1357,7 @@
{
struct usbd_bus *bus = v;
uhci_softc_t *sc = UHCI_BUS2SC(bus);
- uhci_intr_info_t *ii, *nextii;
+ struct uhci_xfer *ux, *nextux;
UHCIHIST_FUNC(); UHCIHIST_CALLED();
DPRINTF("sc %p", sc, 0, 0, 0);
@@ -1381,9 +1375,9 @@
* We scan all interrupt descriptors to see if any have
* completed.
*/
- for (ii = LIST_FIRST(&sc->sc_intrhead); ii; ii = nextii) {
- nextii = LIST_NEXT(ii, list);
- uhci_check_intr(sc, ii);
+ for (ux = TAILQ_FIRST(&sc->sc_intrhead); ux; ux = nextux) {
+ nextux = TAILQ_NEXT(ux, list);
+ uhci_check_intr(sc, ux);
}
if (sc->sc_softwake) {
@@ -1394,25 +1388,26 @@
/* Check for an interrupt. */
void
-uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii)
+uhci_check_intr(uhci_softc_t *sc, struct uhci_xfer *ux)
{
uhci_soft_td_t *std, *lstd;
uint32_t status;
UHCIHIST_FUNC(); UHCIHIST_CALLED();
- DPRINTFN(15, "ii %p", ii, 0, 0, 0);
-
- KASSERT(ii != NULL);
-
- if (ii->xfer->ux_status == USBD_CANCELLED ||
- ii->xfer->ux_status == USBD_TIMEOUT) {
- DPRINTF("aborted xfer %p", ii->xfer, 0, 0, 0);
+ DPRINTFN(15, "ux %p", ux, 0, 0, 0);
+
+ KASSERT(ux != NULL);
+
+ struct usbd_xfer *xfer = &ux->xfer;
+ if (xfer->ux_status == USBD_CANCELLED ||
+ xfer->ux_status == USBD_TIMEOUT) {
+ DPRINTF("aborted xfer %p", xfer, 0, 0, 0);
return;
}
- if (ii->stdstart == NULL)
+ if (ux->stdstart == NULL)
return;
- lstd = ii->stdend;
+ lstd = ux->stdend;
KASSERT(lstd != NULL);
@@ -1429,10 +1424,10 @@
/* If the last TD is not marked active we can complete */
if (!(status & UHCI_TD_ACTIVE)) {
done:
- DPRINTFN(12, "ii=%p done", ii, 0, 0, 0);
-
- callout_stop(&ii->xfer->ux_callout);
- uhci_idone(ii);
+ DPRINTFN(12, "ux=%p done", ux, 0, 0, 0);
+
+ callout_stop(&xfer->ux_callout);
+ uhci_idone(ux);
return;
}
@@ -1441,8 +1436,8 @@
* is an error somewhere in the middle, or whether there was a
* short packet (SPD and not ACTIVE).
*/
- DPRINTFN(12, "active ii=%p", ii, 0, 0, 0);
- for (std = ii->stdstart; std != lstd; std = std->link.std) {
+ DPRINTFN(12, "active ux=%p", ux, 0, 0, 0);
+ for (std = ux->stdstart; std != lstd; std = std->link.std) {
usb_syncmem(&std->dma,
std->offs + offsetof(uhci_td_t, td_status),
sizeof(std->td.td_status),
@@ -1454,8 +1449,8 @@
/* If there's an active TD the xfer isn't done. */
if (status & UHCI_TD_ACTIVE) {
- DPRINTFN(12, "ii=%p std=%p still active",
- ii, std, 0, 0);
+ DPRINTFN(12, "ux=%p std=%p still active",
+ ux, std, 0, 0);
return;
}
@@ -1467,7 +1462,6 @@
* If the data phase of a control transfer is short, we need
* to complete the status stage
*/
- struct usbd_xfer *xfer = ii->xfer;
usb_endpoint_descriptor_t *ed = xfer->ux_pipe->up_endpoint->ue_edesc;
uint8_t xfertype = UE_GET_XFERTYPE(ed->bmAttributes);
@@ -1477,8 +1471,8 @@
uhci_soft_qh_t *sqh = upipe->ctrl.sqh;
uhci_soft_td_t *stat = upipe->ctrl.stat;
- DPRINTFN(12, "ii=%p std=%p control status"
- "phase needs completion", ii, ii->stdstart, 0, 0);
+ DPRINTFN(12, "ux=%p std=%p control status"
+ "phase needs completion", ux, ux->stdstart, 0, 0);
sqh->qh.qh_elink =
htole32(stat->physaddr | UHCI_PTR_TD);
@@ -1503,9 +1497,9 @@
/* Called with USB lock held. */
void
-uhci_idone(uhci_intr_info_t *ii)
+uhci_idone(struct uhci_xfer *ux)
{
- struct usbd_xfer *xfer = ii->xfer;
+ struct usbd_xfer *xfer = &ux->xfer;
uhci_softc_t *sc __diagused = UHCI_XFER2SC(xfer);
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->ux_pipe;
uhci_soft_td_t *std;
@@ -1515,18 +1509,18 @@
KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
UHCIHIST_FUNC(); UHCIHIST_CALLED();
- DPRINTFN(12, "ii=%p", ii, 0, 0, 0);
+ DPRINTFN(12, "ux=%p", ux, 0, 0, 0);
#ifdef DIAGNOSTIC
#ifdef UHCI_DEBUG
- if (ii->isdone) {
+ if (ux->isdone) {
DPRINTF("--- dump start ---", 0, 0, 0, 0);
- uhci_dump_ii(ii);
+ uhci_dump_ii(ux);
DPRINTF("--- dump end ---", 0, 0, 0, 0);
}
Home |
Main Index |
Thread Index |
Old Index