Changeset 52148 in vbox
- Timestamp:
- Jul 23, 2014 12:42:21 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 95182
- Location:
- trunk/src/VBox/Devices/USB
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/VUSBDevice.cpp
r49814 r52148 1130 1130 vusbUrbDoReapAsyncDev(pDev, RT_INDEFINITE_WAIT); 1131 1131 1132 /* Process any URBs waiting to be cancelled first. */ 1133 int rc = RTReqQueueProcess(pDev->hReqQueueCancel, 0); /* Don't wait if there is nothing to do. */ 1134 Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT); 1135 1132 1136 /* Woken up or there is an URB to queue. */ 1133 1137 PRTQUEUEATOMICITEM pHead = RTQueueAtomicRemoveAll(&pDev->QueueUrb); … … 1139 1143 1140 1144 LogFlow(("%s: Queuing URB\n", pUrb->pszDesc)); 1141 intrc = pUrb->pUsbIns->pReg->pfnUrbQueue(pUrb->pUsbIns, pUrb);1145 rc = pUrb->pUsbIns->pReg->pfnUrbQueue(pUrb->pUsbIns, pUrb); 1142 1146 if (RT_FAILURE(rc)) 1143 1147 { … … 1219 1223 rc = rcThread; 1220 1224 1225 pDev->hUrbIoThread = NIL_RTTHREAD; 1226 1221 1227 return rc; 1222 1228 } … … 1292 1298 /* Destroy I/O thread. */ 1293 1299 vusbDevUrbIoThreadDestroy(pDev); 1300 1301 /* Destroy request queue. */ 1302 int rc = RTReqQueueDestroy(pDev->hReqQueueCancel); 1303 AssertRC(rc); 1294 1304 1295 1305 /* … … 1730 1740 AssertMsgReturn(pDev->paIfStates, ("RTMemAllocZ(%d) failed\n", cbIface), VERR_NO_MEMORY); 1731 1741 1742 /* Setup request queue for cancelling URBs synchronously. */ 1743 rc = RTReqQueueCreate(&pDev->hReqQueueCancel); 1744 AssertRCReturn(rc, rc); 1745 1732 1746 rc = vusbDevUrbIoThreadCreate(pDev); 1733 1747 AssertRCReturn(rc, rc); -
trunk/src/VBox/Devices/USB/VUSBInternal.h
r49815 r52148 30 30 #include <iprt/assert.h> 31 31 #include <iprt/queueatomic.h> 32 #include <iprt/req.h> 32 33 33 34 RT_C_DECLS_BEGIN … … 219 220 /** Queue of URBs to submit. */ 220 221 RTQUEUEATOMIC QueueUrb; 222 /** Request queue for cancelling URBs on the I/O thread. */ 223 RTREQQUEUE hReqQueueCancel; 221 224 /** Flag whether the URB I/O thread should terminate. */ 222 225 bool volatile fTerminate; -
trunk/src/VBox/Devices/USB/VUSBUrb.cpp
r49814 r52148 2037 2037 } 2038 2038 2039 2040 /** 2041 * Cancels an URB with CRC failure. 2042 * 2043 * Cancelling an URB is a tricky thing. The USBProxy backend can not 2044 * all cancel it and we must keep the URB around until it's ripe and 2045 * can be reaped the normal way. However, we must complete the URB 2046 * now, before leaving this function. This is not nice. sigh. 2047 * 2048 * This function will cancel the URB if it's in-flight and complete 2049 * it. The device will in its pfnCancel method be given the chance to 2050 * say that the URB doesn't need reaping and should be unlinked. 2051 * 2052 * An URB which is in the cancel state after pfnCancel will remain in that 2053 * state and in the async list until its reaped. When it's finally reaped 2054 * it will be unlinked and freed without doing any completion. 2055 * 2056 * There are different modes of canceling an URB. When devices are being 2057 * disconnected etc., they will be completed with an error (CRC). However, 2058 * when the HC needs to temporarily halt communication with a device, the 2059 * URB/TD must be left alone if possible. 2060 * 2039 /** 2040 * The worker for vusbUrbCancel() which is executed on the I/O thread. 2041 * 2042 * @returns nothing. 2061 2043 * @param pUrb The URB to cancel. 2062 * @param modeThe way the URB should be canceled.2063 */ 2064 void vusbUrbCancel(PVUSBURB pUrb, CANCELMODE mode)2044 * @param enmMode The way the URB should be canceled. 2045 */ 2046 static void vusbUrbCancelWorker(PVUSBURB pUrb, CANCELMODE enmMode) 2065 2047 { 2066 2048 vusbUrbAssert(pUrb); … … 2102 2084 { 2103 2085 AssertMsg(pUrb->enmState == VUSBURBSTATE_CANCELLED, ("Invalid state %d, pUrb=%p\n", pUrb->enmState, pUrb)); 2104 switch ( mode)2086 switch (enmMode) 2105 2087 { 2106 2088 default: … … 2117 2099 } 2118 2100 2101 /** 2102 * Cancels an URB with CRC failure. 2103 * 2104 * Cancelling an URB is a tricky thing. The USBProxy backend can not 2105 * all cancel it and we must keep the URB around until it's ripe and 2106 * can be reaped the normal way. However, we must complete the URB 2107 * now, before leaving this function. This is not nice. sigh. 2108 * 2109 * This function will cancel the URB if it's in-flight and complete 2110 * it. The device will in its pfnCancel method be given the chance to 2111 * say that the URB doesn't need reaping and should be unlinked. 2112 * 2113 * An URB which is in the cancel state after pfnCancel will remain in that 2114 * state and in the async list until its reaped. When it's finally reaped 2115 * it will be unlinked and freed without doing any completion. 2116 * 2117 * There are different modes of canceling an URB. When devices are being 2118 * disconnected etc., they will be completed with an error (CRC). However, 2119 * when the HC needs to temporarily halt communication with a device, the 2120 * URB/TD must be left alone if possible. 2121 * 2122 * @param pUrb The URB to cancel. 2123 * @param mode The way the URB should be canceled. 2124 */ 2125 void vusbUrbCancel(PVUSBURB pUrb, CANCELMODE mode) 2126 { 2127 PRTREQ hReq = NULL; 2128 2129 if (pUrb->VUsb.pDev->hUrbIoThread != NIL_RTTHREAD) 2130 { 2131 int rc = RTReqQueueCallVoid(pUrb->VUsb.pDev->hReqQueueCancel, &hReq, 0, 2132 (PFNRT)vusbUrbCancelWorker, 2, pUrb, mode); 2133 Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT); 2134 vusbDevUrbIoThreadWakeup(pUrb->VUsb.pDev); 2135 rc = RTReqWait(hReq, RT_INDEFINITE_WAIT); 2136 AssertRC(rc); 2137 } 2138 else /* Call the worker directly. */ 2139 vusbUrbCancelWorker(pUrb, mode); 2140 } 2141 2119 2142 2120 2143 /** -
trunk/src/VBox/Devices/USB/freebsd/USBProxyDevice-freebsd.cpp
r50236 r52148 673 673 * @copydoc USBPROXYBACK::pfnUrbQueue 674 674 */ 675 static DECLCALLBACK(int) usbProxyFreeBSDUrbQueue(PVUSBURB pUrb) 676 { 677 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 675 static DECLCALLBACK(int) usbProxyFreeBSDUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb) 676 { 678 677 PUSBPROXYDEVFBSD pDevFBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVFBSD); 679 678 PUSBENDPOINTFBSD pEndpointFBSD;
Note:
See TracChangeset
for help on using the changeset viewer.