VirtualBox

Changeset 32010 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 26, 2010 4:51:26 PM (14 years ago)
Author:
vboxsync
Message:

VUSB: Added a way to cancel URBs without failing the transfer.

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

Legend:

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

    r31249 r32010  
    24162416     */
    24172417    int cFmAge = ohci_in_flight_remove_urb(pOhci, pUrb);
     2418    if (pUrb->enmStatus == VUSBSTATUS_UNDO)
     2419    {
     2420        /* Leave the TD alone - the HCD doesn't want us talking to the device. */
     2421        Log(("%s: ohciRhXferCompletion: CANCELED {ED=%#010x cTds=%d TD0=%#010x age %d}\n",
     2422             pUrb->pszDesc, pUrb->Hci.EdAddr, pUrb->Hci.cTds, pUrb->Hci.paTds[0].TdAddr, cFmAge));
     2423        STAM_COUNTER_INC(&pOhci->StatDroppedUrbs);
     2424        return;
     2425    }
    24182426    bool fHasBeenCanceled = false;
    24192427    if (    (Ed.HeadP & ED_HEAD_HALTED)
     
    24382446    /*
    24392447     * Complete the TD updating and write the back.
    2440      * When appropirate also copy data back to the guest memory.
     2448     * When appropriate also copy data back to the guest memory.
    24412449     */
    24422450    if (pUrb->enmType == VUSBXFERTYPE_ISOC)
  • trunk/src/VBox/Devices/USB/DrvVUSBRootHub.cpp

    r31230 r32010  
    585585     */
    586586    LogFlow(("vusbRhCancelUrbsEp: pRh=%p pUrb=%p\n", pRh));
    587     vusbUrbCancel(pUrb);
     587    vusbUrbCancel(pUrb, CANCELMODE_UNDO);
    588588
    589589    PVUSBURB pRipe;
     
    613613    {
    614614        PVUSBURB pNext = pUrb->VUsb.pNext;
    615         vusbUrbCancel(pUrb);
     615        vusbUrbCancel(pUrb, CANCELMODE_FAIL);
    616616        pUrb = pNext;
    617617    }
  • trunk/src/VBox/Devices/USB/VUSBDevice.cpp

    r28800 r32010  
    10461046        {
    10471047            LogFlow(("%s: vusbDevCancelAllUrbs: CANCELING URB\n", pUrb->pszDesc));
    1048             vusbUrbCancel(pUrb);
     1048            vusbUrbCancel(pUrb, CANCELMODE_FAIL);
    10491049        }
    10501050        pUrb = pNext;
  • trunk/src/VBox/Devices/USB/VUSBInternal.h

    r31230 r32010  
    407407#define VUSBIROOTHUBCONNECTOR_2_VUSBROOTHUB(pInterface) (PVUSBROOTHUB)( (uintptr_t)(pInterface) - RT_OFFSETOF(VUSBROOTHUB, IRhConnector) )
    408408
     409/**
     410 * URB cancellation modes
     411 */
     412typedef enum CANCELMODE
     413{
     414    /** complete the URB with an error (CRC). */
     415    CANCELMODE_FAIL = 0,
     416    /** do not change the URB contents. */
     417    CANCELMODE_UNDO
     418} CANCELMODE;
    409419
    410420/* @} */
     
    417427void vusbUrbTrace(PVUSBURB pUrb, const char *pszMsg, bool fComplete);
    418428void vusbUrbDoReapAsync(PVUSBURB pHead, RTMSINTERVAL cMillies);
    419 void vusbUrbCancel(PVUSBURB pUrb);
     429void vusbUrbCancel(PVUSBURB pUrb, CANCELMODE mode);
    420430void vusbUrbRipe(PVUSBURB pUrb);
    421431void vusbUrbCompletionRh(PVUSBURB pUrb);
  • trunk/src/VBox/Devices/USB/VUSBUrb.cpp

    r30526 r32010  
    20112011 * state and in the async list until its reaped. When it's finally reaped
    20122012 * it will be unlinked and freed without doing any completion.
     2013 *
     2014 * There are different modes of canceling an URB. When devices are being
     2015 * disconnected etc., they will be completed with an error (CRC). However,
     2016 * when the HC needs to temporarily halt communication with a device, the
     2017 * URB/TD must be left alone if possible.
    20132018 *
    20142019 * @param   pUrb        The URB to cancel.
    2015  */
    2016 void vusbUrbCancel(PVUSBURB pUrb)
     2020 * @param   mode        The way the URB should be canceled.
     2021 */
     2022void vusbUrbCancel(PVUSBURB pUrb, CANCELMODE mode)
    20172023{
    20182024    vusbUrbAssert(pUrb);
     
    20542060    {
    20552061        AssertMsg(pUrb->enmState == VUSBURBSTATE_CANCELLED, ("Invalid state %d, pUrb=%p\n", pUrb->enmState, pUrb));
    2056         pUrb->enmStatus = VUSBSTATUS_CRC;
     2062        switch (mode)
     2063        {
     2064            default:
     2065                AssertMsgFailed(("Invalid cancel mode\n"));
     2066            case CANCELMODE_FAIL:
     2067                pUrb->enmStatus = VUSBSTATUS_CRC;
     2068                break;
     2069            case CANCELMODE_UNDO:
     2070                pUrb->enmStatus = VUSBSTATUS_UNDO;
     2071                break;
     2072
     2073        }
    20572074    }
    20582075}
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