VirtualBox

Changeset 29609 in vbox for trunk


Ignore:
Timestamp:
May 18, 2010 10:08:16 AM (15 years ago)
Author:
vboxsync
Message:

LsiLogic: Make sure we have no request pending on suspend

Location:
trunk/src/VBox/Devices
Files:
2 edited

Legend:

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

    r29588 r29609  
    273273    /** Status LUN: Partner of ILeds. */
    274274    R3PTRTYPE(PPDMILEDCONNECTORS)  pLedsConnector;
    275 
     275    /** Pointer to the configuration page area. */
    276276    R3PTRTYPE(PMptConfigurationPagesSupported) pConfigurationPages;
     277    /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when
     278     * a port is entering the idle state. */
     279    bool volatile                  fSignalIdle;
     280
    277281} LSILOGISCSI, *PLSILOGICSCSI;
    278282
     
    20322036    RTMemCacheFree(pLsiLogic->hTaskCache, pTaskState);
    20332037
     2038    if (pLsiLogicDevice->cOutstandingRequests == 0 && pLsiLogic->fSignalIdle)
     2039        PDMDevHlpAsyncNotificationCompleted(pLsiLogic->pDevInsR3);
     2040
    20342041    return VINF_SUCCESS;
    20352042}
     
    43444351}
    43454352
     4353/* -=-=-=-=- Helper -=-=-=-=- */
     4354
     4355/**
     4356 * Checks if all asynchronous I/O is finished.
     4357 *
     4358 * Used by lsilogicReset, lsilogicSuspend and lsilogicPowerOff.
     4359 *
     4360 * @returns true if quiesced, false if busy.
     4361 * @param   pDevIns         The device instance.
     4362 */
     4363static bool lsilogicR3AllAsyncIOIsFinished(PPDMDEVINS pDevIns)
     4364{
     4365    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4366
     4367    for (uint32_t i = 0; i < pThis->cDeviceStates; i++)
     4368    {
     4369        PLSILOGICDEVICE pThisDevice = &pThis->paDeviceStates[i];
     4370        if (pThisDevice->pDrvBase)
     4371        {
     4372            if (pThisDevice->cOutstandingRequests != 0)
     4373                return false;
     4374        }
     4375    }
     4376
     4377    return true;
     4378}
     4379
     4380/**
     4381 * Callback employed by lsilogicR3Suspend and lsilogicR3PowerOff..
     4382 *
     4383 * @returns true if we've quiesced, false if we're still working.
     4384 * @param   pDevIns     The device instance.
     4385 */
     4386static DECLCALLBACK(bool) lsilogicR3IsAsyncSuspendOrPowerOffDone(PPDMDEVINS pDevIns)
     4387{
     4388    if (!lsilogicR3AllAsyncIOIsFinished(pDevIns))
     4389        return false;
     4390
     4391    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4392    ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     4393    return true;
     4394}
     4395
     4396/**
     4397 * Common worker for ahciR3Suspend and ahciR3PowerOff.
     4398 */
     4399static void lsilogicR3SuspendOrPowerOff(PPDMDEVINS pDevIns)
     4400{
     4401    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4402
     4403    ASMAtomicWriteBool(&pThis->fSignalIdle, true);
     4404    if (!lsilogicR3AllAsyncIOIsFinished(pDevIns))
     4405        PDMDevHlpSetAsyncNotification(pDevIns, lsilogicR3IsAsyncSuspendOrPowerOffDone);
     4406    else
     4407        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     4408}
     4409
     4410/**
     4411 * Suspend notification.
     4412 *
     4413 * @param   pDevIns     The device instance data.
     4414 */
     4415static DECLCALLBACK(void) lsilogicSuspend(PPDMDEVINS pDevIns)
     4416{
     4417    Log(("lsilogicSuspend\n"));
     4418    lsilogicR3SuspendOrPowerOff(pDevIns);
     4419}
     4420
    43464421/**
    43474422 * Detach notification.
     
    44254500
    44264501/**
    4427  * @copydoc FNPDMDEVRESET
    4428  */
    4429 static DECLCALLBACK(void) lsilogicReset(PPDMDEVINS pDevIns)
     4502 * Common reset worker.
     4503 *
     4504 * @param   pDevIns     The device instance data.
     4505 */
     4506static void lsilogicR3ResetCommon(PPDMDEVINS pDevIns)
    44304507{
    44314508    PLSILOGICSCSI pLsiLogic = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     
    44364513
    44374514    vboxscsiInitialize(&pLsiLogic->VBoxSCSI);
     4515}
     4516
     4517/**
     4518 * Callback employed by lsilogicR3Reset.
     4519 *
     4520 * @returns true if we've quiesced, false if we're still working.
     4521 * @param   pDevIns     The device instance.
     4522 */
     4523static DECLCALLBACK(bool) lsilogicR3IsAsyncResetDone(PPDMDEVINS pDevIns)
     4524{
     4525    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4526
     4527    if (!lsilogicR3AllAsyncIOIsFinished(pDevIns))
     4528        return false;
     4529    ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     4530
     4531    lsilogicR3ResetCommon(pDevIns);
     4532    return true;
     4533}
     4534
     4535/**
     4536 * @copydoc FNPDMDEVRESET
     4537 */
     4538static DECLCALLBACK(void) lsilogicReset(PPDMDEVINS pDevIns)
     4539{
     4540    PLSILOGICSCSI pThis = PDMINS_2_DATA(pDevIns, PLSILOGICSCSI);
     4541
     4542    ASMAtomicWriteBool(&pThis->fSignalIdle, true);
     4543    if (!lsilogicR3AllAsyncIOIsFinished(pDevIns))
     4544        PDMDevHlpSetAsyncNotification(pDevIns, lsilogicR3IsAsyncResetDone);
     4545    else
     4546    {
     4547        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     4548        lsilogicR3ResetCommon(pDevIns);
     4549    }
    44384550}
    44394551
     
    44764588
    44774589    return rc;
     4590}
     4591
     4592/**
     4593 * Poweroff notification.
     4594 *
     4595 * @param   pDevIns Pointer to the device instance
     4596 */
     4597static DECLCALLBACK(void) lsilogicPowerOff(PPDMDEVINS pDevIns)
     4598{
     4599    Log(("lsilogicPowerOff\n"));
     4600    lsilogicR3SuspendOrPowerOff(pDevIns);
    44784601}
    44794602
     
    47744897    "LSI Logic 53c1030 SCSI controller.\n",
    47754898    /* fFlags */
    4776     PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
     4899    PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0 |
     4900    PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION,
    47774901    /* fClass */
    47784902    PDM_DEVREG_CLASS_STORAGE,
     
    47944918    lsilogicReset,
    47954919    /* pfnSuspend */
    4796     NULL,
     4920    lsilogicSuspend,
    47974921    /* pfnResume */
    47984922    NULL,
     
    48064930    NULL,
    48074931    /* pfnPowerOff */
    4808     NULL,
     4932    lsilogicPowerOff,
    48094933    /* pfnSoftReset */
    48104934    NULL,
     
    48294953    "LSI Logic SAS1068 controller.\n",
    48304954    /* fFlags */
    4831     PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
     4955    PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0 |
     4956    PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION,
    48324957    /* fClass */
    48334958    PDM_DEVREG_CLASS_STORAGE,
     
    48494974    lsilogicReset,
    48504975    /* pfnSuspend */
    4851     NULL,
     4976    lsilogicSuspend,
    48524977    /* pfnResume */
    48534978    NULL,
     
    48614986    NULL,
    48624987    /* pfnPowerOff */
    4863     NULL,
     4988    lsilogicPowerOff,
    48644989    /* pfnSoftReset */
    48654990    NULL,
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r29435 r29609  
    15251525    GEN_CHECK_OFF(LSILOGICSCSI, pLedsConnector);
    15261526    GEN_CHECK_OFF(LSILOGICSCSI, pConfigurationPages);
     1527    GEN_CHECK_OFF(LSILOGICSCSI, fSignalIdle);
    15271528#endif /* VBOX_WITH_LSILOGIC */
    15281529
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