- Timestamp:
- Jan 14, 2015 9:37:27 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r53791 r53796 28 28 *******************************************************************************/ 29 29 #define LOG_GROUP LOG_GROUP_DEV_VMSVGA 30 #define VMSVGA_USE_EMT_HALT_CODE 30 31 #include <VBox/vmm/pdmdev.h> 31 32 #include <VBox/version.h> … … 33 34 #include <VBox/log.h> 34 35 #include <VBox/vmm/pgm.h> 36 #ifdef VMSVGA_USE_EMT_HALT_CODE 37 # include <VBox/vmm/vmapi.h> 38 # include <VBox/vmm/vmcpuset.h> 39 # include <VBox/vmm/vm.h> /* Need VMCPU::idCpu. */ 40 #endif 35 41 #include <VBox/sup.h> 36 42 … … 121 127 SVGAColorBGRX colorAnnotation; 122 128 129 #ifdef VMSVGA_USE_EMT_HALT_CODE 130 /** Number of EMTs in BusyDelayedEmts (quicker than scanning the set). */ 131 uint32_t volatile cBusyDelayedEmts; 132 /** Set of EMTs that are */ 133 VMCPUSET BusyDelayedEmts; 134 #else 123 135 /** Number of EMTs waiting on hBusyDelayedEmts. */ 124 136 uint32_t volatile cBusyDelayedEmts; … … 126 138 * busy (ugly). */ 127 139 RTSEMEVENTMULTI hBusyDelayedEmts; 140 #endif 128 141 /** Tracks how much time we waste reading SVGA_REG_BUSY with a busy FIFO. */ 129 142 STAMPROFILE StatBusyDelayEmts; … … 182 195 SSMFIELD_ENTRY( VMSVGASTATE, colorAnnotation), 183 196 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, cBusyDelayedEmts), 197 #ifdef VMSVGA_USE_EMT_HALT_CODE 198 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, BusyDelayedEmts), 199 #else 184 200 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, hBusyDelayedEmts), 201 #endif 185 202 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, StatBusyDelayEmts), 186 203 SSMFIELD_ENTRY_IGNORE( VMSVGASTATE, StatR3CmdPresent), … … 776 793 { 777 794 #ifndef IN_RING3 778 /* Go to ring-3 and yield the CPU a bit. */795 /* Go to ring-3 and halt the CPU. */ 779 796 rc = VINF_IOM_R3_IOPORT_READ; 780 797 break; 798 #elif defined(VMSVGA_USE_EMT_HALT_CODE) 799 /* The guest is basically doing a HLT via the device here, but with 800 a special wake up condition on FIFO completion. */ 801 PVMSVGASTATE pSVGAState = (PVMSVGASTATE)pThis->svga.pSVGAState; 802 STAM_REL_PROFILE_START(&pSVGAState->StatBusyDelayEmts, EmtDelay); 803 PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3); 804 VMCPUID idCpu = PDMDevHlpGetVMCPU(pThis->pDevInsR3)->idCpu; /** @todo add a separate dev helper for this. */ 805 VMCPUSET_ATOMIC_ADD(&pSVGAState->BusyDelayedEmts, idCpu); 806 ASMAtomicIncU32(&pSVGAState->cBusyDelayedEmts); 807 if (pThis->svga.fBusy) 808 rc = VMR3WaitForDeviceReady(pVM, idCpu); 809 ASMAtomicDecU32(&pSVGAState->cBusyDelayedEmts); 810 VMCPUSET_ATOMIC_DEL(&pSVGAState->BusyDelayedEmts, idCpu); 781 811 #else 812 782 813 /* Delay the EMT a bit so the FIFO and others can get some work done. 783 814 This used to be a crude 50 ms sleep. The current code tries to be … … 808 839 STAM_REL_PROFILE_STOP(&pSVGAState->StatBusyDelayEmts, EmtDelay); 809 840 #endif 810 } 811 *pu32 = pThis->svga.fBusy != 0; 841 *pu32 = pThis->svga.fBusy != 0; 842 } 843 else 844 *pu32 = false; 812 845 break; 813 846 … … 1975 2008 if (pSVGAState->cBusyDelayedEmts > 0) 1976 2009 { 2010 #ifdef VMSVGA_USE_EMT_HALT_CODE 2011 PVM pVM = PDMDevHlpGetVM(pThis->pDevInsR3); 2012 VMCPUID idCpu = VMCpuSetFindLastPresentInternal(&pSVGAState->BusyDelayedEmts); 2013 if (idCpu != NIL_VMCPUID) 2014 { 2015 VMR3NotifyCpuDeviceReady(pVM, idCpu); 2016 while (idCpu-- > 0) 2017 if (VMCPUSET_IS_PRESENT(&pSVGAState->BusyDelayedEmts, idCpu)) 2018 VMR3NotifyCpuDeviceReady(pVM, idCpu); 2019 } 2020 #else 1977 2021 int rc2 = RTSemEventMultiSignal(pSVGAState->hBusyDelayedEmts); 1978 2022 AssertRC(rc2); 2023 #endif 1979 2024 } 1980 2025 } … … 3766 3811 if (pSVGAState) 3767 3812 { 3813 # ifndef VMSVGA_USE_EMT_HALT_CODE 3768 3814 if (pSVGAState->hBusyDelayedEmts != NIL_RTSEMEVENTMULTI) 3769 3815 { … … 3771 3817 pSVGAState->hBusyDelayedEmts = NIL_RTSEMEVENT; 3772 3818 } 3773 3819 # endif 3774 3820 if (pSVGAState->Cursor.fActive) 3775 3821 RTMemFree(pSVGAState->Cursor.pData); … … 3840 3886 } 3841 3887 3888 # ifndef VMSVGA_USE_EMT_HALT_CODE 3842 3889 /* Create semaphore for delaying EMTs wait for the FIFO to stop being busy. */ 3843 3890 rc = RTSemEventMultiCreate(&pSVGAState->hBusyDelayedEmts); 3844 3891 AssertRCReturn(rc, rc); 3892 # endif 3845 3893 3846 3894 /* Register caps. */
Note:
See TracChangeset
for help on using the changeset viewer.