VirtualBox

Changeset 38847 in vbox


Ignore:
Timestamp:
Sep 23, 2011 1:19:23 PM (13 years ago)
Author:
vboxsync
Message:

PDM: Enter the device critical section for PDM callback.

Location:
trunk
Files:
4 edited

Legend:

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

    r37516 r38847  
    7676 *
    7777 * @returns VBox status.
    78  * @param   pDevIns     The device instance data.
     78 * @param   pDevIns     The device instance data.
     79 * 
     80 * @remarks The device critical section is not entered.  The routine may delete
     81 *          the critical section, so the caller cannot exit it.
    7982 */
    8083typedef DECLCALLBACK(int)   FNPDMDEVDESTRUCT(PPDMDEVINS pDevIns);
     
    9699 * @param   offDelta    The relocation delta relative to the old location.
    97100 *
    98  * @remark  A relocation CANNOT fail.
     101 * @remarks A relocation CANNOT fail.
     102 * 
     103 * @remarks The device critical section is not entered.  The relocations should
     104 *          not normally require any locking.
    99105 */
    100106typedef DECLCALLBACK(void) FNPDMDEVRELOCATE(PPDMDEVINS pDevIns, RTGCINTPTR offDelta);
     
    117123 * @param   cbOut       Size of output data.
    118124 * @param   pcbOut      Where to store the actual size of the output data.
     125 * 
     126 * @remarks Not used.
    119127 */
    120128typedef DECLCALLBACK(int) FNPDMDEVIOCTL(PPDMDEVINS pDevIns, RTUINT uFunction,
     
    129137 * @returns VBox status.
    130138 * @param   pDevIns     The device instance data.
     139 * 
     140 * @remarks Caller enters the device critical section.
    131141 */
    132142typedef DECLCALLBACK(void)   FNPDMDEVPOWERON(PPDMDEVINS pDevIns);
     
    139149 * @returns VBox status.
    140150 * @param   pDevIns     The device instance data.
     151 * 
     152 * @remarks Caller enters the device critical section.
    141153 */
    142154typedef DECLCALLBACK(void)  FNPDMDEVRESET(PPDMDEVINS pDevIns);
     
    150162 * @param   pDevIns     The device instance data.
    151163 * @thread  EMT(0)
     164 * 
     165 * @remarks Caller enters the device critical section.
    152166 */
    153167typedef DECLCALLBACK(void)  FNPDMDEVSUSPEND(PPDMDEVINS pDevIns);
     
    160174 * @returns VBox status.
    161175 * @param   pDevIns     The device instance data.
     176 * 
     177 * @remarks Caller enters the device critical section.
    162178 */
    163179typedef DECLCALLBACK(void)  FNPDMDEVRESUME(PPDMDEVINS pDevIns);
     
    174190 * @param   pDevIns     The device instance data.
    175191 * @thread  EMT(0)
     192 * 
     193 * @remarks Caller enters the device critical section.
    176194 */
    177195typedef DECLCALLBACK(void)   FNPDMDEVPOWEROFF(PPDMDEVINS pDevIns);
     
    192210 * @param   iLUN        The logical unit which is being detached.
    193211 * @param   fFlags      Flags, combination of the PDM_TACH_FLAGS_* \#defines.
     212 * 
     213 * @remarks Caller enters the device critical section.
    194214 */
    195215typedef DECLCALLBACK(int)  FNPDMDEVATTACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
     
    209229 * @param   iLUN        The logical unit which is being detached.
    210230 * @param   fFlags      Flags, combination of the PDMDEVATT_FLAGS_* \#defines.
     231 * 
     232 * @remarks Caller enters the device critical section.
    211233 */
    212234typedef DECLCALLBACK(void)  FNPDMDEVDETACH(PPDMDEVINS pDevIns, unsigned iLUN, uint32_t fFlags);
     
    221243 * @param   iLUN        The logicial unit to query.
    222244 * @param   ppBase      Where to store the pointer to the base interface of the LUN.
     245 * 
     246 * @remarks The device critical section is not entered.
    223247 */
    224248typedef DECLCALLBACK(int) FNPDMDEVQUERYINTERFACE(PPDMDEVINS pDevIns, unsigned iLUN, PPDMIBASE *ppBase);
     
    233257 * @returns VBOX status code.
    234258 * @param   pDevIns     The device instance.
     259 * 
     260 * @remarks Caller enters the device critical section.
    235261 */
    236262typedef DECLCALLBACK(int) FNPDMDEVINITCOMPLETE(PPDMDEVINS pDevIns);
     
    273299    /** Construct instance - required. */
    274300    PFNPDMDEVCONSTRUCT  pfnConstruct;
    275     /** Destruct instance - optional. */
     301    /** Destruct instance - optional.
     302     * Critical section NOT entered (will be destroyed).  */
    276303    PFNPDMDEVDESTRUCT   pfnDestruct;
    277     /** Relocation command - optional. */
     304    /** Relocation command - optional.
     305     * Critical section NOT entered. */
    278306    PFNPDMDEVRELOCATE   pfnRelocate;
    279     /** I/O Control interface - optional. */
     307    /** I/O Control interface - optional.
     308     * Not used.  */
    280309    PFNPDMDEVIOCTL      pfnIOCtl;
    281     /** Power on notification - optional. */
     310    /** Power on notification - optional.
     311     * Critical section is entered. */
    282312    PFNPDMDEVPOWERON    pfnPowerOn;
    283     /** Reset notification - optional. */
     313    /** Reset notification - optional.
     314     * Critical section is entered. */
    284315    PFNPDMDEVRESET      pfnReset;
    285     /** Suspend notification  - optional. */
     316    /** Suspend notification  - optional.
     317     * Critical section is entered. */
    286318    PFNPDMDEVSUSPEND    pfnSuspend;
    287     /** Resume notification - optional. */
     319    /** Resume notification - optional.
     320     * Critical section is entered. */
    288321    PFNPDMDEVRESUME     pfnResume;
    289     /** Attach command - optional. */
     322    /** Attach command - optional.
     323     * Critical section is entered. */
    290324    PFNPDMDEVATTACH     pfnAttach;
    291     /** Detach notification - optional. */
     325    /** Detach notification - optional.
     326     * Critical section is entered. */
    292327    PFNPDMDEVDETACH     pfnDetach;
    293     /** Query a LUN base interface - optional. */
     328    /** Query a LUN base interface - optional.
     329     * Critical section is NOT entered. */
    294330    PFNPDMDEVQUERYINTERFACE pfnQueryInterface;
    295     /** Init complete notification - optional. */
     331    /** Init complete notification - optional.
     332     * Critical section is entered. */
    296333    PFNPDMDEVINITCOMPLETE   pfnInitComplete;
    297     /** Power off notification - optional. */
     334    /** Power off notification - optional.
     335     * Critical section is entered. */
    298336    PFNPDMDEVPOWEROFF   pfnPowerOff;
    299337    /** @todo */
     
    38633901    /** The critical section for the device.
    38643902     *
    3865      * TM and IOM will enter this critical section before calling into the
    3866      * device code.  SSM will currently not, but this will be changed later on.
     3903     * TM and IOM will enter this critical section before calling into the device
     3904     * code.  PDM will when doing power on, power off, reset, suspend and resume
     3905     * notifications.  SSM will currently not, but this will be changed later on.
    38673906     *
    38683907     * The device gets a critical section automatically assigned to it before
  • trunk/src/VBox/VMM/VMMR3/PDM.cpp

    r38838 r38847  
    10571057    {
    10581058        LogFlow(("PDMR3PowerOn: Notifying - device '%s'/%d\n", pDevIns->pReg->szName, pDevIns->iInstance));
     1059        PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    10591060        int rc = VINF_SUCCESS; pDevIns->pReg->pfnPowerOn(pDevIns);
     1061        PDMCritSectLeave(pDevIns->pCritSectRoR3);
    10601062        if (RT_FAILURE(rc))
    10611063        {
     
    13431345        if (pDevIns->pReg->pfnReset)
    13441346        {
     1347            uint64_t cNsElapsed = RTTimeNanoTS();
     1348            PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
     1349
    13451350            if (!pDevIns->Internal.s.pfnAsyncNotify)
    13461351            {
     
    13601365                pdmR3NotifyAsyncAdd(pAsync, pDevIns->Internal.s.pDevR3->pReg->szName, pDevIns->iInstance);
    13611366            }
     1367
     1368            PDMCritSectLeave(pDevIns->pCritSectRoR3);
     1369            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
     1370            if (cNsElapsed >= PDMSUSPEND_WARN_AT_NS)
     1371                LogRel(("PDMR3Reset: device '%s'/%d took %'llu ns to reset\n",
     1372                        pDevIns->pReg->szName, pDevIns->iInstance, cNsElapsed));
    13621373        }
    13631374    }
     
    15801591        {
    15811592            uint64_t cNsElapsed = RTTimeNanoTS();
     1593            PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    15821594
    15831595            if (!pDevIns->Internal.s.pfnAsyncNotify)
     
    15991611            }
    16001612
     1613            PDMCritSectLeave(pDevIns->pCritSectRoR3);
    16011614            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
    16021615            if (cNsElapsed >= PDMSUSPEND_WARN_AT_NS)
     
    17561769    {
    17571770        LogFlow(("PDMR3Resume: Notifying - device '%s'/%d\n", pDevIns->pReg->szName, pDevIns->iInstance));
     1771        PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    17581772        int rc = VINF_SUCCESS; pDevIns->pReg->pfnResume(pDevIns);
     1773        PDMCritSectLeave(pDevIns->pCritSectRoR3);
    17591774        if (RT_FAILURE(rc))
    17601775        {
     
    19391954        {
    19401955            uint64_t cNsElapsed = RTTimeNanoTS();
     1956            PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    19411957
    19421958            if (!pDevIns->Internal.s.pfnAsyncNotify)
     
    19581974            }
    19591975
     1976            PDMCritSectLeave(pDevIns->pCritSectRoR3);
    19601977            cNsElapsed = RTTimeNanoTS() - cNsElapsed;
    19611978            if (cNsElapsed >= PDMPOWEROFF_WARN_AT_NS)
  • trunk/src/VBox/VMM/VMMR3/PDMDevice.cpp

    r37812 r38847  
    420420        if (pDevIns->pReg->pfnInitComplete)
    421421        {
     422            PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    422423            rc = pDevIns->pReg->pfnInitComplete(pDevIns);
     424            PDMCritSectLeave(pDevIns->pCritSectRoR3);
    423425            if (RT_FAILURE(rc))
    424426            {
     
    796798            if (!pLun->pTop)
    797799            {
     800                PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    798801                rc = pDevIns->pReg->pfnAttach(pDevIns, iLun, fFlags);
     802                PDMCritSectLeave(pDevIns->pCritSectRoR3);
    799803            }
    800804            else
     
    904908            if (pDevIns->pReg->pfnAttach)
    905909            {
     910                PDMCritSectEnter(pDevIns->pCritSectRoR3, VERR_IGNORED);
    906911                rc = pDevIns->pReg->pfnAttach(pDevIns, iLun, fFlags);
    907912                if (RT_SUCCESS(rc) && ppBase)
    908913                    *ppBase = pLun->pTop ? &pLun->pTop->IBase : NULL;
     914                PDMCritSectLeave(pDevIns->pCritSectRoR3);
    909915            }
    910916            else
  • trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp

    r37418 r38847  
    641641            pLun->pTop = NULL;
    642642            if (!(fFlags & PDM_TACH_FLAGS_NO_CALLBACKS) && pLun->pDevIns->pReg->pfnDetach)
     643            {
     644                PDMCritSectEnter(pLun->pDevIns->pCritSectRoR3, VERR_IGNORED);
    643645                pLun->pDevIns->pReg->pfnDetach(pLun->pDevIns, pLun->iLun, fFlags);
     646                PDMCritSectLeave(pLun->pDevIns->pCritSectRoR3);
     647            }
    644648        }
    645649
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