Changeset 89748 in vbox
- Timestamp:
- Jun 16, 2021 4:06:33 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Audio/DevIchAc97.cpp
r89743 r89748 643 643 } while (0) 644 644 645 /** Retrieves an attribute from a specific audio stream in RC. */646 #define DEVAC97_CTX_SUFF_SD(a_Var, a_SD) CTX_SUFF(a_Var)[a_SD]647 648 645 /** 649 646 * Releases the AC'97 lock. … … 652 649 do { PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); } while (0) 653 650 654 /**655 * Acquires the TM lock and AC'97 lock, returns on failure.656 *657 * @todo r=bird: Isn't this overkill for ring-0, only ring-3 access the timer658 * from what I can tell (ichac97R3StreamTransferCalcNext,659 * ichac97R3TimerSet, timer callback and state load).660 */661 #define DEVAC97_LOCK_BOTH_RETURN(a_pDevIns, a_pThis, a_pStream, a_rcBusy) \662 do { \663 VBOXSTRICTRC rcLock = PDMDevHlpTimerLockClock2((a_pDevIns), (a_pStream)->hTimer, &(a_pThis)->CritSect, (a_rcBusy)); \664 if (RT_LIKELY(rcLock == VINF_SUCCESS)) \665 { /* likely */ } \666 else \667 { \668 AssertRC(VBOXSTRICTRC_VAL(rcLock)); \669 return rcLock; \670 } \671 } while (0)672 673 /**674 * Releases the AC'97 lock and TM lock.675 */676 #define DEVAC97_UNLOCK_BOTH(a_pDevIns, a_pThis, a_pStream) \677 PDMDevHlpTimerUnlockClock2((a_pDevIns), (a_pStream)->hTimer, &(a_pThis)->CritSect)678 651 679 652 #ifndef VBOX_DEVICE_STRUCT_TESTCASE … … 1995 1968 * @param fForce Whether to force re-opening the stream or not. 1996 1969 * Otherwise re-opening only will happen if the PCM properties have changed. 1970 * 1971 * @remarks This is called holding: 1972 * -# The AC'97 device lock. 1973 * -# The AC'97 stream lock. 1974 * -# The mixer sink lock (to prevent racing AIO thread). 1997 1975 */ 1998 1976 static int ichac97R3StreamSetUp(PPDMDEVINS pDevIns, PAC97STATE pThis, PAC97STATER3 pThisCC, PAC97STREAM pStream, … … 2668 2646 PAC97BMREGS pRegs = &pStream->Regs; 2669 2647 2670 /** @todo r=bird: this locking is overkill, we don't need the timer lock2671 * unless we're going to call ichac97R3TimerSet. */2672 DEVAC97_LOCK_BOTH_RETURN(pDevIns, pThis, pStream, VINF_IOM_R3_IOPORT_WRITE);2673 2648 switch (cb) 2674 2649 { … … 2680 2655 */ 2681 2656 case AC97_NABM_OFF_LVI: 2657 DEVAC97_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_IOPORT_WRITE); 2682 2658 if ( (pRegs->cr & AC97_CR_RPBM) 2683 2659 && (pRegs->sr & AC97_SR_DCH)) … … 2692 2668 } 2693 2669 pRegs->lvi = u32 % AC97_MAX_BDLE; 2670 DEVAC97_UNLOCK(pDevIns, pThis); 2694 2671 Log3Func(("[SD%RU8] LVI <- %#x\n", pStream->u8SD, u32)); 2695 2672 break; … … 2700 2677 case AC97_NABM_OFF_CR: 2701 2678 #ifdef IN_RING3 2679 DEVAC97_LOCK(pDevIns, pThis); 2680 2702 2681 Log3Func(("[SD%RU8] CR <- %#x (cr %#x)\n", pStream->u8SD, u32, pRegs->cr)); 2703 2682 if (u32 & AC97_CR_RR) /* Busmaster reset. */ … … 2713 2692 2714 2693 ichac97StreamUpdateSR(pDevIns, pThis, pStream, AC97_SR_DCH); /** @todo Do we need to do that? */ 2694 2695 DEVAC97_UNLOCK(pDevIns, pThis); 2715 2696 } 2716 2697 else … … 2725 2706 2726 2707 pRegs->sr |= AC97_SR_DCH; 2708 2709 DEVAC97_UNLOCK(pDevIns, pThis); 2727 2710 } 2728 2711 else 2729 2712 { 2713 /** @todo r=bird: How do we prevent the guest from triggering enable more 2714 * than once? */ 2730 2715 Log3Func(("[SD%RU8] Enable\n", pStream->u8SD)); 2731 2716 … … 2740 2725 ichac97R3StreamEnable(pDevIns, pThis, pThisCC, pStream, pStreamCC, true /* fEnable */); 2741 2726 2742 /* Arm the timer for this stream. */ 2743 ichac97R3TimerSet(pDevIns, pStream, pStreamCC->State.cTransferTicks); 2727 /* 2728 * Arm the DMA timer. Must drop the AC'97 device lock first as it would 2729 * create a lock order violation with the virtual sync time lock otherwise. 2730 */ 2731 uint64_t const cTicksToDeadline = pStreamCC->State.cTransferTicks; 2732 2733 DEVAC97_UNLOCK(pDevIns, pThis); 2734 2735 /** @todo take down the start time here. */ 2736 int rc2 = PDMDevHlpTimerSetRelative(pDevIns, pStream->hTimer, cTicksToDeadline, NULL /*pu64Now*/); 2737 AssertRC(rc2); 2744 2738 } 2745 2739 } … … 2753 2747 */ 2754 2748 case AC97_NABM_OFF_SR: 2749 DEVAC97_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_IOPORT_WRITE); 2755 2750 ichac97StreamWriteSR(pDevIns, pThis, pStream, u32); 2751 DEVAC97_UNLOCK(pDevIns, pThis); 2756 2752 break; 2757 2753 … … 2767 2763 { 2768 2764 case AC97_NABM_OFF_SR: 2765 DEVAC97_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_IOPORT_WRITE); 2769 2766 ichac97StreamWriteSR(pDevIns, pThis, pStream, u32); 2767 DEVAC97_UNLOCK(pDevIns, pThis); 2770 2768 break; 2771 2769 default: … … 2780 2778 { 2781 2779 case AC97_NABM_OFF_BDBAR: 2780 DEVAC97_LOCK_RETURN(pDevIns, pThis, VINF_IOM_R3_IOPORT_WRITE); 2782 2781 /* Buffer Descriptor list Base Address Register */ 2783 2782 pRegs->bdbar = u32 & ~(uint32_t)3; 2784 2783 Log3Func(("[SD%RU8] BDBAR <- %#x (bdbar %#x)\n", AC97_PORT2IDX(offPort), u32, pRegs->bdbar)); 2784 DEVAC97_UNLOCK(pDevIns, pThis); 2785 2785 break; 2786 2786 default: … … 2795 2795 break; 2796 2796 } 2797 DEVAC97_UNLOCK_BOTH(pDevIns, pThis, pStream);2798 2797 } 2799 2798 else
Note:
See TracChangeset
for help on using the changeset viewer.