Module Name: src Committed By: skrll Date: Mon Dec 16 10:04:20 UTC 2013
Modified Files: src/sys/dev/usb: ehci.c ohci.c Log Message: Backout the ED/QH change removal in [eo]hci_device_request. Reports of the KASSERT firing mean this needs more thought/testing. To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/sys/dev/usb/ehci.c cvs rdiff -u -r1.247 -r1.248 src/sys/dev/usb/ohci.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.223 src/sys/dev/usb/ehci.c:1.224 --- src/sys/dev/usb/ehci.c:1.223 Sun Dec 15 17:15:34 2013 +++ src/sys/dev/usb/ehci.c Mon Dec 16 10:04:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.223 2013/12/15 17:15:34 para Exp $ */ +/* $NetBSD: ehci.c,v 1.224 2013/12/16 10:04: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.223 2013/12/15 17:15:34 para Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.224 2013/12/16 10:04:20 skrll Exp $"); #include "ohci.h" #include "uhci.h" @@ -3364,7 +3364,7 @@ ehci_device_request(usbd_xfer_handle xfe usb_device_request_t *req = &xfer->request; usbd_device_handle dev = epipe->pipe.device; ehci_softc_t *sc = dev->bus->hci_private; - int addr __diagused = dev->address; + int addr = dev->address; ehci_soft_qtd_t *setup, *stat, *next; ehci_soft_qh_t *sqh; int isread; @@ -3395,9 +3395,18 @@ ehci_device_request(usbd_xfer_handle xfe sqh = epipe->sqh; - KASSERT(EHCI_QH_GET_ADDR(le32toh(sqh->qh.qh_endp)) == addr); - KASSERT(EHCI_QH_GET_MPL(le32toh(sqh->qh.qh_endp)) == - UGETW(epipe->pipe.endpoint->edesc->wMaxPacketSize)); + /* + * Update device address and length since they may have changed + * during the setup of the control pipe in usbd_new_device(). + */ + /* XXX This only needs to be done once, but it's too early in open. */ + /* XXXX Should not touch ED here! */ + sqh->qh.qh_endp = + (sqh->qh.qh_endp & htole32(~(EHCI_QH_ADDRMASK | EHCI_QH_MPLMASK))) | + htole32( + EHCI_QH_SET_ADDR(addr) | + EHCI_QH_SET_MPL(UGETW(epipe->pipe.endpoint->edesc->wMaxPacketSize)) + ); /* Set up data transaction */ if (len != 0) { Index: src/sys/dev/usb/ohci.c diff -u src/sys/dev/usb/ohci.c:1.247 src/sys/dev/usb/ohci.c:1.248 --- src/sys/dev/usb/ohci.c:1.247 Sun Dec 15 18:50:25 2013 +++ src/sys/dev/usb/ohci.c Mon Dec 16 10:04:20 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ohci.c,v 1.247 2013/12/15 18:50:25 jakllsch Exp $ */ +/* $NetBSD: ohci.c,v 1.248 2013/12/16 10:04: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.247 2013/12/15 18:50:25 jakllsch Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.248 2013/12/16 10:04:20 skrll Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1683,6 +1683,7 @@ ohci_device_request(usbd_xfer_handle xfe usb_device_request_t *req = &xfer->request; usbd_device_handle dev = opipe->pipe.device; ohci_softc_t *sc = dev->bus->hci_private; + int addr = dev->address; ohci_soft_td_t *setup, *stat, *next, *tail; ohci_soft_ed_t *sed; int isread; @@ -1697,7 +1698,7 @@ ohci_device_request(usbd_xfer_handle xfe DPRINTFN(3,("ohci_device_control type=0x%02x, request=0x%02x, " "wValue=0x%04x, wIndex=0x%04x len=%d, addr=%d, endpt=%d\n", req->bmRequestType, req->bRequest, UGETW(req->wValue), - UGETW(req->wIndex), len, dev->address, + UGETW(req->wIndex), len, addr, opipe->pipe.endpoint->edesc->bEndpointAddress)); setup = opipe->tail.td; @@ -1716,14 +1717,21 @@ ohci_device_request(usbd_xfer_handle xfe sed = opipe->sed; opipe->u.ctl.length = len; - /* XXX is this ever written to by hardware ??? */ + /* Update device address and length since they may have changed + during the setup of the control pipe in usbd_new_device(). */ + /* XXX This only needs to be done once, but it's too early in open. */ + /* XXXX Should not touch ED here! */ + usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags), sizeof(sed->ed.ed_flags), BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD); - - KASSERT(OHCI_ED_GET_FA(HTOO32(sed->ed.ed_flags)) == dev->address); - KASSERT(OHCI_ED_GET_MAXP(HTOO32(sed->ed.ed_flags)) == - UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize)); + sed->ed.ed_flags = HTOO32( + (O32TOH(sed->ed.ed_flags) & ~(OHCI_ED_ADDRMASK | OHCI_ED_MAXPMASK)) | + OHCI_ED_SET_FA(addr) | + OHCI_ED_SET_MAXP(UGETW(opipe->pipe.endpoint->edesc->wMaxPacketSize))); + usb_syncmem(&sed->dma, sed->offs + offsetof(ohci_ed_t, ed_flags), + sizeof(sed->ed.ed_flags), + BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD); next = stat;