VirtualBox

Changeset 52513 in vbox


Ignore:
Timestamp:
Aug 28, 2014 1:14:13 PM (10 years ago)
Author:
vboxsync
Message:

USB: Serialize access to the extra state data for control pipes, fixes several assertions in debug builds

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

Legend:

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

    r52301 r52513  
    12251225    pDev->pCurCfgDesc = NULL;
    12261226    for (unsigned i = 0; i < VUSB_PIPE_MAX; i++)
     1227    {
    12271228        vusbMsgFreeExtraData(pDev->aPipes[i].pCtrl);
     1229        RTCritSectDelete(&pDev->aPipes[i].CritSectCtrl);
     1230    }
    12281231    memset(pDev->aPipes, 0, sizeof(pDev->aPipes));
    12291232    return VINF_SUCCESS;
     
    17111714    pDev->paIfStates = NULL;
    17121715    memset(&pDev->aPipes[0], 0, sizeof(pDev->aPipes));
     1716    for (unsigned i = 0; i < RT_ELEMENTS(pDev->aPipes); i++)
     1717    {
     1718        int rc = RTCritSectInit(&pDev->aPipes[i].CritSectCtrl);
     1719        AssertRCReturn(rc, rc);
     1720    }
    17131721    pDev->pResetTimer = NULL;
    17141722
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r52307 r52513  
    125125    /** Pointer to the extra state data required to run a control pipe. */
    126126    PVUSBCTRLEXTRA      pCtrl;
     127    /** Critical section serializing access to the extra state data for a control pipe. */
     128    RTCRITSECT          CritSectCtrl;
    127129    /** Count of active async transfers. */
    128130    volatile uint32_t   async;
  • trunk/src/VBox/Devices/USB/VUSBUrb.cpp

    r52301 r52513  
    935935            break;
    936936    }
    937     vusbUrbCompletionRh(pUrb);
    938937}
    939938
     
    948947    PVUSBDEV        pDev   = pUrb->VUsb.pDev;
    949948    PVUSBPIPE       pPipe  = &pDev->aPipes[pUrb->EndPt];
     949
     950    RTCritSectEnter(&pPipe->CritSectCtrl);
    950951    PVUSBCTRLEXTRA  pExtra = pPipe->pCtrl;
    951952
     
    977978    if (pUrb->enmState != VUSBURBSTATE_CANCELLED)
    978979        pUrb->enmState = VUSBURBSTATE_ALLOCATED;
     980    RTCritSectLeave(&pPipe->CritSectCtrl);
     981
     982    /* Complete the original control URB on the root hub now. */
     983    vusbUrbCompletionRh(pCtrlUrb);
    979984}
    980985
     
    12601265
    12611266    vusbCtrlCompletion(pUrb);
     1267    vusbUrbCompletionRh(pUrb);
    12621268
    12631269    /*
     
    15721578    PVUSBDEV        pDev = pUrb->VUsb.pDev;
    15731579    PVUSBPIPE       pPipe = &pDev->aPipes[pUrb->EndPt];
     1580
     1581    RTCritSectEnter(&pPipe->CritSectCtrl);
    15741582    PVUSBCTRLEXTRA  pExtra = pPipe->pCtrl;
     1583
    15751584    if (!pExtra && !(pExtra = pPipe->pCtrl = vusbMsgAllocExtraData(pUrb)))
     1585    {
     1586        RTCritSectLeave(&pPipe->CritSectCtrl);
    15761587        return VERR_VUSB_NO_URB_MEMORY;
     1588    }
    15771589    PVUSBSETUP      pSetup = pExtra->pMsg;
    15781590
     
    16131625            {
    16141626                Log(("%s: vusbUrbSubmitCtrl: Stall at setup stage (dir=%#x)!!\n", pUrb->pszDesc, pUrb->enmDir));
    1615                 return vusbMsgStall(pUrb);
     1627                vusbMsgStall(pUrb);
     1628                break;
    16161629            }
    16171630
     
    16221635                pUrb->enmStatus = VUSBSTATUS_DNR;
    16231636                vusbUrbCompletionRh(pUrb);
    1624                 return VINF_SUCCESS;
     1637                break;
    16251638            }
    16261639            if (pPipe->pCtrl != pExtra)
     
    16801693                {
    16811694                    Log(("%s: vusbUrbSubmitCtrl: Stall at data stage!!\n", pUrb->pszDesc));
    1682                     return vusbMsgStall(pUrb);
     1695                    vusbMsgStall(pUrb);
     1696                    break;
    16831697                }
    16841698            }
     
    17471761    }
    17481762
     1763    RTCritSectLeave(&pPipe->CritSectCtrl);
    17491764    return VINF_SUCCESS;
    17501765}
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