VirtualBox

Changeset 82135 in vbox for trunk


Ignore:
Timestamp:
Nov 23, 2019 11:18:35 PM (5 years ago)
Author:
vboxsync
Message:

DevPCNet: Replaced pCanRxQueueR3 with a ring-0 capable semaphore. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevPCNet.cpp

    r82134 r82135  
    316316    /** Transmit signaller - R3. */
    317317    R3PTRTYPE(PPDMQUEUE)                pXmitQueueR3;
    318     /** Receive signaller - R3. */
    319     R3PTRTYPE(PPDMQUEUE)                pCanRxQueueR3;
    320318    /** Pointer to the connector of the attached network driver - R3. */
    321319    PPDMINETWORKUPR3                    pDrvR3;
     
    331329    /** Pointer to the device instance - R0. */
    332330    PPDMDEVINSR0                        pDevInsR0;
    333     /** Receive signaller - R0. */
    334     R0PTRTYPE(PPDMQUEUE)                pCanRxQueueR0;
    335331    /** Transmit signaller - R0. */
    336332    R0PTRTYPE(PPDMQUEUE)                pXmitQueueR0;
     
    340336    /** Pointer to the device instance - RC. */
    341337    PPDMDEVINSRC                        pDevInsRC;
    342     /** Receive signaller - RC. */
    343     RCPTRTYPE(PPDMQUEUE)                pCanRxQueueRC;
    344338    /** Transmit signaller - RC. */
    345339    RCPTRTYPE(PPDMQUEUE)                pXmitQueueRC;
    346340    /** Pointer to the connector of the attached network driver - RC. */
    347341    PPDMINETWORKUPRC                    pDrvRC;
     342    RTRCPTR                             RCPtrAlignment;
    348343
    349344    /** Software Interrupt timer - R3. */
     
    421416    PDMCRITSECT                         CritSect;
    422417    /** Event semaphore for blocking on receive. */
    423     RTSEMEVENT                          hEventOutOfRxSpace;
     418    SUPSEMEVENT                         hEventOutOfRxSpace;
    424419    /** We are waiting/about to start waiting for more receive buffers. */
    425420    bool volatile                       fMaybeOutOfSpace;
     
    16331628}
    16341629
    1635 #ifdef IN_RING3
    1636 
    1637 static DECLCALLBACK(void) pcnetWakeupReceive(PPDMDEVINS pDevIns)
     1630/**
     1631 * Wakes up a receive thread stuck waiting for buffers.
     1632 */
     1633static void pcnetWakeupReceive(PPDMDEVINS pDevIns)
    16381634{
    16391635    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    16401636    STAM_COUNTER_INC(&pThis->StatRxOverflowWakeup);
    1641     if (pThis->hEventOutOfRxSpace != NIL_RTSEMEVENT)
    1642         RTSemEventSignal(pThis->hEventOutOfRxSpace);
    1643 }
     1637    if (pThis->hEventOutOfRxSpace != NIL_SUPSEMEVENT)
     1638    {
     1639        int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventOutOfRxSpace);
     1640        AssertRC(rc);
     1641    }
     1642}
     1643
     1644#ifdef IN_RING3
    16441645
    16451646static DECLCALLBACK(bool) pcnetCanRxQueueConsumer(PPDMDEVINS pDevIns, PPDMQUEUEITEMCORE pItem)
     
    16951696                CSR_CRST(pThis) = ((uint32_t *)&rmd)[1] >> 16; /* Receive Status */
    16961697                if (pThis->fMaybeOutOfSpace)
    1697                 {
    1698 #ifdef IN_RING3
    16991698                    pcnetWakeupReceive(PCNETSTATE_2_DEVINS(pThis));
    1700 #else
    1701                     PPDMQUEUEITEMCORE pItem = PDMQueueAlloc(pThis->CTX_SUFF(pCanRxQueue));
    1702                     if (pItem)
    1703                         PDMQueueInsert(pThis->CTX_SUFF(pCanRxQueue), pItem);
    1704 #endif
    1705                 }
    17061699            }
    17071700            else
     
    47454738#endif
    47464739        PDMCritSectLeave(&pThis->CritSect);
    4747         RTSemEventWait(pThis->hEventOutOfRxSpace, cMillies);
     4740        PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pThis->hEventOutOfRxSpace, cMillies);
    47484741    }
    47494742    STAM_PROFILE_STOP(&pThis->StatRxOverflow, a);
     
    50625055    pThis->pDevInsRC     = PDMDEVINS_2_RCPTR(pDevIns);
    50635056    pThis->pXmitQueueRC  = PDMQueueRCPtr(pThis->pXmitQueueR3);
    5064     pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3);
    50655057#ifdef PCNET_NO_POLLING
    50665058    pThis->pfnEMInterpretInstructionRC += offDelta;
     
    50775069    PPCNETSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PPCNETSTATE);
    50785070
     5071    if (pThis->hEventOutOfRxSpace == NIL_SUPSEMEVENT)
     5072    {
     5073        PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEventOutOfRxSpace);
     5074        PDMDevHlpSUPSemEventClose(pDevIns, pThis->hEventOutOfRxSpace);
     5075        pThis->hEventOutOfRxSpace = NIL_SUPSEMEVENT;
     5076    }
     5077
    50795078    if (PDMCritSectIsInitialized(&pThis->CritSect))
    5080     {
    5081         RTSemEventSignal(pThis->hEventOutOfRxSpace);
    5082         RTSemEventDestroy(pThis->hEventOutOfRxSpace);
    5083         pThis->hEventOutOfRxSpace = NIL_RTSEMEVENT;
    50845079        PDMR3CritSectDelete(&pThis->CritSect);
    5085     }
    50865080    return VINF_SUCCESS;
    50875081}
     
    51075101     * Init what's required to make the destructor safe.
    51085102     */
    5109     pThis->hEventOutOfRxSpace = NIL_RTSEMEVENT;
     5103    pThis->hEventOutOfRxSpace = NIL_SUPSEMEVENT;
    51105104
    51115105    /*
     
    52515245    AssertRCReturn(rc, rc);
    52525246    rc = PDMDevHlpSetDeviceCritSect(pDevIns, &pThis->CritSect);
    5253     AssertRCReturn(rc, rc);
    5254 
    5255     rc = RTSemEventCreate(&pThis->hEventOutOfRxSpace);
    52565247    AssertRCReturn(rc, rc);
    52575248
     
    53625353
    53635354    /*
    5364      * Create the RX notifier signaller.
     5355     * Create the RX notifier semaphore.
    53655356     */
    5366     rc = PDMDevHlpQueueCreate(pDevIns, sizeof(PDMQUEUEITEMCORE), 1, 0,
    5367                               pcnetCanRxQueueConsumer, true, "PCnet-Rcv", &pThis->pCanRxQueueR3);
     5357    rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pThis->hEventOutOfRxSpace);
    53685358    AssertRCReturn(rc, rc);
    5369     pThis->pCanRxQueueR0 = PDMQueueR0Ptr(pThis->pCanRxQueueR3);
    5370     pThis->pCanRxQueueRC = PDMQueueRCPtr(pThis->pCanRxQueueR3);
    53715359
    53725360    /*
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