VirtualBox

Changeset 89844 in vbox


Ignore:
Timestamp:
Jun 23, 2021 8:23:40 AM (4 years ago)
Author:
vboxsync
Message:

DevHda: Eliminated HDASTREAM::CritSect as it is not necessary. The AIO thread serialization happens via the sink lock, the rest via the device wide critical section. bugref:9890

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

Legend:

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

    r89822 r89844  
    13331333
    13341334        STAM_REL_PROFILE_START_NS(&pStreamR3->State.StatReset, a);
    1335         hdaStreamLock(pStreamShared);
     1335        Assert(PDMCritSectIsOwner(&pThis->CritSect));
    13361336        PAUDMIXSINK const pMixSink = pStreamR3->pMixSink ? pStreamR3->pMixSink->pMixSink : NULL;
    13371337        if (pMixSink)
     
    13501350        if (pMixSink) /* (FYI. pMixSink might not be what pStreamR3->pMixSink->pMixSink points at any longer) */
    13511351            AudioMixerSinkUnlock(pMixSink);
    1352         hdaStreamUnlock(pStreamShared);
    13531352        STAM_REL_PROFILE_STOP_NS(&pStreamR3->State.StatReset, a);
    13541353    }
     
    13641363            LogFunc(("[SD%RU8] State changed (fRun=%RTbool)\n", uSD, fRun));
    13651364
    1366             hdaStreamLock(pStreamShared);
     1365            Assert(PDMCritSectIsOwner(&pThis->CritSect));
    13671366            /** @todo bird: It's not clear to me when the pMixSink is actually
    13681367             *        assigned to the stream, so being paranoid till I find out... */
     
    14621461            if (pMixSink)
    14631462                AudioMixerSinkUnlock(pMixSink);
    1464             hdaStreamUnlock(pStreamShared);
    14651463            STAM_REL_PROFILE_STOP_NS((fRun ? &pStreamR3->State.StatStart : &pStreamR3->State.StatStop), r);
    14661464        }
     
    25202518            LogFunc(("Sink '%s' was assigned to stream #%RU8 (channel %RU8) before\n",
    25212519                     pSink->pMixSink->pszName, pOldStreamShared->u8SD, pOldStreamShared->u8Channel));
    2522 
    2523             hdaStreamLock(pOldStreamShared);
     2520            Assert(PDMCritSectIsOwner(&pThis->CritSect));
    25242521
    25252522            /* Only disable the stream if the stream descriptor # has changed. */
     
    25352532            pOldStreamR3->pMixSink = NULL;
    25362533
    2537             hdaStreamUnlock(pOldStreamShared);
    25382534
    25392535            pSink->pStreamShared = NULL;
     
    25502546            PHDASTREAMR3 pStreamR3     = &pThisCC->aStreams[uSD];
    25512547            PHDASTREAM   pStreamShared = &pThis->aStreams[uSD];
    2552             hdaStreamLock(pStreamShared);
     2548            Assert(PDMCritSectIsOwner(&pThis->CritSect));
    25532549
    25542550            pSink->pStreamR3     = pStreamR3;
     
    25582554            pStreamR3->pMixSink      = pSink;
    25592555
    2560             hdaStreamUnlock(pStreamShared);
    25612556            rc = VINF_SUCCESS;
    25622557        }
     
    27652760{
    27662761    LogFlowFuncEnter();
     2762    Assert(PDMCritSectIsOwner(&pThis->CritSect));
    27672763
    27682764    /*
     
    27742770        PHDASTREAM const   pStreamShared = &pThis->aStreams[idxStream];
    27752771        PHDASTREAMR3 const pStreamR3     = &pThisCC->aStreams[idxStream];
    2776         hdaStreamLock(pStreamShared);
    27772772        PAUDMIXSINK const pMixSink = pStreamR3->pMixSink ? pStreamR3->pMixSink->pMixSink : NULL;
    27782773        if (pMixSink)
     
    27892784        if (pMixSink) /* (FYI. pMixSink might not be what pStreamR3->pMixSink->pMixSink points at any longer) */
    27902785            AudioMixerSinkUnlock(pMixSink);
    2791         hdaStreamUnlock(pStreamShared);
    27922786    }
    27932787
     
    45924586
    45934587    for (uint8_t i = 0; i < HDA_MAX_STREAMS; i++)
    4594         hdaR3StreamDestroy(&pThis->aStreams[i], &pThisCC->aStreams[i]);
     4588        hdaR3StreamDestroy(&pThisCC->aStreams[i]);
    45954589
    45964590    /* We don't always go via PowerOff, so make sure the mixer is destroyed. */
  • trunk/src/VBox/Devices/Audio/DevHdaStream.cpp

    r89826 r89844  
    6464int hdaR3StreamConstruct(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, PHDASTATE pThis, PHDASTATER3 pThisCC, uint8_t uSD)
    6565{
    66     int rc;
    67 
    6866    pStreamR3->u8SD             = uSD;
    6967    pStreamShared->u8SD         = uSD;
     
    8179    AssertPtr(pStreamR3->pHDAStateR3);
    8280    AssertPtr(pStreamR3->pHDAStateR3->pDevIns);
    83     rc = PDMDevHlpCritSectInit(pStreamR3->pHDAStateR3->pDevIns, &pStreamShared->CritSect,
    84                                RT_SRC_POS, "hda_sd#%RU8", pStreamShared->u8SD);
    85     AssertRCReturn(rc, rc);
    8681
    8782#ifdef DEBUG
    88     rc = RTCritSectInit(&pStreamR3->Dbg.CritSect);
     83    int rc = RTCritSectInit(&pStreamR3->Dbg.CritSect);
    8984    AssertRCReturn(rc, rc);
    9085#endif
     
    155150    }
    156151
    157     return rc;
     152    return VINF_SUCCESS;
    158153}
    159154
     
    164159 * @param   pStreamR3           The HDA stream to destroy - ring-3 bits.
    165160 */
    166 void hdaR3StreamDestroy(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3)
    167 {
    168     LogFlowFunc(("[SD%RU8] Destroying ...\n", pStreamShared->u8SD));
     161void hdaR3StreamDestroy(PHDASTREAMR3 pStreamR3)
     162{
     163    LogFlowFunc(("[SD%RU8] Destroying ...\n", pStreamR3->u8SD));
    169164    int rc2;
    170165
     
    174169        AssertRC(rc2);
    175170        pStreamR3->State.pAioRegSink = NULL;
    176     }
    177 
    178     if (PDMCritSectIsInitialized(&pStreamShared->CritSect))
    179     {
    180         rc2 = PDMR3CritSectDelete(&pStreamShared->CritSect);
    181         AssertRC(rc2);
    182171    }
    183172
     
    19911980         * Do the DMA transfer.
    19921981         */
    1993         rc2 = PDMDevHlpCritSectEnter(pDevIns, &pStreamShared->CritSect, VERR_IGNORED);
    1994         AssertRC(rc2);
    1995 
    19961982        uint64_t const offWriteBefore = pStreamR3->State.offWrite;
    19971983        hdaR3StreamDoDmaOutput(pDevIns, pThis, pStreamShared, pStreamR3, RT_MIN(cbStreamFree, cbPeriod), tsNowNs);
    1998 
    1999         rc2 = PDMDevHlpCritSectLeave(pDevIns, &pStreamShared->CritSect);
    2000         AssertRC(rc2);
    20011984
    20021985        /*
     
    21542137         */
    21552138        if (cbStreamUsed)
    2156         {
    2157             rc2 = PDMDevHlpCritSectEnter(pDevIns, &pStreamShared->CritSect, VERR_IGNORED);
    2158             AssertRC(rc2);
    2159 
    21602139            hdaR3StreamDoDmaInput(pDevIns, pThis, pStreamShared, pStreamR3,
    21612140                                  RT_MIN(cbStreamUsed, cbPeriod), fWriteSilence, tsNowNs);
    2162 
    2163             rc2 = PDMDevHlpCritSectLeave(pDevIns, &pStreamShared->CritSect);
    2164             AssertRC(rc2);
    2165         }
    21662141
    21672142        /*
     
    22222197}
    22232198
    2224 #endif /* IN_RING3 */
    2225 
    2226 /**
    2227  * Locks an HDA stream for serialized access.
    2228  *
    2229  * @returns VBox status code.
    2230  * @param   pStreamShared       HDA stream to lock (shared bits).
    2231  */
    2232 void hdaStreamLock(PHDASTREAM pStreamShared)
    2233 {
    2234     AssertPtrReturnVoid(pStreamShared);
    2235     int rc2 = PDMCritSectEnter(&pStreamShared->CritSect, VINF_SUCCESS);
    2236     AssertRC(rc2);
    2237 }
    2238 
    2239 /**
    2240  * Unlocks a formerly locked HDA stream.
    2241  *
    2242  * @returns VBox status code.
    2243  * @param   pStreamShared       HDA stream to unlock (shared bits).
    2244  */
    2245 void hdaStreamUnlock(PHDASTREAM pStreamShared)
    2246 {
    2247     AssertPtrReturnVoid(pStreamShared);
    2248     int rc2 = PDMCritSectLeave(&pStreamShared->CritSect);
    2249     AssertRC(rc2);
    2250 }
    2251 
    2252 #ifdef IN_RING3
    22532199
    22542200#if 0 /* unused - no prototype even */
  • trunk/src/VBox/Devices/Audio/DevHdaStream.h

    r89821 r89844  
    238238    /** Pad the structure size to a 64 byte alignment. */
    239239    uint64_t                    au64Padding1[2];
    240     /** Critical section for serialize access to the stream state between the async
    241      * I/O thread and (basically) the guest. */
    242     PDMCRITSECT                 CritSect;
    243240} HDASTREAM;
    244241AssertCompileMemberAlignment(HDASTREAM, State.aBdl, 16);
     
    307304typedef HDASTREAMR3 *PHDASTREAMR3;
    308305
    309 /** @name Stream functions (shared).
    310  * @{
    311  */
    312 void                hdaStreamLock(PHDASTREAM pStreamShared);
    313 void                hdaStreamUnlock(PHDASTREAM pStreamShared);
    314 /** @} */
    315 
    316306#ifdef IN_RING3
    317307
     
    321311int                 hdaR3StreamConstruct(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3, PHDASTATE pThis,
    322312                                         PHDASTATER3 pThisCC, uint8_t uSD);
    323 void                hdaR3StreamDestroy(PHDASTREAM pStreamShared, PHDASTREAMR3 pStreamR3);
     313void                hdaR3StreamDestroy(PHDASTREAMR3 pStreamR3);
    324314int                 hdaR3StreamSetUp(PPDMDEVINS pDevIns, PHDASTATE pThis, PHDASTREAM pStreamShared,
    325315                                     PHDASTREAMR3 pStreamR3, uint8_t uSD);
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