VirtualBox

Changeset 88572 in vbox for trunk/src/VBox/Devices/Audio


Ignore:
Timestamp:
Apr 16, 2021 7:30:00 PM (4 years ago)
Author:
vboxsync
Message:

DevHda: Set the FIFORDY bit when a stream is enabled and clear it when the stream is disabled. This should help Linux guests waste less time reading the STS bit when starting playback or recording. bugref:9890

Location:
trunk/src/VBox/Devices/Audio
Files:
3 edited

Legend:

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

    r88561 r88572  
    13011301        if (pStreamShared->State.fRunning)
    13021302        {
    1303             int rc2 = hdaR3StreamEnable(pStreamShared, pStreamR3, false /* fEnable */);
     1303            int rc2 = hdaR3StreamEnable(pThis, pStreamShared, pStreamR3, false /* fEnable */);
    13041304            AssertRC(rc2); Assert(!pStreamShared->State.fRunning);
    13051305            pStreamShared->State.fRunning = false;
     
    13801380            {
    13811381                /* Enable/disable the stream. */
    1382                 rc2 = hdaR3StreamEnable(pStreamShared, pStreamR3, fRun /* fEnable */);
     1382                rc2 = hdaR3StreamEnable(pThis, pStreamShared, pStreamR3, fRun /* fEnable */);
    13831383                AssertRC(rc2);
    13841384
     
    25182518            /* Only disable the stream if the stream descriptor # has changed. */
    25192519            if (pSink->pStreamShared->u8SD != uSD)
    2520                 hdaR3StreamEnable(pSink->pStreamShared, pSink->pStreamR3, false /*fEnable*/);
     2520                hdaR3StreamEnable(pThis, pSink->pStreamShared, pSink->pStreamR3, false /*fEnable*/);
    25212521
    25222522            pSink->pStreamR3->pMixSink = NULL;
     
    27662766
    27672767        /* We're doing this unconditionally, hope that's not problematic in any way... */
    2768         int rc = hdaR3StreamEnable(pStreamShared, &pThisCC->aStreams[idxStream], false /* fEnable */);
     2768        int rc = hdaR3StreamEnable(pThis, pStreamShared, &pThisCC->aStreams[idxStream], false /* fEnable */);
    27692769        AssertLogRelMsg(RT_SUCCESS(rc) && !pStreamShared->State.fRunning,
    27702770                        ("Disabling stream #%u failed: %Rrc, fRunning=%d\n", idxStream, rc, pStreamShared->State.fRunning));
     
    34743474#endif
    34753475            /* (Re-)enable the stream. */
    3476             rc2 = hdaR3StreamEnable(pStreamShared, pStreamR3, true /* fEnable */);
     3476            rc2 = hdaR3StreamEnable(pThis, pStreamShared, pStreamR3, true /* fEnable */);
    34773477            AssertRC(rc2);
    34783478
  • trunk/src/VBox/Devices/Audio/DevHdaStream.cpp

    r88357 r88572  
    885885 *
    886886 * @returns VBox status code.
     887 * @param   pThis               The shared HDA device state.
    887888 * @param   pStreamShared       HDA stream to enable or disable - shared bits.
    888889 * @param   pStreamR3           HDA stream to enable or disable - ring-3 bits.
    889890 * @param   fEnable             Whether to enable or disble the stream.
    890891 */
    891 int hdaR3StreamEnable(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, bool fEnable)
     892int hdaR3StreamEnable(PHDASTATE pThis, PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, bool fEnable)
    892893{
    893894    AssertPtr(pStreamR3);
     
    942943            pStreamShared->State.tsTransferLast = 0; /* Make sure it's not stale and messes up WALCLK calculations. */
    943944        pStreamShared->State.fRunning = fEnable;
     945
     946        /*
     947         * Set the FIFORDY bit when we start running and clear it when stopping.
     948         *
     949         * This prevents Linux from timing out in snd_hdac_stream_sync when starting
     950         * a stream.  Technically, Linux also uses the SSYNC feature there, but we
     951         * can get away with just setting the FIFORDY bit for now.
     952         */
     953        if (fEnable)
     954            HDA_STREAM_REG(pThis, STS, pStreamShared->u8SD) |= HDA_SDSTS_FIFORDY;
     955        else
     956            HDA_STREAM_REG(pThis, STS, pStreamShared->u8SD) &= ~HDA_SDSTS_FIFORDY;
    944957    }
    945958
     
    12041217    pStreamShared->State.tsLastTransferNs = tsNowNs;
    12051218
    1206     /*
    1207      * Set the FIFORDY bit on the stream while doing the transfer.
    1208      */
    1209     /** @todo r=bird: I don't get the HDA_SDSTS_FIFORDY logic.  Unless we're
    1210      *        assuming SMP guest and that it can get stream registers while we're
    1211      *        here.  Only it cannot do the later because we're sitting on the big
    1212      *        HDA device lock, see assertions in hdaR3Timer().  So, this is an
    1213      *        pointless guesture given that we clear it again after the loop. */
    1214     HDA_STREAM_REG(pThis, STS, uSD) |= HDA_SDSTS_FIFORDY;
    1215 
    12161219    return true;
    12171220}
     
    12211224 *
    12221225 * @param   pDevIns         The device instance.
    1223  * @param   pThis           The shared HDA device state.
    12241226 * @param   pStreamShared   The HDA stream (shared).
    12251227 * @param   pStreamR3       The HDA stream (ring-3).
    12261228 */
    1227 DECLINLINE(void) hdaR3StreamDoDmaEpilogue(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3)
    1228 {
    1229     /*
    1230      * Clear the (pointless) FIFORDY bit again.
    1231      */
    1232     HDA_STREAM_REG(pThis, STS, pStreamShared->u8SD) &= ~HDA_SDSTS_FIFORDY;
    1233 
     1229DECLINLINE(void) hdaR3StreamDoDmaEpilogue(PPDMDEVINS pDevIns, PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3)
     1230{
    12341231    /*
    12351232     * We must update this in the epilogue rather than in the prologue
     
    15251522     * Common epilogue.
    15261523     */
    1527     hdaR3StreamDoDmaEpilogue(pDevIns, pThis, pStreamShared, pStreamR3);
     1524    hdaR3StreamDoDmaEpilogue(pDevIns, pStreamShared, pStreamR3);
    15281525
    15291526    /*
     
    18121809     * Common epilogue.
    18131810     */
    1814     hdaR3StreamDoDmaEpilogue(pDevIns, pThis, pStreamShared, pStreamR3);
     1811    hdaR3StreamDoDmaEpilogue(pDevIns, pStreamShared, pStreamR3);
    18151812
    18161813    /*
  • trunk/src/VBox/Devices/Audio/DevHdaStream.h

    r88357 r88572  
    354354void                hdaR3StreamReset(PHDASTATE pThis, PHDASTATER3 pThisCC,
    355355                                     PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, uint8_t uSD);
    356 int                 hdaR3StreamEnable(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, bool fEnable);
     356int                 hdaR3StreamEnable(PHDASTATE pThis, PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, bool fEnable);
    357357void                hdaR3StreamMarkStarted(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared, uint64_t tsNow);
    358358void                hdaR3StreamMarkStopped(PHDASTREAM pStreamShared);
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