Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/nick-nhusb]: src/sys Centralise the up_repeat handling and use the stand...
details: https://anonhg.NetBSD.org/src/rev/260a41fb7fd9
branches: nick-nhusb
changeset: 334420:260a41fb7fd9
user: skrll <skrll%NetBSD.org@localhost>
date: Sun Feb 28 09:16:20 2016 +0000
description:
Centralise the up_repeat handling and use the standard pipe method to
start the next transfer. This allows the removal of a bunch of code
in the upm_done methods for interrupt transfers which had copies of
the upm_start method code.
At the same time we can perform the upm_done method before calling the
transfer callback allowing correct bus_dma(9) operations before
using the transfer DMA buffer.
diffstat:
sys/dev/usb/ehci.c | 56 ++++------------------------
sys/dev/usb/ohci.c | 56 ++++-----------------------
sys/dev/usb/uhci.c | 52 +++-----------------------
sys/dev/usb/usbdi.c | 88 ++++++++++++++++++-------------------------
sys/dev/usb/xhci.c | 15 ++++---
sys/external/bsd/dwc2/dwc2.c | 9 +---
6 files changed, 71 insertions(+), 205 deletions(-)
diffs (truncated from 481 to 300 lines):
diff -r d3a0f34ce14a -r 260a41fb7fd9 sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c Sat Feb 27 17:03:58 2016 +0000
+++ b/sys/dev/usb/ehci.c Sun Feb 28 09:16:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.234.2.90 2016/02/27 17:03:58 skrll Exp $ */
+/* $NetBSD: ehci.c,v 1.234.2.91 2016/02/28 09:16:20 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.234.2.90 2016/02/27 17:03:58 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.234.2.91 2016/02/28 09:16:20 skrll Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -838,11 +838,6 @@
* the _SAFE version of TAILQ_FOREACH.
*/
TAILQ_FOREACH_SAFE(ex, &cq, ex_next, nextex) {
- /*
- * XXX transfer_complete memcpys out transfer data (for in
- * endpoints) during this call, before methods->done is called.
- * A dma sync required beforehand.
- */
usb_transfer_complete(&ex->ex_xfer);
}
@@ -4248,11 +4243,9 @@
Static void
ehci_device_intr_done(struct usbd_xfer *xfer)
{
- ehci_softc_t *sc = EHCI_XFER2SC(xfer);
- struct ehci_xfer *exfer = EHCI_XFER2EXFER(xfer);
+ ehci_softc_t *sc __diagused = EHCI_XFER2SC(xfer);
struct ehci_pipe *epipe = EHCI_XFER2EPIPE(xfer);
- ehci_soft_qh_t *sqh;
- int len, isread, endpt;
+ int isread, endpt;
USBHIST_FUNC(); USBHIST_CALLED(ehcidebug);
@@ -4261,43 +4254,10 @@
KASSERT(sc->sc_bus.ub_usepolling || mutex_owned(&sc->sc_lock));
- if (xfer->ux_pipe->up_repeat) {
-
- KASSERT(exfer->ex_isdone);
-#ifdef DIAGNOSTIC
- exfer->ex_isdone = false;
-#endif
-
- len = xfer->ux_length;
- endpt = epipe->pipe.up_endpoint->ue_edesc->bEndpointAddress;
- isread = UE_GET_DIR(endpt) == UE_DIR_IN;
- usb_syncmem(&xfer->ux_dmabuf, 0, len,
- isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
- sqh = epipe->sqh;
-
- ehci_soft_qtd_t *end;
- ehci_reset_sqtd_chain(sc, xfer, len, isread,
- &epipe->nexttoggle, &end);
- end->qtd.qtd_status |= htole32(EHCI_QTD_IOC);
- usb_syncmem(&end->dma, end->offs, sizeof(end->qtd),
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-
- exfer->ex_sqtdend = end;
-
- /* also does usb_syncmem(sqh) */
- ehci_set_qh_qtd(sqh, exfer->ex_sqtdstart);
- if (xfer->ux_timeout && !sc->sc_bus.ub_usepolling) {
- callout_reset(&xfer->ux_callout,
- mstohz(xfer->ux_timeout), ehci_timeout, xfer);
- }
- ehci_add_intr_list(sc, exfer);
- xfer->ux_status = USBD_IN_PROGRESS;
- } else {
- endpt = epipe->pipe.up_endpoint->ue_edesc->bEndpointAddress;
- isread = UE_GET_DIR(endpt) == UE_DIR_IN;
- usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
- isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
- }
+ endpt = epipe->pipe.up_endpoint->ue_edesc->bEndpointAddress;
+ isread = UE_GET_DIR(endpt) == UE_DIR_IN;
+ usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
+ isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
}
/************************/
diff -r d3a0f34ce14a -r 260a41fb7fd9 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Sat Feb 27 17:03:58 2016 +0000
+++ b/sys/dev/usb/ohci.c Sun Feb 28 09:16:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.254.2.53 2016/02/27 15:54:30 skrll Exp $ */
+/* $NetBSD: ohci.c,v 1.254.2.54 2016/02/28 09:16:20 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.254.2.53 2016/02/27 15:54:30 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.254.2.54 2016/02/28 09:16:20 skrll Exp $");
#include "opt_usb.h"
@@ -1679,10 +1679,7 @@
void
ohci_device_intr_done(struct usbd_xfer *xfer)
{
- struct ohci_xfer *ox = OHCI_XFER2OXFER(xfer);
- struct ohci_pipe *opipe = OHCI_PIPE2OPIPE(xfer->ux_pipe);
- ohci_softc_t *sc = OHCI_XFER2SC(xfer);
- ohci_soft_ed_t *sed = opipe->sed;
+ ohci_softc_t *sc __diagused = OHCI_XFER2SC(xfer);
int isread =
(UE_GET_DIR(xfer->ux_pipe->up_endpoint->ue_edesc->bEndpointAddress) == UE_DIR_IN);
@@ -1693,47 +1690,6 @@
usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
- if (xfer->ux_pipe->up_repeat) {
- ohci_soft_td_t *data, *last, *tail;
- int len = xfer->ux_length;
-
- /*
- * Use the pipe "tail" TD as our first and loan our first TD
- * to the next transfer.
- */
- data = opipe->tail.td;
- opipe->tail.td = ox->ox_stds[0];
- ox->ox_stds[0] = data;
- ohci_reset_std_chain(sc, xfer, len, isread, data, &last);
-
- /* point at sentinel */
- tail = opipe->tail.td;
- memset(&tail->td, 0, sizeof(tail->td));
- tail->nexttd = NULL;
- tail->xfer = NULL;
- usb_syncmem(&tail->dma, tail->offs, sizeof(tail->td),
- BUS_DMASYNC_PREWRITE);
-
- /* We want interrupt at the end of the transfer. */
- last->td.td_flags &= HTOO32(~OHCI_TD_INTR_MASK);
- last->td.td_flags |= HTOO32(OHCI_TD_SET_DI(1));
-
- last->td.td_nexttd = HTOO32(tail->physaddr);
- last->nexttd = tail;
- last->flags |= OHCI_CALL_DONE;
- usb_syncmem(&last->dma, last->offs, sizeof(last->td),
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-
- xfer->ux_hcpriv = data;
- xfer->ux_actlen = 0;
-
- /* Insert ED in schedule */
- sed->ed.ed_tailp = HTOO32(tail->physaddr);
- usb_syncmem(&sed->dma,
- sed->offs + offsetof(ohci_ed_t, ed_tailp),
- sizeof(sed->ed.ed_tailp),
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
- }
}
void
@@ -1803,6 +1759,12 @@
void
ohci_root_intr_done(struct usbd_xfer *xfer)
{
+ ohci_softc_t *sc = OHCI_XFER2SC(xfer);
+
+ KASSERT(mutex_owned(&sc->sc_lock));
+
+ KASSERT(sc->sc_intrxfer == xfer);
+ sc->sc_intrxfer = NULL;
}
/*
diff -r d3a0f34ce14a -r 260a41fb7fd9 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c Sat Feb 27 17:03:58 2016 +0000
+++ b/sys/dev/usb/uhci.c Sun Feb 28 09:16:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.264.4.62 2016/02/27 16:07:01 skrll Exp $ */
+/* $NetBSD: uhci.c,v 1.264.4.63 2016/02/28 09:16:20 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.62 2016/02/27 16:07:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.264.4.63 2016/02/28 09:16:20 skrll Exp $");
#include "opt_usb.h"
@@ -3399,7 +3399,6 @@
uhci_device_intr_done(struct usbd_xfer *xfer)
{
uhci_softc_t *sc = UHCI_XFER2SC(xfer);
- struct uhci_xfer *ux = UHCI_XFER2UXFER(xfer);
struct uhci_pipe *upipe = UHCI_PIPE2UPIPE(xfer->ux_pipe);
uhci_soft_qh_t *sqh;
int i, npoll;
@@ -3419,49 +3418,10 @@
sizeof(sqh->qh.qh_elink),
BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
}
-
- if (xfer->ux_pipe->up_repeat) {
- uhci_soft_td_t *data, *dataend;
- int endpt = upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress;
- int isread = UE_GET_DIR(endpt) == UE_DIR_IN;
-
- KASSERT(ux->ux_isdone);
-#ifdef DIAGNOSTIC
- ux->ux_isdone = false;
-#endif
- DPRINTFN(5, "re-queueing", 0, 0, 0, 0);
-
- data = ux->ux_stdstart;
- uhci_reset_std_chain(sc, xfer, xfer->ux_length, isread,
- &upipe->nexttoggle, &dataend);
- dataend->td.td_status |= htole32(UHCI_TD_IOC);
- usb_syncmem(&dataend->dma,
- dataend->offs + offsetof(uhci_td_t, td_status),
- sizeof(dataend->td.td_status),
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-
-#ifdef UHCI_DEBUG
- if (uhcidebug >= 10) {
- DPRINTF("--- dump start ---", 0, 0, 0, 0);
- uhci_dump_tds(data);
- uhci_dump_qh(upipe->intr.qhs[0]);
- DPRINTF("--- dump end ---", 0, 0, 0, 0);
- }
-#endif
-
- ux->ux_stdend = dataend;
- for (i = 0; i < npoll; i++) {
- sqh = upipe->intr.qhs[i];
- sqh->elink = data;
- sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD);
- usb_syncmem(&sqh->dma,
- sqh->offs + offsetof(uhci_qh_t, qh_elink),
- sizeof(sqh->qh.qh_elink),
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
- }
- xfer->ux_status = USBD_IN_PROGRESS;
- uhci_add_intr_list(sc, ux);
- }
+ const int endpt = upipe->pipe.up_endpoint->ue_edesc->bEndpointAddress;
+ const bool isread = UE_GET_DIR(endpt) == UE_DIR_IN;
+ usb_syncmem(&xfer->ux_dmabuf, 0, xfer->ux_length,
+ isread ? BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
}
/* Deallocate request data structures */
diff -r d3a0f34ce14a -r 260a41fb7fd9 sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Sat Feb 27 17:03:58 2016 +0000
+++ b/sys/dev/usb/usbdi.c Sun Feb 28 09:16:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.162.2.42 2016/02/07 15:50:43 skrll Exp $ */
+/* $NetBSD: usbdi.c,v 1.162.2.43 2016/02/28 09:16:20 skrll Exp $ */
/*
* Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.42 2016/02/07 15:50:43 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.162.2.43 2016/02/28 09:16:20 skrll Exp $");
#ifdef _KERNEL_OPT
#include "opt_usb.h"
@@ -893,10 +893,11 @@
struct usbd_pipe *pipe = xfer->ux_pipe;
struct usbd_bus *bus = pipe->up_dev->ud_bus;
int sync = xfer->ux_flags & USBD_SYNCHRONOUS;
- int erred = xfer->ux_status == USBD_CANCELLED ||
+ int erred =
+ xfer->ux_status == USBD_CANCELLED ||
xfer->ux_status == USBD_TIMEOUT;
int polling = bus->ub_usepolling;
- int repeat;
+ int repeat = pipe->up_repeat;
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
@@ -907,21 +908,10 @@
KASSERT(xfer->ux_state == XFER_ONQU);
KASSERT(pipe != NULL);
- repeat = pipe->up_repeat;
Home |
Main Index |
Thread Index |
Old Index