VirtualBox

Changeset 24772 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Nov 18, 2009 7:10:17 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
54982
Message:

DevAHCI,ATAController: Async hanlding of reset, suspend and power off.

Location:
trunk/src/VBox/Devices/Storage
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/ATAController.cpp

    r24265 r24772  
    38623862    if (    pCtl->fSignalIdle
    38633863        &&  ataAsyncIOIsIdle(pCtl, false /*fStrict*/))
     3864    {
     3865        PDMDevHlpAsyncNotificationCompleted(pCtl->pDevInsR3);
    38643866        RTThreadUserSignal(pCtl->AsyncIOThread);
     3867    }
    38653868
    38663869    rc = RTSemMutexRelease(pCtl->AsyncIORequestMutex); AssertRC(rc);
     
    43334336
    43344337    /* Signal the ultimate idleness. */
     4338    if (pCtl->fSignalIdle)
     4339        PDMDevHlpAsyncNotificationCompleted(pCtl->pDevInsR3);
    43354340    RTThreadUserSignal(ThreadSelf);
    43364341
     
    51725177#endif
    51735178
    5174 /**
    5175  * Suspend notification.
    5176  *
    5177  * @returns VBox status.
    5178  * @param   pDevIns     The device instance data.
    5179  */
    5180 void ataControllerSuspend(PAHCIATACONTROLLER pCtl)
    5181 {
    5182     Log(("%s:\n", __FUNCTION__));
    5183     if (!ataWaitForAllAsyncIOIsIdle(pCtl, 20000))
    5184         AssertMsgFailed(("Async I/O didn't stop in 20 seconds!\n"));
    5185     return;
    5186 }
    5187 
    51885179
    51895180/**
     
    52095200
    52105201/**
    5211  * Power Off notification.
     5202 * Tests if the controller is idle, leaving the PDM notifications on if busy.
    52125203 *
    5213  * @returns VBox status.
    5214  * @param   pCtl     The controller instance.
     5204 * @returns true if idle, false if idle.
     5205 * @param   pCtl the controller instance.
    52155206 */
    5216 void ataControllerPowerOff(PAHCIATACONTROLLER pCtl)
    5217 {
    5218     Log(("%s:\n", __FUNCTION__));
    5219     if (!ataWaitForAllAsyncIOIsIdle(pCtl, 20000))
    5220         AssertMsgFailed(("Async I/O didn't stop in 20 seconds!\n"));
    5221     return;
    5222 }
    5223 
    5224 /**
    5225  * Prepare state save and load operation.
    5226  *
    5227  * @returns VBox status code.
    5228  * @param   pDevIns         Device instance of the device which registered the data unit.
    5229  * @param   pSSM            SSM operation handle.
    5230  */
    5231 static int ataSaveLoadPrep(PAHCIATACONTROLLER pCtl)
    5232 {
    5233     /* sanity - the suspend notification will wait on the async stuff. */
    5234     Assert(ataAsyncIOIsIdle(pCtl, false));
    5235     if (!ataAsyncIOIsIdle(pCtl, false))
    5236         return VERR_SSM_IDE_ASYNC_TIMEOUT;
    5237 
    5238     return VINF_SUCCESS;
    5239 }
    5240 
    5241 /**
    5242  * Prepare state save operation.
    5243  *
    5244  * @returns VBox status code.
    5245  * @param   pCtl    The controller instance.
    5246  * @param   pSSM    SSM operation handle.
    5247  */
    5248 DECLCALLBACK(int) ataControllerSavePrep(PAHCIATACONTROLLER pCtl, PSSMHANDLE pSSM)
    5249 {
    5250     return ataSaveLoadPrep(pCtl);
    5251 }
    5252 
    5253 /**
    5254  * Prepare state load operation.
    5255  *
    5256  * @returns VBox status code.
    5257  * @param   pCtl    The controller instance.
    5258  * @param   pSSM    SSM operation handle.
    5259  */
    5260 DECLCALLBACK(int) ataControllerLoadPrep(PAHCIATACONTROLLER pCtl, PSSMHANDLE pSSM)
    5261 {
    5262     return ataSaveLoadPrep(pCtl);
     5207bool ataControllerIsIdle(PAHCIATACONTROLLER pCtl)
     5208{
     5209    ASMAtomicWriteBool(&pCtl->fSignalIdle, true);
     5210    if (ataAsyncIOIsIdle(pCtl, false /*fStrict*/))
     5211    {
     5212        ASMAtomicWriteBool(&pCtl->fSignalIdle, false);
     5213        return true;
     5214    }
     5215    return false;
    52635216}
    52645217
  • trunk/src/VBox/Devices/Storage/ATAController.h

    r24096 r24772  
    366366    /** The position at which to get a new request for the AIO thread. */
    367367    uint8_t             AsyncIOReqTail;
    368     /** Whether to call RTThreadUserSignal when idle.
    369      * Before setting this, call RTThreadUserReset. */
     368    /** Whether to call RTThreadUserSignal and PDMDevHlpAsyncNotificationCompleted
     369     * when idle.  Before setting this, call RTThreadUserReset. */
    370370    bool volatile       fSignalIdle;
    371371    uint8_t             Alignment3[1]; /**< Explicit padding of the 1 byte gap. */
     
    435435
    436436/**
    437  * Power off a controller.
    438  *
    439  * @returns nothing.
     437 * Tests if the controller is idle, leaving the PDM notifications on if busy.
     438 *
     439 * @returns true if idle, false if idle.
    440440 * @param   pCtl the controller instance.
    441441 */
    442 void ataControllerPowerOff(PAHCIATACONTROLLER pCtl);
     442bool ataControllerIsIdle(PAHCIATACONTROLLER pCtl);
    443443
    444444/**
     
    449449 */
    450450void ataControllerReset(PAHCIATACONTROLLER pCtl);
    451 
    452 /**
    453  * Suspend operation of an controller.
    454  *
    455  * @returns nothing
    456  * @param   pCtl The controller instance.
    457  */
    458 void ataControllerSuspend(PAHCIATACONTROLLER pCtl);
    459451
    460452/**
     
    486478
    487479/**
    488  * Prepare state save operation.
     480 * Excute state load operation.
    489481 *
    490482 * @returns VBox status code.
     
    492484 * @param   pSSM    SSM operation handle.
    493485 */
    494 int ataControllerSavePrep(PAHCIATACONTROLLER pCtl, PSSMHANDLE pSSM);
    495 
    496 /**
    497  * Excute state load operation.
    498  *
    499  * @returns VBox status code.
    500  * @param   pCtl    The controller instance.
    501  * @param   pSSM    SSM operation handle.
    502  */
    503486int ataControllerLoadExec(PAHCIATACONTROLLER pCtl, PSSMHANDLE pSSM);
    504 
    505 /**
    506  * Prepare state load operation.
    507  *
    508  * @returns VBox status code.
    509  * @param   pCtl    The controller instance.
    510  * @param   pSSM    SSM operation handle.
    511  */
    512 int ataControllerLoadPrep(PAHCIATACONTROLLER pCtl, PSSMHANDLE pSSM);
    513487
    514488#endif /* IN_RING3 */
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r24760 r24772  
    57035703
    57045704/**
    5705  * Checks if all asynchronous I/O is finished.
     5705 * Checks if all asynchronous I/O is finished, both AHCI and IDE.
    57065706 *
    57075707 * Used by ahciR3Reset, ahciR3Suspend and ahciR3PowerOff. ahciR3SavePrep makes
     
    57295729        }
    57305730    }
     5731
     5732    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
     5733        if (!ataControllerIsIdle(&pThis->aCts[i]))
     5734            return false;
     5735
    57315736    return true;
    57325737}
     
    57395744static DECLCALLBACK(int) ahciR3SavePrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    57405745{
    5741     PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI);
    5742 
    57435746    Assert(ahciR3AllAsyncIOIsFinished(pDevIns));
    5744 
    5745     for (uint32_t i = 0; i < RT_ELEMENTS(pAhci->aCts); i++)
    5746     {
    5747         int rc;
    5748 
    5749         rc = ataControllerSavePrep(&pAhci->aCts[i], pSSM);
    5750         if (RT_FAILURE(rc))
    5751             return rc;
    5752     }
    5753 
    57545747    return VINF_SUCCESS;
    57555748}
     
    57605753static DECLCALLBACK(int) ahciR3LoadPrep(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
    57615754{
    5762     PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI);
    5763 
    5764     for (uint32_t i = 0; i < RT_ELEMENTS(pAhci->aCts); i++)
    5765     {
    5766         int rc;
    5767 
    5768         rc = ataControllerLoadPrep(&pAhci->aCts[i], pSSM);
    5769         if (RT_FAILURE(rc))
    5770             return rc;
    5771     }
    5772 
     5755    Assert(ahciR3AllAsyncIOIsFinished(pDevIns));
    57735756    return VINF_SUCCESS;
    57745757}
     
    62686251 * Suspend notification.
    62696252 *
    6270  * @returns VBox status.
    62716253 * @param   pDevIns     The device instance data.
    62726254 */
    62736255static DECLCALLBACK(void) ahciR3Suspend(PPDMDEVINS pDevIns)
    62746256{
    6275     PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI);
    6276     Log(("%s:\n", __FUNCTION__));
    6277 
     6257    Log(("ahciR3Suspend\n"));
    62786258    ahciR3SuspendOrPowerOff(pDevIns);
    6279 
    6280     for (uint32_t i = 0; i < RT_ELEMENTS(pAhci->aCts); i++)
    6281         ataControllerSuspend(&pAhci->aCts[i]);
    62826259}
    62836260
     
    64756452 * Poweroff notification.
    64766453 *
    6477  * @returns nothing
    64786454 * @param   pDevIns Pointer to the device instance
    64796455 */
    64806456static DECLCALLBACK(void) ahciR3PowerOff(PPDMDEVINS pDevIns)
    64816457{
    6482     PAHCI pAhci = PDMINS_2_DATA(pDevIns, PAHCI);
    6483 
     6458    Log(("achiR3PowerOff\n"));
    64846459    ahciR3SuspendOrPowerOff(pDevIns);
    6485 
    6486     for (uint32_t i = 0; i < RT_ELEMENTS(pAhci->aCts); i++)
    6487         ataControllerPowerOff(&pAhci->aCts[i]);
    64886460}
    64896461
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