VirtualBox

Changeset 24741 in vbox for trunk


Ignore:
Timestamp:
Nov 17, 2009 9:44:52 PM (15 years ago)
Author:
vboxsync
Message:

DevATA: Use the async notification handling.

File:
1 edited

Legend:

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

    r24587 r24741  
    37463746 * @returns true on success.
    37473747 * @returns false when the thread is still processing.
    3748  * @param   pThis       Pointer to the controller data.
    3749  * @param   cMillies    How long to wait (total).  This isn't very accurate.
     3748 * @param   pThis               Pointer to the controller data.
     3749 * @param   cMillies            How long to wait (total).  This isn't very
     3750 *                              accurate.
     3751 * @param   fLeaveSignallingOn  Leave the signalling on so that it will notifiy
     3752 *                              PDM about completion of the asynchronous
     3753 *                              notification.
    37503754 */
    3751 static bool ataWaitForAsyncIOIsIdle(PATACONTROLLER pCtl, unsigned cMillies)
     3755static bool ataWaitForAsyncIOIsIdle(PATACONTROLLER pCtl, unsigned cMillies, bool fLeaveSignallingOn)
    37523756{
    37533757    uint64_t        u64Start;
     
    37853789    }
    37863790
    3787     ASMAtomicWriteBool(&pCtl->fSignalIdle, false);
     3791    if (fRc || !fLeaveSignallingOn)
     3792        ASMAtomicWriteBool(&pCtl->fSignalIdle, false);
    37883793    return fRc;
    37893794}
     
    37953800 * @returns true on success.
    37963801 * @returns false when one or more threads is still processing.
    3797  * @param   pThis       Pointer to the instance data.
    3798  * @param   cMillies    How long to wait per controller.
     3802 * @param   pThis               Pointer to the instance data.
     3803 * @param   cMillies            How long to wait per controller.
     3804 * @param   fLeaveSignallingOn  Leave the signalling on so that it will notifiy
     3805 *                              PDM about completion of the asynchronous
     3806 *                              notification.
    37993807 */
    3800 static bool ataWaitForAllAsyncIOIsIdle(PPDMDEVINS pDevIns, uint32_t cMillies)
     3808static bool ataWaitForAllAsyncIOIsIdle(PPDMDEVINS pDevIns, uint32_t cMillies, bool fLeaveSignallingOn)
    38013809{
    38023810    PCIATAState *pThis = PDMINS_2_DATA(pDevIns, PCIATAState *);
     
    38043812    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aCts); i++)
    38053813        if (   pThis->aCts[i].AsyncIOThread != NIL_RTTHREAD
    3806             && !ataWaitForAsyncIOIsIdle(&pThis->aCts[i], cMillies))
     3814            && !ataWaitForAsyncIOIsIdle(&pThis->aCts[i], cMillies, fLeaveSignallingOn))
    38073815        {
    38083816            LogRel(("PIIX3 ATA: Ctl#%u is still executing, DevSel=%d AIOIf=%d CmdIf0=%#04x CmdIf1=%#04x\n",
     
    45684576    if (    pCtl->fSignalIdle
    45694577        &&  ataAsyncIOIsIdle(pCtl, false /*fStrict*/))
     4578    {
    45704579        RTThreadUserSignal(pCtl->AsyncIOThread);
     4580        PDMDevHlpAsyncNotificationCompleted(pCtl->pDevInsR3);
     4581    }
    45714582
    45724583    rc = RTSemMutexRelease(pCtl->AsyncIORequestMutex); AssertRC(rc);
     
    53045315        ataAsyncIOPutRequest(&pThis->aCts[i], &ataResetARequest);
    53055316        ataAsyncIOPutRequest(&pThis->aCts[i], &ataResetCRequest);
    5306         if (!ataWaitForAsyncIOIsIdle(&pThis->aCts[i], 30000))
     5317/** @todo Deadlock alert. see @bugref{4394}. */
     5318        if (!ataWaitForAsyncIOIsIdle(&pThis->aCts[i], 30000, false /*fLeaveSignallingOn*/))
    53075319        {
    53085320            PDMDevHlpVMSetRuntimeError(pDevIns, 0 /*fFlags*/, "DevATA_ASYNCBUSY",
     
    56225634
    56235635#ifdef IN_RING3
     5636
     5637/**
     5638 * Callback employed by ataSuspend and ataPowerOff.
     5639 *
     5640 * @returns true if we've quiesced, false if we're still working.
     5641 * @param   pDevIns     The device instance.
     5642 */
     5643static DECLCALLBACK(bool) ataR3IsAsyncSuspendOrPowerOffDone(PPDMDEVINS pDevIns)
     5644{
     5645    return ataWaitForAllAsyncIOIsIdle(pDevIns, 0, true /*fLeaveSignallingOn*/);
     5646}
     5647
     5648
     5649/**
     5650 * Common worker for ataSuspend and ataPowerOff.
     5651 */
     5652static void ataR3SuspendOrPowerOff(PPDMDEVINS pDevIns)
     5653{
     5654#if 1
     5655    if (!ataWaitForAllAsyncIOIsIdle(pDevIns, 0, true /*fLeaveSignallingOn*/))
     5656        PDMDevHlpSetAsyncNotification(pDevIns, ataR3IsAsyncSuspendOrPowerOffDone);
     5657#else
     5658    if (!ataWaitForAllAsyncIOIsIdle(pDevIns, 20000))
     5659        AssertMsgFailed(("Async I/O didn't stop in ~40 seconds!\n"));
     5660#endif
     5661}
     5662
    56245663
    56255664DECLINLINE(void) ataRelocBuffer(PPDMDEVINS pDevIns, ATADevState *s)
     
    59816020{
    59826021    Log(("%s:\n", __FUNCTION__));
    5983     if (!ataWaitForAllAsyncIOIsIdle(pDevIns, 20000))
    5984         AssertMsgFailed(("Async I/O didn't stop in ~40 seconds!\n"));
    5985     return;
     6022    ataR3SuspendOrPowerOff(pDevIns);
    59866023}
    59876024
     
    60206057{
    60216058    Log(("%s:\n", __FUNCTION__));
    6022     if (!ataWaitForAllAsyncIOIsIdle(pDevIns, 20000))
    6023         AssertMsgFailed(("Async I/O didn't stop in ~40 seconds!\n"));
    6024     return;
     6059    ataR3SuspendOrPowerOff(pDevIns);
    60256060}
    60266061
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