VirtualBox

Changeset 56402 in vbox for trunk


Ignore:
Timestamp:
Jun 13, 2015 2:58:10 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
101002
Message:

DevATA,PDMCritSect: Changed the AsyncIOSem from RTSEMEVENT to SUPSEMEVENT so it can be signalled in ring-0 too.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmcritsect.h

    r56291 r56402  
    6363VMMR3DECL(bool)     PDMR3CritSectYield(PPDMCRITSECT pCritSect);
    6464VMMR3DECL(const char *) PDMR3CritSectName(PCPDMCRITSECT pCritSect);
    65 VMMR3DECL(int)      PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal);
    6665VMMR3DECL(int)      PDMR3CritSectDelete(PPDMCRITSECT pCritSect);
     66#if defined(IN_RING0) || defined(IN_RING3)
     67VMMDECL(int)        PDMHCCritSectScheduleExitEvent(PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal);
     68#endif
    6769
    6870VMMDECL(int)        PDMCritSectEnter(PPDMCRITSECT pCritSect, int rcBusy);
  • trunk/include/iprt/critsect.h

    r56291 r56402  
    211211RTDECL(int) RTCritSectTryEnterDebug(PRTCRITSECT pCritSect, RTHCUINTPTR uId, RT_SRC_POS_DECL);
    212212
    213 #ifdef IN_RING3 /* Crazy APIs: ring-3 only. */
     213# ifdef IN_RING3 /* Crazy APIs: ring-3 only. */
    214214
    215215/**
     
    252252RTDECL(int) RTCritSectEnterMultipleDebug(size_t cCritSects, PRTCRITSECT *papCritSects, RTUINTPTR uId, RT_SRC_POS_DECL);
    253253
    254 #endif /* IN_RING3 */
     254# endif /* IN_RING3 */
    255255
    256256/**
  • trunk/src/VBox/Devices/Storage/DevATA.cpp

    r56400 r56402  
    1515 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    1616 */
     17
    1718
    1819/*******************************************************************************
     
    3536#define ATA_SAVED_STATE_VERSION_WITHOUT_EVENT_STATUS    17
    3637/** @} */
     38
    3739
    3840/*******************************************************************************
     
    5658#include <VBox/vmm/pgm.h>
    5759
     60#include <VBox/sup.h>
    5861#include <VBox/scsi.h>
    5962
     
    6265#include "ATAPIPassthrough.h"
    6366#include "VBoxDD.h"
     67
    6468
    6569/*******************************************************************************
     
    423427    RTTHREAD            AsyncIOThread;
    424428    /** The event semaphore the thread is waiting on for requests. */
    425     RTSEMEVENT          AsyncIOSem;
     429    SUPSEMEVENT         hAsyncIOSem;
     430    /** The support driver session handle. */
     431    PSUPDRVSESSION      pSupDrvSession;
    426432    /** The request queue for the AIO thread. One element is always unused. */
    427433    ATARequest          aAsyncIORequests[4];
     
    439445    /** The event semaphore the thread is waiting on during suspended I/O. */
    440446    RTSEMEVENT          SuspendIOSem;
    441 #if HC_ARCH_BITS == 32
     447#if 0 /*HC_ARCH_BITS == 32*/
    442448    uint32_t            Alignment0;
    443449#endif
     
    728734    AssertRC(rc);
    729735
    730     rc = PDMR3CritSectScheduleExitEvent(&pCtl->lock, pCtl->AsyncIOSem);
     736    rc = PDMHCCritSectScheduleExitEvent(&pCtl->lock, pCtl->hAsyncIOSem);
    731737    if (RT_FAILURE(rc))
    732738    {
    733         rc = RTSemEventSignal(pCtl->AsyncIOSem);
     739        rc = SUPSemEventSignal(pCtl->pSupDrvSession, pCtl->hAsyncIOSem);
    734740        AssertRC(rc);
    735741    }
     
    50965102            if (pCtl->fSignalIdle)
    50975103                ataR3AsyncSignalIdle(pCtl);
    5098             rc = RTSemEventWait(pCtl->AsyncIOSem, RT_INDEFINITE_WAIT);
     5104            rc = SUPSemEventWaitNoResume(pCtl->pSupDrvSession, pCtl->hAsyncIOSem, RT_INDEFINITE_WAIT);
    50995105            /* Continue if we got a signal by RTThreadPoke().
    51005106             * We will get notified if there is a request to process.
     
    70207026        {
    70217027            ASMAtomicWriteU32(&pThis->aCts[i].fShutdown, true);
    7022             rc = RTSemEventSignal(pThis->aCts[i].AsyncIOSem);
     7028            rc = SUPSemEventSignal(pThis->aCts[i].pSupDrvSession, pThis->aCts[i].hAsyncIOSem);
    70237029            AssertRC(rc);
    70247030            rc = RTSemEventSignal(pThis->aCts[i].SuspendIOSem);
     
    70517057        if (PDMCritSectIsInitialized(&pThis->aCts[i].AsyncIORequestLock))
    70527058            PDMR3CritSectDelete(&pThis->aCts[i].AsyncIORequestLock);
    7053         if (pThis->aCts[i].AsyncIOSem != NIL_RTSEMEVENT)
    7054         {
    7055             RTSemEventDestroy(pThis->aCts[i].AsyncIOSem);
    7056             pThis->aCts[i].AsyncIOSem = NIL_RTSEMEVENT;
     7059        if (pThis->aCts[i].hAsyncIOSem != NIL_SUPSEMEVENT)
     7060        {
     7061            SUPSemEventClose(pThis->aCts[i].pSupDrvSession, pThis->aCts[i].hAsyncIOSem);
     7062            pThis->aCts[i].hAsyncIOSem = NIL_SUPSEMEVENT;
    70577063        }
    70587064        if (pThis->aCts[i].SuspendIOSem != NIL_RTSEMEVENT)
     
    71387144    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
    71397145    {
    7140         pThis->aCts[i].AsyncIOSem = NIL_RTSEMEVENT;
     7146        pThis->aCts[i].hAsyncIOSem = NIL_SUPSEMEVENT;
    71417147        pThis->aCts[i].SuspendIOSem = NIL_RTSEMEVENT;
    71427148        pThis->aCts[i].AsyncIOThread = NIL_RTTHREAD;
     
    74287434         */
    74297435        pCtl->uAsyncIOState = ATA_AIO_NEW;
    7430         rc = RTSemEventCreate(&pCtl->AsyncIOSem);
     7436        pCtl->pSupDrvSession = PDMDevHlpGetSupDrvSession(pDevIns);
     7437        rc = SUPSemEventCreate(pCtl->pSupDrvSession, &pCtl->hAsyncIOSem);
    74317438        AssertLogRelRCReturn(rc, rc);
    74327439        rc = RTSemEventCreate(&pCtl->SuspendIOSem);
     
    74377444                             RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "ATA-%u", i);
    74387445        AssertLogRelRCReturn(rc, rc);
    7439         Assert(  pCtl->AsyncIOThread != NIL_RTTHREAD    && pCtl->AsyncIOSem != NIL_RTSEMEVENT
     7446        Assert(  pCtl->AsyncIOThread != NIL_RTTHREAD    && pCtl->hAsyncIOSem != NIL_SUPSEMEVENT
    74407447               && pCtl->SuspendIOSem != NIL_RTSEMEVENT  && PDMCritSectIsInitialized(&pCtl->AsyncIORequestLock));
    7441         Log(("%s: controller %d AIO thread id %#x; sem %p susp_sem %p\n", __FUNCTION__, i, pCtl->AsyncIOThread, pCtl->AsyncIOSem, pCtl->SuspendIOSem));
     7448        Log(("%s: controller %d AIO thread id %#x; sem %p susp_sem %p\n", __FUNCTION__, i, pCtl->AsyncIOThread, pCtl->hAsyncIOSem, pCtl->SuspendIOSem));
    74427449
    74437450        for (uint32_t j = 0; j < RT_ELEMENTS(pCtl->aIfs); j++)
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r56392 r56402  
    953953    GEN_CHECK_OFF(ATACONTROLLER, fShutdown);
    954954    GEN_CHECK_OFF(ATACONTROLLER, AsyncIOThread);
    955     GEN_CHECK_OFF(ATACONTROLLER, AsyncIOSem);
     955    GEN_CHECK_OFF(ATACONTROLLER, hAsyncIOSem);
    956956    GEN_CHECK_OFF(ATACONTROLLER, aAsyncIORequests[4]);
    957957    GEN_CHECK_OFF(ATACONTROLLER, AsyncIOReqHead);
  • trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp

    r56287 r56402  
    585585         */
    586586        /* update members. */
     587        SUPSEMEVENT hEventToSignal  = pCritSect->s.hEventToSignal;
     588        pCritSect->s.hEventToSignal = NIL_SUPSEMEVENT;
    587589# ifdef IN_RING3
    588         RTSEMEVENT hEventToSignal    = pCritSect->s.EventToSignal;
    589         pCritSect->s.EventToSignal   = NIL_RTSEMEVENT;
    590590#  if defined(PDMCRITSECT_STRICT)
    591591        if (pCritSect->s.Core.pValidatorRec->hThread != NIL_RTTHREAD)
     
    611611        }
    612612
    613 # ifdef IN_RING3
    614613        /* Signal exit event. */
    615         if (hEventToSignal != NIL_RTSEMEVENT)
     614        if (hEventToSignal != NIL_SUPSEMEVENT)
    616615        {
    617             Log8(("Signalling %#x\n", hEventToSignal));
    618             int rc = RTSemEventSignal(hEventToSignal);
     616            Log8(("Signalling %#p\n", hEventToSignal));
     617            int rc = SUPSemEventSignal(pCritSect->s.CTX_SUFF(pVM)->pSession, hEventToSignal);
    619618            AssertRC(rc);
    620619        }
    621 # endif
    622620
    623621# if defined(DEBUG_bird) && defined(IN_RING0)
     
    673671
    674672
     673#if defined(IN_RING0) || defined(IN_RING3)
     674/**
     675 * Schedule a event semaphore for signalling upon critsect exit.
     676 *
     677 * @returns VINF_SUCCESS on success.
     678 * @returns VERR_TOO_MANY_SEMAPHORES if an event was already scheduled.
     679 * @returns VERR_NOT_OWNER if we're not the critsect owner (ring-3 only).
     680 * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
     681 *
     682 * @param   pCritSect       The critical section.
     683 * @param   hEventToSignal  The support driver event semaphore that should be
     684 *                          signalled.
     685 */
     686VMMDECL(int) PDMHCCritSectScheduleExitEvent(PPDMCRITSECT pCritSect, SUPSEMEVENT hEventToSignal)
     687{
     688    AssertPtr(pCritSect);
     689    Assert(!(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NOP));
     690    Assert(hEventToSignal != NIL_SUPSEMEVENT);
     691# ifdef IN_RING3
     692    if (RT_UNLIKELY(!RTCritSectIsOwner(&pCritSect->s.Core)))
     693        return VERR_NOT_OWNER;
     694# endif
     695    if (RT_LIKELY(   pCritSect->s.hEventToSignal == NIL_RTSEMEVENT
     696                  || pCritSect->s.hEventToSignal == hEventToSignal))
     697    {
     698        pCritSect->s.hEventToSignal = hEventToSignal;
     699        return VINF_SUCCESS;
     700    }
     701    return VERR_TOO_MANY_SEMAPHORES;
     702}
     703#endif /* IN_RING0 || IN_RING3 */
     704
     705
    675706/**
    676707 * Checks the caller is the owner of the critical section.
  • trunk/src/VBox/VMM/VMMR3/PDMCritSect.cpp

    r56287 r56402  
    183183                pCritSect->fAutomaticDefaultCritsect = false;
    184184                pCritSect->fUsedByTimerOrSimilar     = false;
    185                 pCritSect->EventToSignal             = NIL_RTSEMEVENT;
     185                pCritSect->hEventToSignal            = NIL_SUPSEMEVENT;
    186186                pCritSect->pszName                   = pszName;
    187187
     
    885885
    886886/**
    887  * Schedule a event semaphore for signalling upon critsect exit.
    888  *
    889  * @returns VINF_SUCCESS on success.
    890  * @returns VERR_TOO_MANY_SEMAPHORES if an event was already scheduled.
    891  * @returns VERR_NOT_OWNER if we're not the critsect owner.
    892  * @returns VERR_SEM_DESTROYED if RTCritSectDelete was called while waiting.
    893  *
    894  * @param   pCritSect       The critical section.
    895  * @param   EventToSignal   The semaphore that should be signalled.
    896  */
    897 VMMR3DECL(int) PDMR3CritSectScheduleExitEvent(PPDMCRITSECT pCritSect, RTSEMEVENT EventToSignal)
    898 {
    899     AssertPtr(pCritSect);
    900     Assert(!(pCritSect->s.Core.fFlags & RTCRITSECT_FLAGS_NOP));
    901     Assert(EventToSignal != NIL_RTSEMEVENT);
    902     if (RT_UNLIKELY(!RTCritSectIsOwner(&pCritSect->s.Core)))
    903         return VERR_NOT_OWNER;
    904     if (RT_LIKELY(   pCritSect->s.EventToSignal == NIL_RTSEMEVENT
    905                   || pCritSect->s.EventToSignal == EventToSignal))
    906     {
    907         pCritSect->s.EventToSignal = EventToSignal;
    908         return VINF_SUCCESS;
    909     }
    910     return VERR_TOO_MANY_SEMAPHORES;
    911 }
    912 
    913 
    914 /**
    915887 * PDMR3CritSectBothCountOwned worker.
    916888 *
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r56287 r56402  
    301301    /** Alignment padding. */
    302302    bool                            afPadding[2];
    303     /** Event semaphore that is scheduled to be signaled upon leaving the
    304      * critical section. This is Ring-3 only of course. */
    305     RTSEMEVENT                      EventToSignal;
     303    /** Support driver event semaphore that is scheduled to be signaled upon leaving
     304     * the critical section. This is only for Ring-3 and Ring-0. */
     305    SUPSEMEVENT                     hEventToSignal;
    306306    /** The lock name. */
    307307    R3PTRTYPE(const char *)         pszName;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette