VirtualBox

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


Ignore:
Timestamp:
May 18, 2010 11:48:31 AM (15 years ago)
Author:
vboxsync
Message:

BusLogic: Make sure that there are no tasks pending during suspend

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

Legend:

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

    r29250 r29614  
    381381    /** Partner of ILeds. */
    382382    R3PTRTYPE(PPDMILEDCONNECTORS)  pLedsConnector;
     383
     384#if HC_ARCH_BITS == 64
     385    uint32_t                       Alignment3;
     386#endif
     387
     388    /** Indicates that PDMDevHlpAsyncNotificationCompleted should be called when
     389     * a port is entering the idle state. */
     390    bool volatile                  fSignalIdle;
     391
    383392} BUSLOGIC, *PBUSLOGIC;
    384393
     
    19871996    /* Add task to the cache. */
    19881997    RTMemCacheFree(pBusLogic->hTaskCache, pTaskState);
     1998
     1999    if (pBusLogicDevice->cOutstandingRequests == 0 && pBusLogic->fSignalIdle)
     2000        PDMDevHlpAsyncNotificationCompleted(pBusLogic->pDevInsR3);
     2001
    19892002    return VINF_SUCCESS;
    19902003}
     
    23862399}
    23872400
     2401/* -=-=-=-=- Helper -=-=-=-=- */
     2402
     2403 /**
     2404 * Checks if all asynchronous I/O is finished.
     2405 *
     2406 * Used by lsilogicReset, lsilogicSuspend and lsilogicPowerOff.
     2407 *
     2408 * @returns true if quiesced, false if busy.
     2409 * @param   pDevIns         The device instance.
     2410 */
     2411static bool buslogicR3AllAsyncIOIsFinished(PPDMDEVINS pDevIns)
     2412{
     2413    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     2414
     2415    for (uint32_t i = 0; i < RT_ELEMENTS(pThis->aDeviceStates); i++)
     2416    {
     2417        PBUSLOGICDEVICE pThisDevice = &pThis->aDeviceStates[i];
     2418        if (pThisDevice->pDrvBase)
     2419        {
     2420            if (pThisDevice->cOutstandingRequests != 0)
     2421                return false;
     2422        }
     2423    }
     2424
     2425    return true;
     2426}
     2427
     2428/**
     2429 * Callback employed by lsilogicR3Suspend and lsilogicR3PowerOff..
     2430 *
     2431 * @returns true if we've quiesced, false if we're still working.
     2432 * @param   pDevIns     The device instance.
     2433 */
     2434static DECLCALLBACK(bool) buslogicR3IsAsyncSuspendOrPowerOffDone(PPDMDEVINS pDevIns)
     2435{
     2436    if (!buslogicR3AllAsyncIOIsFinished(pDevIns))
     2437        return false;
     2438
     2439    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     2440    ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     2441    return true;
     2442}
     2443
     2444/**
     2445 * Common worker for ahciR3Suspend and ahciR3PowerOff.
     2446 */
     2447static void buslogicR3SuspendOrPowerOff(PPDMDEVINS pDevIns)
     2448{
     2449    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     2450
     2451    ASMAtomicWriteBool(&pThis->fSignalIdle, true);
     2452    if (!buslogicR3AllAsyncIOIsFinished(pDevIns))
     2453        PDMDevHlpSetAsyncNotification(pDevIns, buslogicR3IsAsyncSuspendOrPowerOffDone);
     2454    else
     2455        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     2456}
     2457
     2458/**
     2459 * Suspend notification.
     2460 *
     2461 * @param   pDevIns     The device instance data.
     2462 */
     2463static DECLCALLBACK(void) buslogicSuspend(PPDMDEVINS pDevIns)
     2464{
     2465    Log(("buslogicSuspend\n"));
     2466    buslogicR3SuspendOrPowerOff(pDevIns);
     2467}
     2468
    23882469/**
    23892470 * Detach notification.
     
    24622543}
    24632544
     2545/**
     2546 * Callback employed by buslogicR3Reset.
     2547 *
     2548 * @returns true if we've quiesced, false if we're still working.
     2549 * @param   pDevIns     The device instance.
     2550 */
     2551static DECLCALLBACK(bool) buslogicR3IsAsyncResetDone(PPDMDEVINS pDevIns)
     2552{
     2553    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     2554
     2555    if (!buslogicR3AllAsyncIOIsFinished(pDevIns))
     2556        return false;
     2557    ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     2558
     2559    buslogicHwReset(pThis);
     2560    return true;
     2561}
     2562
     2563/**
     2564 * @copydoc FNPDMDEVRESET
     2565 */
     2566static DECLCALLBACK(void) buslogicReset(PPDMDEVINS pDevIns)
     2567{
     2568    PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
     2569
     2570    ASMAtomicWriteBool(&pThis->fSignalIdle, true);
     2571    if (!buslogicR3AllAsyncIOIsFinished(pDevIns))
     2572        PDMDevHlpSetAsyncNotification(pDevIns, buslogicR3IsAsyncResetDone);
     2573    else
     2574    {
     2575        ASMAtomicWriteBool(&pThis->fSignalIdle, false);
     2576        buslogicHwReset(pThis);
     2577    }
     2578}
     2579
    24642580static DECLCALLBACK(void) buslogicRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
    24652581{
     
    24802596
    24812597/**
    2482  * Reset notification.
    2483  *
    2484  * @returns VBox status.
    2485  * @param   pDevIns     The device instance data.
    2486  */
    2487 static DECLCALLBACK(void)  buslogicReset(PPDMDEVINS pDevIns)
    2488 {
    2489     PBUSLOGIC pThis = PDMINS_2_DATA(pDevIns, PBUSLOGIC);
    2490 
    2491     buslogicHwReset(pThis);
     2598 * Poweroff notification.
     2599 *
     2600 * @param   pDevIns Pointer to the device instance
     2601 */
     2602static DECLCALLBACK(void) buslogicPowerOff(PPDMDEVINS pDevIns)
     2603{
     2604    Log(("buslogicPowerOff\n"));
     2605    buslogicR3SuspendOrPowerOff(pDevIns);
    24922606}
    24932607
     
    26822796    "BusLogic BT-958 SCSI host adapter.\n",
    26832797    /* fFlags */
    2684     PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
     2798    PDM_DEVREG_FLAGS_DEFAULT_BITS | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0 |
     2799    PDM_DEVREG_FLAGS_FIRST_SUSPEND_NOTIFICATION | PDM_DEVREG_FLAGS_FIRST_POWEROFF_NOTIFICATION,
    26852800    /* fClass */
    26862801    PDM_DEVREG_CLASS_STORAGE,
     
    27022817    buslogicReset,
    27032818    /* pfnSuspend */
    2704     NULL,
     2819    buslogicSuspend,
    27052820    /* pfnResume */
    27062821    NULL,
     
    27142829    NULL,
    27152830    /* pfnPowerOff */
    2716     NULL,
     2831    buslogicPowerOff,
    27172832    /* pfnSoftReset */
    27182833    NULL,
  • trunk/src/VBox/Devices/testcase/tstDeviceStructSizeRC.cpp

    r29609 r29614  
    14591459    GEN_CHECK_OFF(BUSLOGIC, ILeds);
    14601460    GEN_CHECK_OFF(BUSLOGIC, pLedsConnector);
     1461    GEN_CHECK_OFF(BUSLOGIC, fSignalIdle);
    14611462#endif /* VBOX_WITH_BUSLOGIC */
    14621463
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