VirtualBox

Changeset 82403 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 5, 2019 12:08:56 AM (5 years ago)
Author:
vboxsync
Message:

DevHDA/hdaRegWriteSDCTL: Don't take the virtual-sync clock lock unless we're likely to need it. We only need it if DMA state changes to RUN. It is bad to do unnecessary work while sitting on that lock, in addition, less locking+unlocking saves time too. bugref:9218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Audio/DevHDA.cpp

    r82402 r82403  
    12391239    const bool fReset    = RT_BOOL(u32Value & HDA_SDCTL_SRST);
    12401240
    1241     /**
    1242      * @todo r=bird: Must reduce the time we holding the virtual sync
    1243      *               clock lock here!
    1244      */
    1245     DEVHDA_UNLOCK(pDevIns, pThis);
    1246     DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_MMIO_WRITE);
     1241    /* If the run bit is set, we take the virtual-sync clock lock as well so we
     1242       can safely update timers via hdaR3TimerSet if necessary.   We need to be
     1243       very careful with the fInReset and fInRun indicators here, as they may
     1244       change during the relocking if we need to acquire the clock lock. */
     1245    const bool fNeedVirtualSyncClockLock = (u32Value & (HDA_SDCTL_RUN | HDA_SDCTL_SRST)) == HDA_SDCTL_RUN
     1246                                        && (HDA_REG_IND(pThis, iReg) & HDA_SDCTL_RUN) == 0;
     1247    if (fNeedVirtualSyncClockLock)
     1248    {
     1249        DEVHDA_UNLOCK(pDevIns, pThis);
     1250        DEVHDA_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_MMIO_WRITE);
     1251    }
    12471252
    12481253    const bool fInRun    = RT_BOOL(HDA_REG_IND(pThis, iReg) & HDA_SDCTL_RUN);
     
    13961401    }
    13971402
    1398     VBOXSTRICTRC rc = hdaRegWriteU24(pDevIns, pThis, iReg, u32Value);
    1399 
    1400     PDMDevHlpTimerUnlockClock(pDevIns, pStream->hTimer); /* Caller will unlock pThis->CritSect. */ /** @todo r=bird: Move this up. */
    1401     return rc;
     1403    if (fNeedVirtualSyncClockLock)
     1404        PDMDevHlpTimerUnlockClock(pDevIns, pStream->hTimer); /* Caller will unlock pThis->CritSect. */
     1405
     1406    return hdaRegWriteU24(pDevIns, pThis, iReg, u32Value);
    14021407#else  /* !IN_RING3 */
    14031408    RT_NOREF(pDevIns, pThis, iReg, u32Value);
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