VirtualBox

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


Ignore:
Timestamp:
May 27, 2015 8:42:10 AM (10 years ago)
Author:
vboxsync
Message:

Storage/AHCI: Fix race condition which might lead to a hang during power off

File:
1 edited

Legend:

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

    r55850 r56087  
    20242024    Assert(fAllTasksCanceled);
    20252025
     2026    Assert(pAhciPort->cTasksActive == 0);
     2027
    20262028    pAhciPort->regIS   = 0;
    20272029    pAhciPort->regIE   = 0;
     
    20532055    pAhciPort->u32QueuedTasksFinished = 0;
    20542056    pAhciPort->u32CurrentCommandSlot = 0;
    2055 
    2056     pAhciPort->cTasksActive = 0;
    20572057
    20582058    ASMAtomicWriteU32(&pAhciPort->MediaEventStatus, ATA_EVENT_STATUS_UNCHANGED);
     
    60126012    bool fXchg = ASMAtomicCmpXchgPtr(&pAhciPort->aActiveTasks[pAhciReq->uTag], NULL, pAhciReq);
    60136013
    6014     if (fXchg)
    6015     {
    6016         AssertReleaseMsg(ASMAtomicReadU32(&pAhciPort->cTasksActive) > 0,
    6017                          ("Inconsistent request counter\n"));
    6018         ASMAtomicDecU32(&pAhciPort->cTasksActive);
    6019     }
    6020 
    60216014    /*
    60226015     * Leave a release log entry if the request was active for more than 25 seconds
     
    61886181                        pAhciReq->cbTransfer, rcReq));
    61896182         }
     6183    }
     6184
     6185    /*
     6186     * Decrement the active task counter as the last step or we might run into a
     6187     * hang during power off otherwise (see @bugref{7859}).
     6188     * Before it could happen that we signal PDM that we are done while we still have to
     6189     * copy the data to the guest but EMT might be busy destroying the driver chains
     6190     * below us while we have to delegate copying data to EMT instead of doing it
     6191     * on this thread.
     6192     */
     6193    if (fXchg)
     6194    {
     6195        AssertReleaseMsg(ASMAtomicReadU32(&pAhciPort->cTasksActive) > 0,
     6196                         ("Inconsistent request counter\n"));
     6197        ASMAtomicDecU32(&pAhciPort->cTasksActive);
    61906198    }
    61916199
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