VirtualBox

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


Ignore:
Timestamp:
Aug 19, 2014 10:04:54 AM (10 years ago)
Author:
vboxsync
Message:

Storage/AHCI: Free cached tasks on detach and before ahciR3Destruct is called because drivers are not available at that point anymore

File:
1 edited

Legend:

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

    r52026 r52408  
    56605660
    56615661/**
     5662 * Free all cached tasks on the given port.
     5663 *
     5664 * @returns nothing.
     5665 * @param   pAhciPort    The AHCI port.
     5666 */
     5667static void ahciR3PortCachedReqsFree(PAHCIPort pAhciPort)
     5668{
     5669    for (uint32_t i = 0; i < AHCI_NR_COMMAND_SLOTS; i++)
     5670    {
     5671        if (pAhciPort->aCachedTasks[i])
     5672        {
     5673            ahciReqMemFree(pAhciPort, pAhciPort->aCachedTasks[i], true /* fForceFree */);
     5674            RTMemFree(pAhciPort->aCachedTasks[i]);
     5675            pAhciPort->aCachedTasks[i] = NULL;
     5676        }
     5677    }
     5678}
     5679
     5680/**
    56625681 * Cancels all active tasks on the port.
    56635682 *
     
    75887607    PAHCI pThis = PDMINS_2_DATA(pDevIns, PAHCI);
    75897608    ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     7609    /*
     7610     * Free all cached tasks here, not possible on destruct because the driver
     7611     * is destroyed before us.
     7612     */
     7613    for (unsigned iPort = 0; iPort < pThis->cPortsImpl; iPort++)
     7614        ahciR3PortCachedReqsFree(&pThis->ahciPort[iPort]);
    75907615    return true;
    75917616}
     
    76027627        PDMDevHlpSetAsyncNotification(pDevIns, ahciR3IsAsyncSuspendOrPowerOffDone);
    76037628    else
     7629    {
     7630        /*
     7631         * Free all cached tasks here, not possible on destruct because the driver
     7632         * is destroyed before us.
     7633         */
     7634        for (unsigned iPort = 0; iPort < pThis->cPortsImpl; iPort++)
     7635            ahciR3PortCachedReqsFree(&pThis->ahciPort[iPort]);
     7636
    76047637        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     7638    }
    76057639}
    76067640
     
    78107844    if (pAhciPort->fATAPI)
    78117845        ahciMediumRemoved(pAhciPort);
     7846
     7847    /* Free all cached I/O tasks. */
     7848    ahciR3PortCachedReqsFree(pAhciPort);
    78127849
    78137850    if (!(fFlags & PDM_TACH_FLAGS_NOT_HOT_PLUG))
     
    80178054static DECLCALLBACK(void) ahciR3PowerOff(PPDMDEVINS pDevIns)
    80188055{
     8056    PAHCI pThis = PDMINS_2_DATA(pDevIns, PAHCI);
     8057
    80198058    Log(("achiR3PowerOff\n"));
    80208059    ahciR3SuspendOrPowerOff(pDevIns);
     
    80568095            }
    80578096
    8058             /* Free all cached tasks. */
    8059             for (uint32_t i = 0; i < AHCI_NR_COMMAND_SLOTS; i++)
    8060                 if (pAhciPort->aCachedTasks[i])
    8061                 {
    8062                     ahciReqMemFree(pAhciPort, pAhciPort->aCachedTasks[i], true /* fForceFree */);
    8063                     RTMemFree(pAhciPort->aCachedTasks[i]);
    8064                     pAhciPort->aCachedTasks[i] = NULL;
    8065                 }
     8097#ifdef VBOX_STRICT
     8098            /* Check that all cached tasks were freed at this point. */
     8099            for (unsigned iPort = 0; iPort < pThis->cPortsImpl; iPort++)
     8100            {
     8101                PAHCIPort pAhciPort = &pThis->ahciPort[iPort];
     8102
     8103                for (uint32_t i = 0; i < AHCI_NR_COMMAND_SLOTS; i++)
     8104                    Assert(!pAhciPort->aCachedTasks[i]);
     8105            }
     8106#endif
    80668107        }
    80678108
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