VirtualBox

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


Ignore:
Timestamp:
Apr 10, 2024 1:29:23 PM (8 months ago)
Author:
vboxsync
Message:

DevOHCI: Reworked endpoint skipping to use the new cancel by address/endpoint/direction callback (see bugref:10634).

File:
1 edited

Legend:

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

    r104250 r104276  
    693693/** RD  - Resume detect. */
    694694#define OHCI_INTR_RESUME_DETECT             RT_BIT(3)
    695 /** UE  - Unrecoverable error. */
     695/** UE  - ",erable error. */
    696696#define OHCI_INTR_UNRECOVERABLE_ERROR       RT_BIT(4)
    697697/** FNO - Frame number overflow. */
     
    20282028}
    20292029
     2030#if 0
    20302031/**
    20312032 * Returns a URB associated with an in-flight TD, if any.
     
    20452046    return NULL;
    20462047}
     2048#endif
    20472049
    20482050/**
     
    30783080    ohciR3Unlock(pThisCC);
    30793081    return fRetire;
     3082}
     3083
     3084
     3085/**
     3086 * Determine transfer direction from an endpoint descriptor.
     3087 * NB: This may fail if the direction is not valid. If it does fail,
     3088 * we do not raise an unrecoverable error but the caller may wish to.
     3089 */
     3090static bool ohciR3GetDirection(PPDMDEVINS pDevIns, POHCI pThis, POHCICC pThisCC, PCOHCIED pEd, VUSBDIRECTION *pEnmDir)
     3091{
     3092    RT_NOREF(pThisCC);
     3093    RT_NOREF(pThis);
     3094    VUSBDIRECTION   enmDir = VUSBDIRECTION_INVALID;
     3095
     3096    if (pEd->hwinfo & ED_HWINFO_ISO)
     3097    {
     3098        switch (pEd->hwinfo & ED_HWINFO_DIR)
     3099        {
     3100            case ED_HWINFO_OUT: enmDir = VUSBDIRECTION_OUT; break;
     3101            case ED_HWINFO_IN:  enmDir = VUSBDIRECTION_IN;  break;
     3102            default:
     3103                Log(("ohciR3GetDirection: Invalid direction!!!! Ed.hwinfo=%#x\n", pEd->hwinfo));
     3104                *pEnmDir = VUSBDIRECTION_INVALID;
     3105                return false;
     3106        }
     3107    }
     3108    else
     3109    {
     3110        switch (pEd->hwinfo & ED_HWINFO_DIR)
     3111        {
     3112            case ED_HWINFO_OUT: enmDir = VUSBDIRECTION_OUT; break;
     3113            case ED_HWINFO_IN:  enmDir = VUSBDIRECTION_IN;  break;
     3114            default:
     3115                /* We must read the TD to determine direction. */
     3116                uint32_t    TdAddr = pEd->HeadP & ED_PTR_MASK;
     3117                OHCITD      Td;
     3118                ohciR3ReadTd(pDevIns, TdAddr, &Td);
     3119                switch (Td.hwinfo & TD_HWINFO_DIR)
     3120                {
     3121                    case TD_HWINFO_OUT: enmDir = VUSBDIRECTION_OUT; break;
     3122                    case TD_HWINFO_IN:  enmDir = VUSBDIRECTION_IN; break;
     3123                    case 0:             enmDir = VUSBDIRECTION_SETUP; break;
     3124                    default:
     3125                        Log(("ohciR3GetDirection: Invalid direction!!!! Td.hwinfo=%#x Ed.hwinfo=%#x\n", Td.hwinfo, pEd->hwinfo));
     3126                        *pEnmDir = VUSBDIRECTION_INVALID;
     3127                        return false;
     3128                }
     3129        }
     3130   }
     3131
     3132    *pEnmDir = enmDir;
     3133    return true;
    30803134}
    30813135
     
    38343888                 * cancel outstanding URBs, if any.
    38353889                 */
    3836                 uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK;
    3837                 PVUSBURB pUrb = ohciR3TdInFlightUrb(pThisCC, TdAddr);
    3838                 if (pUrb)
    3839                     pThisCC->RootHub.pIRhConn->pfnCancelUrbsEp(pThisCC->RootHub.pIRhConn, pUrb);
     3890                uint8_t uAddr  = Ed.hwinfo & ED_HWINFO_FUNCTION;
     3891                uint8_t uEndPt = (Ed.hwinfo & ED_HWINFO_ENDPOINT) >> ED_HWINFO_ENDPOINT_SHIFT;
     3892                VUSBDIRECTION enmDir;
     3893                if (ohciR3GetDirection(pDevIns, pThis, pThisCC, &Ed, &enmDir))
     3894                {
     3895                    pThisCC->RootHub.pIRhConn->pfnAbortEpByAddr(pThisCC->RootHub.pIRhConn, uAddr, uEndPt, enmDir);
     3896                }
    38403897            }
    38413898        }
     
    38903947            {
    38913948                LogFlow(("ohciR3UndoBulkList: Ed=%#010RX32 Ed.TailP=%#010RX32 UNDO\n", EdAddr, Ed.TailP));
    3892                 PVUSBURB pUrb = ohciR3TdInFlightUrb(pThisCC, TdAddr);
    3893                 if (pUrb)
    3894                     pThisCC->RootHub.pIRhConn->pfnCancelUrbsEp(pThisCC->RootHub.pIRhConn, pUrb);
     3949               /* First we need to determine the transfer direction, which may fail(!). */
     3950               uint8_t uAddr  = Ed.hwinfo & ED_HWINFO_FUNCTION;
     3951               uint8_t uEndPt = (Ed.hwinfo & ED_HWINFO_ENDPOINT) >> ED_HWINFO_ENDPOINT_SHIFT;
     3952               VUSBDIRECTION enmDir;
     3953               if (ohciR3GetDirection(pDevIns, pThis, pThisCC, &Ed, &enmDir))
     3954               {
     3955                   pThisCC->RootHub.pIRhConn->pfnAbortEpByAddr(pThisCC->RootHub.pIRhConn, uAddr, uEndPt, enmDir);
     3956               }
    38953957            }
    38963958        }
     
    40544116                /* If the ED is in 'skip' state, no transactions on it are allowed and we must
    40554117                 * cancel outstanding URBs, if any.
     4118                 * First we need to determine the transfer direction, which may fail(!).
    40564119                 */
    4057                 uint32_t TdAddr = Ed.HeadP & ED_PTR_MASK;
    4058                 PVUSBURB pUrb = ohciR3TdInFlightUrb(pThisCC, TdAddr);
    4059                 if (pUrb)
    4060                     pThisCC->RootHub.pIRhConn->pfnCancelUrbsEp(pThisCC->RootHub.pIRhConn, pUrb);
     4120                uint8_t uAddr  = Ed.hwinfo & ED_HWINFO_FUNCTION;
     4121                uint8_t uEndPt = (Ed.hwinfo & ED_HWINFO_ENDPOINT) >> ED_HWINFO_ENDPOINT_SHIFT;
     4122                VUSBDIRECTION enmDir;
     4123                if (ohciR3GetDirection(pDevIns, pThis, pThisCC, &Ed, &enmDir))
     4124                {
     4125                    pThisCC->RootHub.pIRhConn->pfnAbortEpByAddr(pThisCC->RootHub.pIRhConn, uAddr, uEndPt, enmDir);
     4126                }
    40614127            }
    40624128        }
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