Changeset 93989 in vbox for trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp
- Timestamp:
- Feb 28, 2022 3:28:20 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp
r93979 r93989 245 245 * @param pThis The VUSB roothub device instance. 246 246 * @param uPort The port to get the device for. 247 * @param pszWho Caller of this method. 247 248 * 248 249 * @note The reference count of the VUSB device structure is retained to prevent it from going away. 249 250 */ 250 static PVUSBDEV vusbR3RhGetVUsbDevByPortRetain(PVUSBROOTHUB pThis, uint32_t uPort )251 static PVUSBDEV vusbR3RhGetVUsbDevByPortRetain(PVUSBROOTHUB pThis, uint32_t uPort, const char *pszWho) 251 252 { 252 253 PVUSBDEV pDev = NULL; … … 258 259 pDev = pThis->apDevByPort[uPort]; 259 260 if (RT_LIKELY(pDev)) 260 vusbDevRetain(pDev );261 vusbDevRetain(pDev, pszWho); 261 262 262 263 RTCritSectLeave(&pThis->CritSectDevices); … … 272 273 * @param pThis The VUSB roothub device instance. 273 274 * @param u8Address The address to get the device for. 275 * @param pszWho Caller of this method. 274 276 * 275 277 * @note The reference count of the VUSB device structure is retained to prevent it from going away. 276 278 */ 277 static PVUSBDEV vusbR3RhGetVUsbDevByAddrRetain(PVUSBROOTHUB pThis, uint8_t u8Address )279 static PVUSBDEV vusbR3RhGetVUsbDevByAddrRetain(PVUSBROOTHUB pThis, uint8_t u8Address, const char *pszWho) 278 280 { 279 281 PVUSBDEV pDev = NULL; … … 285 287 pDev = pThis->apDevByAddr[u8Address]; 286 288 if (RT_LIKELY(pDev)) 287 vusbDevRetain(pDev );289 vusbDevRetain(pDev, pszWho); 288 290 289 291 RTCritSectLeave(&pThis->CritSectDevices); … … 466 468 pUsbIns->pvVUsbDev2 = NULL; 467 469 } 468 vusbDevRelease(pDev );470 vusbDevRelease(pDev, "vusbPDMHubAttachDevice"); 469 471 return rc; 470 472 } … … 487 489 vusbDevSetStateCmp(pDev, VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_RESET); 488 490 vusbHubDetach(pThis, pDev); 489 vusbDevRelease(pDev );491 vusbDevRelease(pDev, "vusbPDMHubDetachDevice"); 490 492 return VINF_SUCCESS; 491 493 } … … 521 523 Assert(pUrb->enmState != VUSBURBSTATE_FREE); 522 524 525 #ifdef LOG_ENABLED 526 vusbUrbTrace(pUrb, "vusbRhFreeUrb", true); 527 #endif 528 523 529 /* 524 530 * Free the URB description (logging builds only). … … 536 542 537 543 vusbUrbPoolFree(&pUrb->pVUsb->pDev->UrbPool, pUrb); 538 vusbDevRelease(pDev );544 vusbDevRelease(pDev, "vusbRhFreeUrb"); 539 545 } 540 546 else 541 vusbUrbPoolFree(&pRh-> Dev.UrbPool, pUrb);547 vusbUrbPoolFree(&pRh->UrbPool, pUrb); 542 548 } 543 549 … … 550 556 { 551 557 RT_NOREF(pszTag); 552 PVUSBURBPOOL pUrbPool = &pRh-> Dev.UrbPool;558 PVUSBURBPOOL pUrbPool = &pRh->UrbPool; 553 559 554 560 if (RT_UNLIKELY(cbData > (32 * _1M))) … … 560 566 PVUSBDEV pDev; 561 567 if (uPort == VUSB_DEVICE_PORT_INVALID) 562 pDev = vusbR3RhGetVUsbDevByAddrRetain(pRh, DstAddress );568 pDev = vusbR3RhGetVUsbDevByAddrRetain(pRh, DstAddress, "vusbRhNewUrb"); 563 569 else 564 pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort );570 pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhNewUrb"); 565 571 566 572 if (pDev) … … 602 608 (pUrb->enmDir == VUSBDIRECTION_IN) ? '<' : ((pUrb->enmDir == VUSBDIRECTION_SETUP) ? 's' : '>'), 603 609 pRh->iSerial, pszTag ? pszTag : "<none>"); 610 611 vusbUrbTrace(pUrb, "vusbRhNewUrb", false); 604 612 #endif 605 613 } … … 817 825 LogFlow(("vusR3bRhPowerOn: pRh=%p\n", pRh)); 818 826 819 Assert( pRh-> Dev.enmState != VUSB_DEVICE_STATE_DETACHED820 && pRh-> Dev.enmState != VUSB_DEVICE_STATE_RESET);821 822 if (pRh-> Dev.enmState == VUSB_DEVICE_STATE_ATTACHED)823 pRh-> Dev.enmState = VUSB_DEVICE_STATE_POWERED;827 Assert( pRh->enmState != VUSB_DEVICE_STATE_DETACHED 828 && pRh->enmState != VUSB_DEVICE_STATE_RESET); 829 830 if (pRh->enmState == VUSB_DEVICE_STATE_ATTACHED) 831 pRh->enmState = VUSB_DEVICE_STATE_POWERED; 824 832 825 833 return VINF_SUCCESS; … … 833 841 LogFlow(("vusbR3RhDevPowerOff: pThis=%p\n", pThis)); 834 842 835 Assert( pThis-> Dev.enmState != VUSB_DEVICE_STATE_DETACHED836 && pThis-> Dev.enmState != VUSB_DEVICE_STATE_RESET);843 Assert( pThis->enmState != VUSB_DEVICE_STATE_DETACHED 844 && pThis->enmState != VUSB_DEVICE_STATE_RESET); 837 845 838 846 /* … … 843 851 VUSBIRhReapAsyncUrbs(&pThis->IRhConnector, uPort, 0); 844 852 845 pThis-> Dev.enmState = VUSB_DEVICE_STATE_ATTACHED;853 pThis->enmState = VUSB_DEVICE_STATE_ATTACHED; 846 854 return VINF_SUCCESS; 847 855 } … … 944 952 else 945 953 { 946 vusbDevRetain(&pRh->Dev);947 pUrb->pVUsb->pDev = &pRh->Dev;948 954 Log(("vusb: pRh=%p: SUBMIT: Address %i not found!!!\n", pRh, pUrb->DstAddress)); 949 955 … … 980 986 { 981 987 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); NOREF(pRh); 982 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort); 983 984 if ( !pDev 985 || RTListIsEmpty(&pDev->LstAsyncUrbs)) 988 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhReapAsyncUrbs"); 989 990 if (!pDev) 986 991 return; 987 992 988 STAM_PROFILE_START(&pRh->StatReapAsyncUrbs, a); 989 int rc = vusbDevIoThreadExecSync(pDev, (PFNRT)vusbRhReapAsyncUrbsWorker, 2, pDev, cMillies); 990 AssertRC(rc); 991 STAM_PROFILE_STOP(&pRh->StatReapAsyncUrbs, a); 992 993 vusbDevRelease(pDev); 993 if (!RTListIsEmpty(&pDev->LstAsyncUrbs)) 994 { 995 STAM_PROFILE_START(&pRh->StatReapAsyncUrbs, a); 996 int rc = vusbDevIoThreadExecSync(pDev, (PFNRT)vusbRhReapAsyncUrbsWorker, 2, pDev, cMillies); 997 AssertRC(rc); 998 STAM_PROFILE_STOP(&pRh->StatReapAsyncUrbs, a); 999 } 1000 1001 vusbDevRelease(pDev, "vusbRhReapAsyncUrbs"); 994 1002 } 995 1003 … … 1094 1102 { 1095 1103 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1096 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort );1104 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhAbortEp"); 1097 1105 1098 1106 if (pDev->pHub != pRh) … … 1100 1108 1101 1109 vusbDevIoThreadExecSync(pDev, (PFNRT)vusbRhAbortEpWorker, 3, pDev, EndPt, enmDir); 1102 vusbDevRelease(pDev );1110 vusbDevRelease(pDev, "vusbRhAbortEp"); 1103 1111 1104 1112 /* The reaper thread will take care of completing the URB. */ … … 1187 1195 PVUSBROOTHUB pRh = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1188 1196 AssertReturn(pRh, 0); 1189 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort ); AssertPtr(pDev);1197 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pRh, uPort, "vusbRhUpdateIsocFrameDelta"); AssertPtr(pDev); 1190 1198 PVUSBPIPE pPipe = &pDev->aPipes[EndPt]; 1191 1199 uint32_t *puLastFrame; … … 1200 1208 uFrameDelta += uMaxVal; 1201 1209 1202 vusbDevRelease(pDev );1210 vusbDevRelease(pDev, "vusbRhUpdateIsocFrameDelta"); 1203 1211 return (uint16_t)uFrameDelta; 1204 1212 } … … 1210 1218 { 1211 1219 PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1212 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort );1220 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevReset"); 1213 1221 AssertPtr(pDev); 1214 1222 1215 1223 int rc = VUSBIDevReset(&pDev->IDevice, fResetOnLinux, pfnDone, pvUser, pVM); 1216 vusbDevRelease(pDev );1224 vusbDevRelease(pDev, "vusbR3RhDevReset"); 1217 1225 return rc; 1218 1226 } … … 1223 1231 { 1224 1232 PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1225 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort );1233 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevPowerOn"); 1226 1234 AssertPtr(pDev); 1227 1235 1228 1236 int rc = VUSBIDevPowerOn(&pDev->IDevice); 1229 vusbDevRelease(pDev );1237 vusbDevRelease(pDev, "vusbR3RhDevPowerOn"); 1230 1238 return rc; 1231 1239 } … … 1236 1244 { 1237 1245 PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1238 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort );1246 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevPowerOff"); 1239 1247 AssertPtr(pDev); 1240 1248 1241 1249 int rc = VUSBIDevPowerOff(&pDev->IDevice); 1242 vusbDevRelease(pDev );1250 vusbDevRelease(pDev, "vusbR3RhDevPowerOff"); 1243 1251 return rc; 1244 1252 } … … 1249 1257 { 1250 1258 PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1251 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort );1259 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevGetState"); 1252 1260 AssertPtr(pDev); 1253 1261 1254 1262 VUSBDEVICESTATE enmState = VUSBIDevGetState(&pDev->IDevice); 1255 vusbDevRelease(pDev );1263 vusbDevRelease(pDev, "vusbR3RhDevGetState"); 1256 1264 return enmState; 1257 1265 } … … 1262 1270 { 1263 1271 PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1264 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort );1272 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevIsSavedStateSupported"); 1265 1273 AssertPtr(pDev); 1266 1274 1267 1275 bool fSavedStateSupported = VUSBIDevIsSavedStateSupported(&pDev->IDevice); 1268 vusbDevRelease(pDev );1276 vusbDevRelease(pDev, "vusbR3RhDevIsSavedStateSupported"); 1269 1277 return fSavedStateSupported; 1270 1278 } … … 1275 1283 { 1276 1284 PVUSBROOTHUB pThis = VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface); 1277 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort );1285 PVUSBDEV pDev = vusbR3RhGetVUsbDevByPortRetain(pThis, uPort, "vusbR3RhDevGetSpeed"); 1278 1286 AssertPtr(pDev); 1279 1287 1280 1288 VUSBSPEED enmSpeed = pDev->IDevice.pfnGetSpeed(&pDev->IDevice); 1281 vusbDevRelease(pDev );1289 vusbDevRelease(pDev, "vusbR3RhDevGetSpeed"); 1282 1290 return enmSpeed; 1283 1291 } … … 1509 1517 PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns); 1510 1518 1511 vusbUrbPoolDestroy(&pRh-> Dev.UrbPool);1519 vusbUrbPoolDestroy(&pRh->UrbPool); 1512 1520 if (pRh->pszName) 1513 1521 { … … 1573 1581 pDrvIns->IBase.pfnQueryInterface = vusbRhQueryInterface; 1574 1582 /* the usb device */ 1575 pThis->Dev.enmState = VUSB_DEVICE_STATE_ATTACHED; 1576 pThis->Dev.cRefs = 1; 1583 pThis->enmState = VUSB_DEVICE_STATE_ATTACHED; 1577 1584 //pThis->hub.cPorts - later 1578 1585 pThis->cDevices = 0; 1579 pThis->Dev.pHub = pThis;1580 1586 RTStrAPrintf(&pThis->pszName, "RootHub#%d", pDrvIns->iInstance); 1581 1587 /* misc */ … … 1629 1635 Log(("vusbRhConstruct: fHcVersions=%u\n", pThis->fHcVersions)); 1630 1636 1631 rc = vusbUrbPoolInit(&pThis-> Dev.UrbPool);1637 rc = vusbUrbPoolInit(&pThis->UrbPool); 1632 1638 if (RT_FAILURE(rc)) 1633 1639 return rc; … … 1792 1798 "/VUSB/%d/FramesProcessedClbk", pDrvIns->iInstance); 1793 1799 #endif 1794 PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis-> Dev.UrbPool.cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.",1800 PDMDrvHlpSTAMRegisterF(pDrvIns, (void *)&pThis->UrbPool.cUrbsInPool, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "The number of URBs in the pool.", 1795 1801 "/VUSB/%d/cUrbsInPool", pDrvIns->iInstance); 1796 1802
Note:
See TracChangeset
for help on using the changeset viewer.