VirtualBox

Changeset 77000 in vbox for trunk/src/VBox/Devices/USB


Ignore:
Timestamp:
Jan 26, 2019 10:30:14 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128422
Message:

Devices/USB: Create the USB I/O thread for each device during the attach phase (as it was destructed during a detach) to fix a debug assertion when saving a VM state where the device gets reattached during the process

Location:
trunk/src/VBox/Devices/USB
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r76553 r77000  
    234234{
    235235    LogFlow(("vusbHubAttach: pHub=%p[%s] pDev=%p[%s]\n", pHub, pHub->pszName, pDev, pDev->pUsbIns->pszName));
    236     AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
    237 
    238     pDev->pHub = pHub;
    239     pDev->enmState = VUSB_DEVICE_STATE_ATTACHED;
    240 
    241     /* noone else ever messes with the default pipe while we are attached */
    242     vusbDevMapEndpoint(pDev, &g_Endpoint0);
    243     vusbDevDoSelectConfig(pDev, &g_Config0);
    244 
    245     int rc = pHub->pOps->pfnAttach(pHub, pDev);
    246     if (RT_FAILURE(rc))
    247     {
    248         pDev->pHub = NULL;
    249         pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
    250     }
    251     return rc;
     236    return vusbDevAttach(pDev, pHub);
    252237}
    253238
  • trunk/src/VBox/Devices/USB/VUSBDevice.cpp

    r76684 r77000  
    12141214
    12151215/**
     1216 * Attaches a device to the given hub.
     1217 *
     1218 * @returns VBox status code.
     1219 * @param   pDev        The device to attach.
     1220 * @param   pHub        THe hub to attach to.
     1221 */
     1222int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub)
     1223{
     1224    AssertMsg(pDev->enmState == VUSB_DEVICE_STATE_DETACHED, ("enmState=%d\n", pDev->enmState));
     1225
     1226    pDev->pHub = pHub;
     1227    pDev->enmState = VUSB_DEVICE_STATE_ATTACHED;
     1228
     1229    /* noone else ever messes with the default pipe while we are attached */
     1230    vusbDevMapEndpoint(pDev, &g_Endpoint0);
     1231    vusbDevDoSelectConfig(pDev, &g_Config0);
     1232
     1233    /* Create I/O thread and attach to the hub. */
     1234    int rc = vusbDevUrbIoThreadCreate(pDev);
     1235    if (RT_SUCCESS(rc))
     1236        rc = pHub->pOps->pfnAttach(pHub, pDev);
     1237
     1238    if (RT_FAILURE(rc))
     1239    {
     1240        pDev->pHub = NULL;
     1241        pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
     1242    }
     1243
     1244    return rc;
     1245}
     1246
     1247
     1248/**
    12161249 * Detaches a device from the hub it's attached to.
    12171250 *
     
    12451278    vusbDevUrbIoThreadDestroy(pDev);
    12461279
    1247     int rc = RTReqQueueDestroy(pDev->hReqQueueSync);
    1248     AssertRC(rc);
    1249     pDev->hReqQueueSync = NIL_RTREQQUEUE;
    1250 
    12511280    vusbDevSetState(pDev, VUSB_DEVICE_STATE_DETACHED);
    12521281    pDev->pHub = NULL;
     
    12831312
    12841313    vusbUrbPoolDestroy(&pDev->UrbPool);
     1314
     1315    int rc = RTReqQueueDestroy(pDev->hReqQueueSync);
     1316    AssertRC(rc);
     1317    pDev->hReqQueueSync = NIL_RTREQQUEUE;
    12851318
    12861319    RTCritSectDelete(&pDev->CritSectAsyncUrbs);
     
    17151748}
    17161749
    1717 
    1718 static DECLCALLBACK(int) vusbDevGetDescriptorCacheWorker(PPDMUSBINS pUsbIns, PCPDMUSBDESCCACHE *ppDescCache)
    1719 {
    1720     *ppDescCache = pUsbIns->pReg->pfnUsbGetDescriptorCache(pUsbIns);
    1721     return VINF_SUCCESS;
    1722 }
    17231750
    17241751/**
     
    17821809    AssertRCReturn(rc, rc);
    17831810
    1784     /* Create I/O thread. */
    1785     rc = vusbDevUrbIoThreadCreate(pDev);
    1786     AssertRCReturn(rc, rc);
    1787 
    17881811    /*
    17891812     * Create the reset timer.
     
    18021825     * Get the descriptor cache from the device. (shall cannot fail)
    18031826     */
    1804     rc = vusbDevIoThreadExecSync(pDev, (PFNRT)vusbDevGetDescriptorCacheWorker, 2, pUsbIns, &pDev->pDescCache);
    1805     AssertRC(rc);
     1827    pDev->pDescCache = pUsbIns->pReg->pfnUsbGetDescriptorCache(pUsbIns);
    18061828    AssertPtr(pDev->pDescCache);
    18071829#ifdef VBOX_STRICT
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r76565 r77000  
    298298void vusbDevMapEndpoint(PVUSBDEV dev, PCVUSBDESCENDPOINTEX ep);
    299299int vusbDevDetach(PVUSBDEV pDev);
     300int vusbDevAttach(PVUSBDEV pDev, PVUSBHUB pHub);
    300301DECLINLINE(PVUSBROOTHUB) vusbDevGetRh(PVUSBDEV pDev);
    301302size_t vusbDevMaxInterfaces(PVUSBDEV dev);
     
    738739/** Strings for the CTLSTAGE enum values. */
    739740extern const char * const g_apszCtlStates[4];
    740 /** Default message pipe. */
    741 extern const VUSBDESCENDPOINTEX g_Endpoint0;
    742 /** Default configuration. */
    743 extern const VUSBDESCCONFIGEX g_Config0;
    744741
    745742RT_C_DECLS_END
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette