VirtualBox

Changeset 53796 in vbox for trunk/src


Ignore:
Timestamp:
Jan 14, 2015 9:37:27 AM (10 years ago)
Author:
vboxsync
Message:

VMSVGA: Use new EMT wait API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r53791 r53796  
    2828*******************************************************************************/
    2929#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
     30#define VMSVGA_USE_EMT_HALT_CODE
    3031#include <VBox/vmm/pdmdev.h>
    3132#include <VBox/version.h>
     
    3334#include <VBox/log.h>
    3435#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
    3541#include <VBox/sup.h>
    3642
     
    121127    SVGAColorBGRX           colorAnnotation;
    122128
     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
    123135    /** Number of EMTs waiting on hBusyDelayedEmts. */
    124136    uint32_t volatile       cBusyDelayedEmts;
     
    126138     *  busy (ugly).  */
    127139    RTSEMEVENTMULTI         hBusyDelayedEmts;
     140#endif
    128141    /** Tracks how much time we waste reading SVGA_REG_BUSY with a busy FIFO. */
    129142    STAMPROFILE             StatBusyDelayEmts;
     
    182195    SSMFIELD_ENTRY(             VMSVGASTATE, colorAnnotation),
    183196    SSMFIELD_ENTRY_IGNORE(      VMSVGASTATE, cBusyDelayedEmts),
     197#ifdef VMSVGA_USE_EMT_HALT_CODE
     198    SSMFIELD_ENTRY_IGNORE(      VMSVGASTATE, BusyDelayedEmts),
     199#else
    184200    SSMFIELD_ENTRY_IGNORE(      VMSVGASTATE, hBusyDelayedEmts),
     201#endif
    185202    SSMFIELD_ENTRY_IGNORE(      VMSVGASTATE, StatBusyDelayEmts),
    186203    SSMFIELD_ENTRY_IGNORE(      VMSVGASTATE, StatR3CmdPresent),
     
    776793        {
    777794#ifndef IN_RING3
    778             /* Go to ring-3 and yield the CPU a bit. */
     795            /* Go to ring-3 and halt the CPU. */
    779796            rc = VINF_IOM_R3_IOPORT_READ;
    780797            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);
    781811#else
     812
    782813            /* Delay the EMT a bit so the FIFO and others can get some work done.
    783814               This used to be a crude 50 ms sleep. The current code tries to be
     
    808839            STAM_REL_PROFILE_STOP(&pSVGAState->StatBusyDelayEmts, EmtDelay);
    809840#endif
    810         }
    811         *pu32 = pThis->svga.fBusy != 0;
     841            *pu32 = pThis->svga.fBusy != 0;
     842        }
     843        else
     844            *pu32 = false;
    812845        break;
    813846
     
    19752008    if (pSVGAState->cBusyDelayedEmts > 0)
    19762009    {
     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
    19772021        int rc2 = RTSemEventMultiSignal(pSVGAState->hBusyDelayedEmts);
    19782022        AssertRC(rc2);
     2023#endif
    19792024    }
    19802025}
     
    37663811    if (pSVGAState)
    37673812    {
     3813# ifndef VMSVGA_USE_EMT_HALT_CODE
    37683814        if (pSVGAState->hBusyDelayedEmts != NIL_RTSEMEVENTMULTI)
    37693815        {
     
    37713817            pSVGAState->hBusyDelayedEmts = NIL_RTSEMEVENT;
    37723818        }
    3773 
     3819# endif
    37743820        if (pSVGAState->Cursor.fActive)
    37753821            RTMemFree(pSVGAState->Cursor.pData);
     
    38403886    }
    38413887
     3888# ifndef VMSVGA_USE_EMT_HALT_CODE
    38423889    /* Create semaphore for delaying EMTs wait for the FIFO to stop being busy. */
    38433890    rc = RTSemEventMultiCreate(&pSVGAState->hBusyDelayedEmts);
    38443891    AssertRCReturn(rc, rc);
     3892# endif
    38453893
    38463894    /* Register caps. */
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