VirtualBox

Changeset 51762 in vbox


Ignore:
Timestamp:
Jun 30, 2014 9:31:20 AM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94576
Message:

DisplayImpl: legacy video accel lock fixes, do not call VGA under the lock.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r51627 r51762  
    335335    void handleResizeCompletedEMT(unsigned uScreenId, BOOL fResizeContext);
    336336
     337    /* Old guest additions (3.x?) use VMMDev for VBVA and the host VBVA code (VideoAccel*)
     338     * can be executed concurrently by VGA refresh timer and the guest VMMDev request
     339     * in SMP VMs. The lock serialized this.
     340     */
    337341    RTCRITSECT mVBVALock;
    338342    volatile uint32_t mfu32PendingVideoAccelDisable;
     
    342346
    343347public:
     348    bool vbvaLockIsOwner(void);
     349
    344350    static int  displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
    345351
     
    369375    /* Functions run under VBVA lock. */
    370376    int  videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory);
    371     void videoAccelFlush(void);
     377    int videoAccelFlush(void);
    372378
    373379#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
  • trunk/src/VBox/Main/src-client/DisplayImpl.cpp

    r51724 r51762  
    399399
    400400                /* This can be called from any thread. */
     401                Assert(!that->vbvaLockIsOwner());
    401402                that->mpDrv->pUpPort->pfnFreeScreenshot(that->mpDrv->pUpPort, pu8Data);
    402403            }
     
    917918    if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
    918919    {
     920        Assert(!vbvaLockIsOwner());
    919921        mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, false);
    920922
     
    11601162    {
    11611163#endif /* VBOX_WITH_HGSMI */
    1162         /* When VBVA is enabled, the VRDP server is informed in the VideoAccelFlush.
     1164        /* When VBVA is enabled, the VRDP server is informed
     1165         * either in VideoAccelFlush or displayVBVAUpdateProcess.
    11631166         * Inform the server here only if VBVA is disabled.
    11641167         */
     
    15611564}
    15621565
     1566bool Display::vbvaLockIsOwner(void)
     1567{
     1568    return RTCritSectIsOwner(&mVBVALock);
     1569}
    15631570
    15641571/**
     
    15681575{
    15691576    int rc;
     1577
     1578    if (fEnable)
     1579    {
     1580        /* Process any pending VGA device changes, resize. */
     1581        Assert(!vbvaLockIsOwner());
     1582        mpDrv->pUpPort->pfnUpdateDisplay(mpDrv->pUpPort);
     1583    }
     1584
    15701585    vbvaLock();
    15711586    rc = videoAccelEnable (fEnable, pVbvaMemory);
    15721587    vbvaUnlock();
     1588
     1589    if (!fEnable)
     1590    {
     1591        Assert(!vbvaLockIsOwner());
     1592        mpDrv->pUpPort->pfnUpdateDisplay(mpDrv->pUpPort);
     1593    }
     1594
    15731595    return rc;
    15741596}
     
    15761598int Display::videoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory)
    15771599{
     1600    Assert(vbvaLockIsOwner());
     1601
    15781602    int rc = VINF_SUCCESS;
    15791603
     
    16331657    mfVideoAccelEnabled = false;
    16341658
    1635     /* Update entire display. */
    1636     mpDrv->pUpPort->pfnUpdateDisplayAll(mpDrv->pUpPort);
    1637 
    16381659    /* Everything OK. VBVA status can be changed. */
    16391660
     
    20142035{
    20152036    vbvaLock();
    2016     videoAccelFlush();
     2037    int rc = videoAccelFlush();
     2038    if (RT_FAILURE(rc))
     2039    {
     2040        /* Disable on errors. */
     2041        videoAccelEnable(false, NULL);
     2042    }
    20172043    vbvaUnlock();
    2018 }
    2019 
    2020 /* Under VBVA lock. DevVGA is not taken. */
    2021 void Display::videoAccelFlush (void)
    2022 {
     2044
     2045    if (RT_FAILURE(rc))
     2046    {
     2047        /* VideoAccel was disabled because of a failure, switching back to VGA updates. Redraw the screen. */
     2048        Assert(!vbvaLockIsOwner());
     2049        mpDrv->pUpPort->pfnUpdateDisplay(mpDrv->pUpPort);
     2050    }
     2051}
     2052
     2053int Display::videoAccelFlush (void)
     2054{
     2055    Assert(vbvaLockIsOwner());
     2056
    20232057#ifdef DEBUG_sunlover_2
    20242058    LogFlowFunc(("mfVideoAccelEnabled = %d\n", mfVideoAccelEnabled));
     
    20282062    {
    20292063        Log(("Display::VideoAccelFlush: called with disabled VBVA!!! Ignoring.\n"));
    2030         return;
     2064        return VINF_SUCCESS;
    20312065    }
    20322066
     
    20432077    if (mpVbvaMemory->indexRecordFirst == mpVbvaMemory->indexRecordFree)
    20442078    {
    2045         return;
     2079        return VINF_SUCCESS;
    20462080    }
    20472081
     
    20632097            Log(("Display::VideoAccelFlush: unable to fetch command. off32Data = %d, off32Free = %d. Disabling VBVA!!!\n",
    20642098                  mpVbvaMemory->off32Data, mpVbvaMemory->off32Free));
    2065 
    2066             /* Disable VBVA on those processing errors. */
    2067             videoAccelEnable (false, NULL);
    2068 
    2069             break;
     2099            return VERR_INVALID_STATE;
    20702100        }
    20712101
     
    21282158        vbvaRgnUpdateFramebuffer (&rgn, uScreenId);
    21292159    }
     2160    return VINF_SUCCESS;
    21302161}
    21312162
     
    21432174    {
    21442175        /* Acceleration was enabled while machine was not yet running
    2145          * due to restoring from saved state. Update entire display and
    2146          * actually enable acceleration.
     2176         * due to restoring from saved state. Actually enable acceleration.
    21472177         */
    21482178        Assert(mpPendingVbvaMemory);
     
    21712201        {
    21722202            Assert(mpVbvaMemory);
    2173             videoAccelFlush ();
    2174 
    2175             rc = VINF_SUCCESS; /* VBVA processed, no need to a display update. */
     2203            rc = videoAccelFlush();
     2204            if (RT_FAILURE(rc))
     2205            {
     2206                /* Disable on errors. */
     2207                videoAccelEnable(false, NULL);
     2208                rc = VWRN_INVALID_STATE; /* Do a display update in VGA device. */
     2209            }
     2210            else
     2211            {
     2212                rc = VINF_SUCCESS;
     2213            }
    21762214        }
    21772215    }
     
    22352273            u32Width = mpDrv->IConnector.cx;
    22362274            u32Height = mpDrv->IConnector.cy;
     2275
     2276            alock.release();
     2277
     2278            Assert(!vbvaLockIsOwner());
    22372279            int rc = mpDrv->pUpPort->pfnQueryColorDepth(mpDrv->pUpPort, &u32BitsPerPixel);
    22382280            AssertRC(rc);
     2281
     2282            alock.acquire();
    22392283        }
    22402284    }
     
    24052449    if (!bpp)
    24062450    {
     2451        alock.release();
     2452
    24072453        uint32_t cBits = 0;
     2454        Assert(!vbvaLockIsOwner());
    24082455        int rc = mpDrv->pUpPort->pfnQueryColorDepth(mpDrv->pUpPort, &cBits);
    24092456        AssertRC(rc);
    24102457        bpp = cBits;
     2458
     2459        alock.acquire();
    24112460    }
    24122461    ULONG cMonitors;
     
    25472596{
    25482597    int rc;
    2549     pDisplay->vbvaLock();
     2598
    25502599    if (   aScreenId == VBOX_VIDEO_PRIMARY_SCREEN
    25512600        && pDisplay->maFramebuffers[aScreenId].fVBVAEnabled == false) /* A non-VBVA mode. */
    25522601    {
     2602        Assert(!pDisplay->vbvaLockIsOwner());
    25532603        rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppu8Data, pcbData, pu32Width, pu32Height);
    25542604    }
     
    25902640                uint32_t u32DstBitsPerPixel = 32;
    25912641
     2642                Assert(!pDisplay->vbvaLockIsOwner());
    25922643                rc = pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
    25932644                                                           width, height,
     
    26152666                        && aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
    26162667                    {
     2668                        Assert(!pDisplay->vbvaLockIsOwner());
    26172669                        rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort,
    26182670                                                                         ppu8Data, pcbData, pu32Width, pu32Height);
     
    26352687        rc = VERR_INVALID_PARAMETER;
    26362688    }
    2637     pDisplay->vbvaUnlock();
     2689
    26382690    return rc;
    26392691}
     
    27002752        {
    27012753            /* This can be called from any thread. */
     2754            Assert(!pDisplay->vbvaLockIsOwner());
    27022755            pDrv->pUpPort->pfnFreeScreenshot(pDrv->pUpPort, pu8Data);
    27032756        }
     
    30603113{
    30613114    int rc = VINF_SUCCESS;
    3062     pDisplay->vbvaLock();
    30633115
    30643116    DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[aScreenId];
     
    30663118    if (aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
    30673119    {
     3120        Assert(!pDisplay->vbvaLockIsOwner());
    30683121        rc = pDisplay->mpDrv->pUpPort->pfnDisplayBlt(pDisplay->mpDrv->pUpPort, address, x, y, width, height);
    30693122    }
     
    30873140        uint32_t u32DstBitsPerPixel = pFBInfo->u16BitsPerPixel;
    30883141
     3142        Assert(!pDisplay->vbvaLockIsOwner());
    30893143        rc = pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
    30903144                                                   width, height,
     
    31393193                        u32DstBitsPerPixel = 32;
    31403194
     3195                        Assert(!pDisplay->vbvaLockIsOwner());
    31413196                        pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
    31423197                                                              width, height,
     
    31643219        pDisplay->mParent->i_consoleVRDPServer()->SendUpdateBitmap(aScreenId, x, y, width, height);
    31653220
    3166     pDisplay->vbvaUnlock();
    31673221    return rc;
    31683222}
     
    32313285void Display::InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll)
    32323286{
    3233     pDisplay->vbvaLock();
    32343287    unsigned uScreenId;
    32353288    for (uScreenId = (fUpdateAll ? 0 : uId); uScreenId < pDisplay->mcMonitors; uScreenId++)
     
    32403293            && uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
    32413294        {
     3295            Assert(!pDisplay->vbvaLockIsOwner());
    32423296            pDisplay->mpDrv->pUpPort->pfnUpdateDisplayAll(pDisplay->mpDrv->pUpPort);
    32433297        }
     
    32933347                        {
    32943348
     3349                            Assert(!pDisplay->vbvaLockIsOwner());
    32953350                            pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
    32963351                                                                  width, height,
     
    33133368            break;
    33143369    }
    3315     pDisplay->vbvaUnlock();
    33163370}
    33173371
     
    34873541    {
    34883542        if (fSetRenderVRAM)
     3543        {
     3544            Assert(!vbvaLockIsOwner());
    34893545            mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, true);
    3490 
    3491 // @todo later
    3492 //        if (fInvalidate)
    3493 //            VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT,
    3494 //                             3, this, aScreenId, false);
     3546        }
     3547
     3548        if (fInvalidate)
     3549            VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::InvalidateAndUpdateEMT,
     3550                             3, this, aScreenId, false);
    34953551    }
    34963552
     
    37313787            /* No VBVA do a display update. */
    37323788            DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN];
    3733             pDisplay->vbvaLock();
     3789            Assert(!pDisplay->vbvaLockIsOwner());
    37343790            pDrv->pUpPort->pfnUpdateDisplay(pDrv->pUpPort);
    3735             pDisplay->vbvaUnlock();
    37363791        }
    37373792
     
    45174572    {
    45184573        /* Force full screen update, because VGA device must take control, do resize, etc. */
    4519         pThis->mpDrv->pUpPort->pfnUpdateDisplayAll(pThis->mpDrv->pUpPort);
     4574        Assert(!pThis->vbvaLockIsOwner());
     4575        pThis->mpDrv->pUpPort->pfnUpdateDisplay(pThis->mpDrv->pUpPort);
    45204576    }
    45214577}
     
    45524608            && !pFBInfo->fDisabled)
    45534609        {
     4610            Assert(!pThis->vbvaLockIsOwner());
    45544611            pDrv->pUpPort->pfnUpdateDisplayRect (pDrv->pUpPort, pCmd->x, pCmd->y, pCmd->w, pCmd->h);
    45554612        }
     
    45924649                uint32_t u32DstBitsPerPixel = 32;
    45934650
     4651                Assert(!pThis->vbvaLockIsOwner());
    45944652                pDrv->pUpPort->pfnCopyRect(pDrv->pUpPort,
    45954653                                           width, height,
     
    48764934    LogRelFlowFunc(("iInstance=%d\n", pDrvIns->iInstance));
    48774935
     4936    if (pThis->pDisplay)
     4937        Assert(!pThis->pDisplay->vbvaLockIsOwner());
     4938
    48784939    pThis->pUpPort->pfnSetRenderVRAM(pThis->pUpPort, false);
    48794940
     
    49835044
    49845045    /* Disable VRAM to a buffer copy initially. */
     5046    Assert(!pDisplay->vbvaLockIsOwner());
    49855047    pThis->pUpPort->pfnSetRenderVRAM (pThis->pUpPort, false);
    49865048    pThis->IConnector.cBits = 32; /* DevVGA does nothing otherwise. */
     
    49895051     * Start periodic screen refreshes
    49905052     */
     5053    Assert(!pDisplay->vbvaLockIsOwner());
    49915054    pThis->pUpPort->pfnSetRefreshRate(pThis->pUpPort, 20);
    49925055
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette