Index: /trunk/include/VBox/vmm/pdmifs.h
===================================================================
--- /trunk/include/VBox/vmm/pdmifs.h	(revision 51012)
+++ /trunk/include/VBox/vmm/pdmifs.h	(revision 51013)
@@ -3073,9 +3073,6 @@
      * @param   pCmd                The Video HW Acceleration Command that was
      *                              completed.
-     * @todo r=bird: if async means asynchronous; then
-     *                   s/pfnVHWACommandCompleteAsynch/pfnVHWACommandCompleteAsync/;
-     *               fi
-     */
-    DECLR3CALLBACKMEMBER(int, pfnVHWACommandCompleteAsynch, (PPDMIDISPLAYVBVACALLBACKS pInterface,
+     */
+    DECLR3CALLBACKMEMBER(int, pfnVHWACommandCompleteAsync, (PPDMIDISPLAYVBVACALLBACKS pInterface,
                                                              PVBOXVHWACMD pCmd));
 
@@ -3095,5 +3092,5 @@
 } PDMIDISPLAYVBVACALLBACKS;
 /** PDMIDISPLAYVBVACALLBACKS  */
-#define PDMIDISPLAYVBVACALLBACKS_IID            "193b2975-215f-480a-abef-42f029ae890f"
+#define PDMIDISPLAYVBVACALLBACKS_IID            "ddac0bd0-332d-4671-8853-732921a80216"
 
 /** Pointer to a PCI raw connector interface. */
Index: /trunk/src/VBox/Devices/Graphics/DevVGA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 51012)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA.cpp	(revision 51013)
@@ -5983,5 +5983,5 @@
 #if defined(VBOX_WITH_HGSMI)
 # if defined(VBOX_WITH_VIDEOHWACCEL)
-    pThis->IVBVACallbacks.pfnVHWACommandCompleteAsynch = vbvaVHWACommandCompleteAsynch;
+    pThis->IVBVACallbacks.pfnVHWACommandCompleteAsync = vbvaVHWACommandCompleteAsync;
 # endif
 #if defined(VBOX_WITH_CRHGSMI)
Index: /trunk/src/VBox/Devices/Graphics/DevVGA.h
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 51012)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA.h	(revision 51013)
@@ -605,5 +605,5 @@
 
 # ifdef VBOX_WITH_VIDEOHWACCEL
-int vbvaVHWACommandCompleteAsynch(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd);
+int vbvaVHWACommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd);
 int vbvaVHWAConstruct (PVGASTATE pVGAState);
 int vbvaVHWAReset (PVGASTATE pVGAState);
Index: /trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp	(revision 51012)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp	(revision 51013)
@@ -802,5 +802,5 @@
     {
         Assert(pCommand->Flags & VBOXVHWACMD_FLAG_HG_ASYNCH);
-        vbvaVHWACommandCompleteAsynch(&pVGAState->IVBVACallbacks, pCommand);
+        vbvaVHWACommandCompleteAsync(&pVGAState->IVBVACallbacks, pCommand);
     }
     else
@@ -1241,5 +1241,5 @@
 }
 
-int vbvaVHWACommandCompleteAsynch(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd)
+int vbvaVHWACommandCompleteAsync(PPDMIDISPLAYVBVACALLBACKS pInterface, PVBOXVHWACMD pCmd)
 {
     int rc;
Index: /trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
===================================================================
--- /trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp	(revision 51012)
+++ /trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp	(revision 51013)
@@ -1334,5 +1334,5 @@
             }
 
-            rc = VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, false);
+            rc = VBoxVDMAThreadTerm(&pVdma->Thread, NULL, NULL, true);
             if (RT_FAILURE(rc))
             {
@@ -2752,5 +2752,5 @@
     }
     else
-        WARN(("vdmaVBVACtlSubmit failed %d\n", rc));
+        Log(("vdmaVBVACtlSubmit failed %d\n", rc));
 
     RTSemEventDestroy(Data.hEvent);
Index: /trunk/src/VBox/Main/include/DisplayImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/DisplayImpl.h	(revision 51012)
+++ /trunk/src/VBox/Main/include/DisplayImpl.h	(revision 51013)
@@ -244,5 +244,5 @@
 
 #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
-    void crViewportNotify(class VMMDev *pVMMDev, ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
+    int crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
 #endif
 
@@ -346,4 +346,5 @@
     /* for fast host hgcm calls */
     HGCMCVSHANDLE mhCrOglSvc;
+    RTCRITSECTRW mCrOglLock;
 #endif
 #ifdef VBOX_WITH_CROGL
Index: /trunk/src/VBox/Main/src-client/DisplayImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/DisplayImpl.cpp	(revision 51012)
+++ /trunk/src/VBox/Main/src-client/DisplayImpl.cpp	(revision 51013)
@@ -152,4 +152,6 @@
 #ifdef VBOX_WITH_CRHGSMI
     mhCrOglSvc = NULL;
+    rc = RTCritSectRwInit(&mCrOglLock);
+    AssertRC(rc);
 #endif
 #ifdef VBOX_WITH_CROGL
@@ -182,4 +184,12 @@
         RT_ZERO(mSaveSeamlessRectLock);
     }
+
+#ifdef VBOX_WITH_CRHGSMI
+    if (RTCritSectRwIsInitialized (&mCrOglLock))
+    {
+        RTCritSectRwDelete (&mCrOglLock);
+        RT_ZERO(mCrOglLock);
+    }
+#endif
     BaseFinalRelease();
 }
@@ -3486,5 +3496,5 @@
 {
 #ifdef VBOX_WITH_VIDEOHWACCEL
-    mpDrv->pVBVACallbacks->pfnVHWACommandCompleteAsynch(mpDrv->pVBVACallbacks, (PVBOXVHWACMD)pCommand);
+    mpDrv->pVBVACallbacks->pfnVHWACommandCompleteAsync(mpDrv->pVBVACallbacks, (PVBOXVHWACMD)pCommand);
     return S_OK;
 #else
@@ -3508,11 +3518,6 @@
     if (is3denabled)
     {
-        VMMDev *pVMMDev = mParent->getVMMDev();
-
-        if (pVMMDev)
-        {
-            crViewportNotify(pVMMDev, aScreenId, x, y, width, height);
-        }
-        else
+        int rc = crViewportNotify(aScreenId, x, y, width, height);
+        if (RT_FAILURE(rc))
         {
             DISPLAYFBINFO *pFb = &maFramebuffers[aScreenId];
@@ -3611,6 +3616,10 @@
 
 #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
-void Display::crViewportNotify(VMMDev *pVMMDev, ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height)
-{
+int Display::crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height)
+{
+    VMMDev *pVMMDev = mParent->getVMMDev();
+    if (!pVMMDev)
+        return VERR_INVALID_STATE;
+
     struct {
         VBOXCRCMDCTL_HGCM data;
@@ -3636,5 +3645,5 @@
     s.data.aParms[4].u.uint32 = height;
 
-    crCtlSubmitSync(&s.data.Hdr, RT_OFFSETOF(VBOXCRCMDCTL_HGCM, aParms[5]));
+    return crCtlSubmitSync(&s.data.Hdr, RT_OFFSETOF(VBOXCRCMDCTL_HGCM, aParms[5]));
 }
 #endif
@@ -3645,7 +3654,11 @@
     VMMDev *pVMMDev = mParent->getVMMDev();
     Assert(pVMMDev);
-    int rc = VERR_GENERAL_FAILURE;
+    int rc = RTCritSectRwEnterExcl(&mCrOglLock);
+    AssertRC(rc);
+
     if (pVMMDev)
         rc = pVMMDev->hgcmHostSvcHandleCreate("VBoxSharedCrOpenGL", &mhCrOglSvc);
+    else
+        rc = VERR_GENERAL_FAILURE;
 
     if (RT_SUCCESS(rc))
@@ -3666,19 +3679,21 @@
         rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_CRHGSMI_CTL, 1, &parm);
         if (RT_SUCCESS(rc))
-        {
             mCrOglCallbacks = Completion.MainInterface;
-
-            return;
-        }
-
-        AssertMsgFailed(("VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_COMPLETION failed rc %d", rc));
-    }
-
+        else
+            AssertMsgFailed(("VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_COMPLETION failed rc %d", rc));
+    }
+
+    if (RT_FAILURE(rc))
+        mhCrOglSvc = NULL;
+
+    RTCritSectRwLeaveExcl(&mCrOglLock);
+}
+
+void Display::destructCrHgsmiData(void)
+{
+    int rc = RTCritSectRwEnterExcl(&mCrOglLock);
+    AssertRC(rc);
     mhCrOglSvc = NULL;
-}
-
-void Display::destructCrHgsmiData(void)
-{
-    mhCrOglSvc = NULL;
+    RTCritSectRwLeaveExcl(&mCrOglLock);
 }
 #endif
@@ -4350,6 +4365,12 @@
                             continue;
 
-                        crViewportNotify(pVMMDev, ul, pFb->pendingViewportInfo.x, pFb->pendingViewportInfo.y, pFb->pendingViewportInfo.width, pFb->pendingViewportInfo.height);
-                        pFb->pendingViewportInfo.fPending = false;
+                        rc = crViewportNotify(ul, pFb->pendingViewportInfo.x, pFb->pendingViewportInfo.y, pFb->pendingViewportInfo.width, pFb->pendingViewportInfo.height);
+                        if (RT_SUCCESS(rc))
+                            pFb->pendingViewportInfo.fPending = false;
+                        else
+                        {
+                            AssertMsgFailed(("crViewportNotify failed %d\n", rc));
+                            rc = VINF_SUCCESS;
+                        }
                     }
                 }
@@ -4439,10 +4460,30 @@
 int Display::crCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion)
 {
-    return mpDrv->pVBVACallbacks->pfnCrCtlSubmit(mpDrv->pVBVACallbacks, pCmd, cbCmd, pfnCompletion, pvCompletion);
+    int rc = RTCritSectRwEnterShared(&mCrOglLock);
+    if (RT_SUCCESS(rc))
+    {
+        if (mhCrOglSvc)
+            rc = mpDrv->pVBVACallbacks->pfnCrCtlSubmit(mpDrv->pVBVACallbacks, pCmd, cbCmd, pfnCompletion, pvCompletion);
+        else
+            rc = VERR_NOT_SUPPORTED;
+
+        RTCritSectRwLeaveShared(&mCrOglLock);
+    }
+    return rc;
 }
 
 int Display::crCtlSubmitSync(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd)
 {
-    return mpDrv->pVBVACallbacks->pfnCrCtlSubmitSync(mpDrv->pVBVACallbacks, pCmd, cbCmd);
+    int rc = RTCritSectRwEnterShared(&mCrOglLock);
+    if (RT_SUCCESS(rc))
+    {
+        if (mhCrOglSvc)
+            rc = mpDrv->pVBVACallbacks->pfnCrCtlSubmitSync(mpDrv->pVBVACallbacks, pCmd, cbCmd);
+        else
+            rc = VERR_NOT_SUPPORTED;
+
+        RTCritSectRwLeaveShared(&mCrOglLock);
+    }
+    return rc;
 }
 
