VirtualBox

Changeset 50938 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Apr 1, 2014 9:36:18 AM (11 years ago)
Author:
vboxsync
Message:

AHCI: Fix race condition during port reset causing a release assertion when canceling outstanding requests

File:
1 edited

Legend:

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

    r50564 r50938  
    11751175    if ((u32Value & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_INIT)
    11761176    {
    1177         bool fAllTasksCanceled;
    1178 
    1179         /* Cancel all tasks first. */
    1180         fAllTasksCanceled = ahciCancelActiveTasks(pAhciPort);
    1181         Assert(fAllTasksCanceled);
    1182 
    11831177        if (!ASMAtomicXchgBool(&pAhciPort->fPortReset, true))
    11841178            LogRel(("AHCI#%u: Port %d reset\n", ahci->CTX_SUFF(pDevIns)->iInstance,
    11851179                    pAhciPort->iLUN));
     1180
     1181        /* Make sure the async I/O thread is not working before we start to cancel active requests. */
     1182        while (   pAhciPort->u32TasksNew
     1183               && !pAhciPort->fWrkThreadSleeping)
     1184            RTThreadYield();
     1185
     1186        /* Cancel all tasks first. */
     1187        bool fAllTasksCanceled = ahciCancelActiveTasks(pAhciPort);
     1188        Assert(fAllTasksCanceled);
    11861189
    11871190        pAhciPort->regSSTS = 0;
     
    11901193        pAhciPort->fFirstD2HFisSend = false;
    11911194    }
    1192     else if ((u32Value & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_NINIT && pAhciPort->pDrvBase &&
    1193              (pAhciPort->regSCTL & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_INIT)
     1195    else if (   (u32Value & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_NINIT
     1196             && (pAhciPort->regSCTL & AHCI_PORT_SCTL_DET) == AHCI_PORT_SCTL_DET_INIT
     1197             && pAhciPort->pDrvBase)
    11941198    {
    11951199        if (pAhciPort->pDrvBase)
     
    12381242                }
    12391243            }
    1240        }
     1244        }
    12411245    }
    12421246
     
    65386542
    65396543        idx = ASMBitFirstSetU32(u32Tasks);
    6540         while (idx)
     6544        while (   idx
     6545               && !pAhciPort->fPortReset)
    65416546        {
    65426547            bool fReqCanceled = false;
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