VirtualBox

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


Ignore:
Timestamp:
Feb 28, 2022 12:03:21 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150204
Message:

Devices/USB: Fix for regression introduced with r150168 where a guest failed to enumerate USB devices if more than one device was on the bus when the VM was powered on. Simplify the code even more to not require any lists for devices in the default state, bugref:10196

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

Legend:

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

    r93956 r93974  
    430430    pThis->apDevByPort[uPort]  = NULL;
    431431
    432     if (pDev->u8Address == VUSB_DEFAULT_ADDRESS)
    433     {
    434         AssertPtr(pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS]);
    435 
    436         if (pDev == pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS])
    437             pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS] = pDev->pNextDefAddr;
    438         else
    439         {
    440             /* Search the list for the device and remove it. */
    441             PVUSBDEV pDevPrev = pThis->apDevByAddr[VUSB_DEFAULT_ADDRESS];
    442 
    443             while (   pDevPrev
    444                    && pDevPrev->pNextDefAddr != pDev)
    445                 pDevPrev = pDevPrev->pNextDefAddr;
    446 
    447             AssertPtr(pDevPrev);
    448             pDevPrev->pNextDefAddr = pDev->pNextDefAddr;
    449         }
    450 
    451         pDev->pNextDefAddr = NULL;
    452     }
    453     else
     432    if (pDev->u8Address != VUSB_INVALID_ADDRESS)
    454433    {
    455434        Assert(pThis->apDevByAddr[pDev->u8Address] == pDev);
  • trunk/src/VBox/Devices/USB/VUSBDevice.cpp

    r93955 r93974  
    10331033
    10341034    /* Remove the device from the current address. */
    1035     if (pDev->u8Address == VUSB_DEFAULT_ADDRESS)
    1036     {
    1037         AssertPtr(pRh->apDevByAddr[VUSB_DEFAULT_ADDRESS]);
    1038 
    1039         if (pDev == pRh->apDevByAddr[VUSB_DEFAULT_ADDRESS])
    1040             pRh->apDevByAddr[VUSB_DEFAULT_ADDRESS] = pDev->pNextDefAddr;
    1041         else
    1042         {
    1043             /* Search the list for the device and remove it. */
    1044             PVUSBDEV pDevPrev = pRh->apDevByAddr[VUSB_DEFAULT_ADDRESS];
    1045 
    1046             while (   pDevPrev
    1047                    && pDevPrev->pNextDefAddr != pDev)
    1048                 pDevPrev = pDevPrev->pNextDefAddr;
    1049 
    1050             AssertPtr(pDevPrev);
    1051             pDevPrev->pNextDefAddr = pDev->pNextDefAddr;
    1052         }
    1053 
    1054         pDev->pNextDefAddr = NULL;
    1055     }
    1056     else if (pDev->u8Address != VUSB_INVALID_ADDRESS)
     1035    if (pDev->u8Address != VUSB_INVALID_ADDRESS)
     1036    {
     1037        Assert(pRh->apDevByAddr[VUSB_DEFAULT_ADDRESS] == pDev);
    10571038        pRh->apDevByAddr[pDev->u8Address] = NULL;
     1039    }
    10581040
    10591041    if (u8Address == VUSB_DEFAULT_ADDRESS)
     
    10631045        if (pDevDef)
    10641046        {
     1047            pDevDef->u8Address = VUSB_INVALID_ADDRESS;
     1048            pDevDef->u8NewAddress = VUSB_INVALID_ADDRESS;
    10651049            vusbDevSetStateCmp(pDevDef, VUSB_DEVICE_STATE_POWERED, VUSB_DEVICE_STATE_DEFAULT);
    10661050            Log(("2 DEFAULT ADDRS\n"));
    10671051        }
    10681052
    1069         pDev->pNextDefAddr = pDevDef;
    10701053        pRh->apDevByAddr[VUSB_DEFAULT_ADDRESS] = pDev;
    10711054        vusbDevSetState(pDev, VUSB_DEVICE_STATE_DEFAULT);
     
    10781061    }
    10791062
     1063    pDev->u8Address = u8Address;
    10801064    RTCritSectLeave(&pRh->CritSectDevices);
    1081 
    1082     pDev->u8Address = u8Address;
    10831065
    10841066    Log(("vusb: %p[%s]/%i: Assigned address %u\n",
     
    18071789    pDev->IDevice.pfnGetSpeed = vusbIDeviceGetSpeed;
    18081790    pDev->pUsbIns = pUsbIns;
    1809     pDev->pNextDefAddr = NULL;
    18101791    pDev->pHub = NULL;
    18111792    pDev->enmState = VUSB_DEVICE_STATE_DETACHED;
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r93955 r93974  
    225225    /** Pointer to the PDM USB device instance. */
    226226    PPDMUSBINS          pUsbIns;
    227     /** Next device in the chain of devices with the default address. */
    228     PVUSBDEV            pNextDefAddr;
    229227    /** Pointer to the hub this device is attached to. */
    230228    PVUSBHUB            pHub;
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