Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPVidModes.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPVidModes.cpp	(revision 40797)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/common/VBoxMPVidModes.cpp	(revision 40842)
@@ -536,5 +536,5 @@
     if (!VBoxLikesVideoMode(iDisplay, xres, yres, bpp))
     {
-        WARN(("host does not like special mode %dx%d:%d for display %d", xres, yres, bpp, iDisplay));
+        WARN_NOBP(("host does not like special mode %dx%d:%d for display %d", xres, yres, bpp, iDisplay));
         return FALSE;
     }
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h	(revision 40797)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPTypes.h	(revision 40842)
@@ -142,4 +142,5 @@
     uint32_t iIndex;
     uint32_t cOpens;
+    KSPIN_LOCK OpenLock;
     LIST_ENTRY OpenList;
     /* helps tracking when to release wine shared resource */
@@ -287,4 +288,5 @@
     PVBOXWDDM_DEVICE pDevice;
     uint32_t cShRcRefs;
+    uint32_t cOpens;
 } VBOXWDDM_OPENALLOCATION, *PVBOXWDDM_OPENALLOCATION;
 
Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp	(revision 40797)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPWddm.cpp	(revision 40842)
@@ -49,4 +49,46 @@
 {
     ExFreePool(pvMem);
+}
+
+DECLINLINE(void) VBoxWddmOaRelease(PVBOXWDDM_OPENALLOCATION pOa)
+{
+    PVBOXWDDM_ALLOCATION pAllocation = pOa->pAllocation;
+    KIRQL OldIrql;
+    KeAcquireSpinLock(&pAllocation->OpenLock, &OldIrql);
+    Assert(pAllocation->cOpens);
+    --pAllocation->cOpens;
+    uint32_t cOpens = --pOa->cOpens;
+    Assert(cOpens < UINT32_MAX/2);
+    if (!cOpens)
+    {
+        RemoveEntryList(&pOa->ListEntry);
+        KeReleaseSpinLock(&pAllocation->OpenLock, OldIrql);
+        vboxWddmMemFree(pOa);
+    }
+    else
+        KeReleaseSpinLock(&pAllocation->OpenLock, OldIrql);
+}
+
+DECLINLINE(PVBOXWDDM_OPENALLOCATION) VBoxWddmOaSearchLocked(PVBOXWDDM_DEVICE pDevice, PVBOXWDDM_ALLOCATION pAllocation)
+{
+    for (PLIST_ENTRY pCur = pAllocation->OpenList.Flink; pCur != &pAllocation->OpenList; pCur = pCur->Flink)
+    {
+        PVBOXWDDM_OPENALLOCATION pCurOa = CONTAINING_RECORD(pCur, VBOXWDDM_OPENALLOCATION, ListEntry);
+        if (pCurOa->pDevice == pDevice)
+        {
+            return pCurOa;
+        }
+    }
+    return NULL;
+}
+
+DECLINLINE(PVBOXWDDM_OPENALLOCATION) VBoxWddmOaSearch(PVBOXWDDM_DEVICE pDevice, PVBOXWDDM_ALLOCATION pAllocation)
+{
+    PVBOXWDDM_OPENALLOCATION pOa;
+    KIRQL OldIrql;
+    KeAcquireSpinLock(&pAllocation->OpenLock, &OldIrql);
+    pOa = VBoxWddmOaSearchLocked(pDevice, pAllocation);
+    KeReleaseSpinLock(&pAllocation->OpenLock, OldIrql);
+    return pOa;
 }
 
@@ -2020,4 +2062,5 @@
             pAllocation->bVisible = FALSE;
             pAllocation->bAssigned = FALSE;
+            KeInitializeSpinLock(&pAllocation->OpenLock);
             InitializeListHead(&pAllocation->OpenList);
 
@@ -3991,15 +4034,5 @@
                 }
 
-                PVBOXWDDM_OPENALLOCATION pOa = NULL;
-                for (PLIST_ENTRY pCur = pAlloc->OpenList.Flink; pCur != &pAlloc->OpenList; pCur = pCur->Flink)
-                {
-                    PVBOXWDDM_OPENALLOCATION pCurOa = CONTAINING_RECORD(pCur, VBOXWDDM_OPENALLOCATION, ListEntry);
-                    if (pCurOa->pDevice == pDevice)
-                    {
-                        pOa = pCurOa;
-                        break;
-                    }
-                }
-
+                PVBOXWDDM_OPENALLOCATION pOa = VBoxWddmOaSearch(pDevice, pAlloc);
                 if (!pOa)
                 {
@@ -4867,4 +4900,6 @@
 }
 
+
+
 /*
  * DxgkDdiOpenAllocation
@@ -4916,41 +4951,15 @@
             }
 
-            PVBOXWDDM_OPENALLOCATION pOa = (PVBOXWDDM_OPENALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_OPENALLOCATION));
-            if (!pOa)
-            {
-                WARN(("failed to allocation alloc info"));
-                Status = STATUS_INSUFFICIENT_RESOURCES;
-                break;
-            }
-
 #ifdef DEBUG
-            for (PLIST_ENTRY pCur = pAllocation->OpenList.Flink; pCur != &pAllocation->OpenList; pCur = pCur->Flink)
-            {
-                PVBOXWDDM_OPENALLOCATION pCurOa = CONTAINING_RECORD(pCur, VBOXWDDM_OPENALLOCATION, ListEntry);
-                if (pCurOa->pDevice == pDevice)
-                {
-                    /* should not happen */
-                    Assert(0);
-                    break;
-                }
-            }
             Assert(!pAllocation->fAssumedDeletion);
 #endif
-            InsertHeadList(&pAllocation->OpenList, &pOa->ListEntry);
-            pOa->hAllocation = pInfo->hAllocation;
-            pOa->pAllocation = pAllocation;
-            pOa->pDevice = pDevice;
-            pInfo->hDeviceSpecificAllocation = pOa;
-
-
             if (pRcInfo)
             {
                 Assert(pAllocation->enmType == VBOXWDDM_ALLOC_TYPE_UMD_RC_GENERIC);
 
-                if (pInfo->PrivateDriverDataSize < sizeof (VBOXWDDM_ALLOCINFO)
+                if (pInfo->PrivateDriverDataSize != sizeof (VBOXWDDM_ALLOCINFO)
                         || !pInfo->pPrivateDriverData)
                 {
                     WARN(("invalid data size"));
-                    vboxWddmMemFree(pOa);
                     Status = STATUS_INVALID_PARAMETER;
                     break;
@@ -4969,5 +4978,47 @@
             }
 
-            ++pAllocation->cOpens;
+            KIRQL OldIrql;
+            PVBOXWDDM_OPENALLOCATION pOa;
+            KeAcquireSpinLock(&pAllocation->OpenLock, &OldIrql);
+            pOa = VBoxWddmOaSearchLocked(pDevice, pAllocation);
+            if (pOa)
+            {
+                ++pOa->cOpens;
+                ++pAllocation->cOpens;
+                KeReleaseSpinLock(&pAllocation->OpenLock, OldIrql);
+            }
+            else
+            {
+                KeReleaseSpinLock(&pAllocation->OpenLock, OldIrql);
+                pOa = (PVBOXWDDM_OPENALLOCATION)vboxWddmMemAllocZero(sizeof (VBOXWDDM_OPENALLOCATION));
+                if (!pOa)
+                {
+                    WARN(("failed to allocation alloc info"));
+                    Status = STATUS_INSUFFICIENT_RESOURCES;
+                    break;
+                }
+
+                pOa->hAllocation = pInfo->hAllocation;
+                pOa->pAllocation = pAllocation;
+                pOa->pDevice = pDevice;
+                pOa->cOpens = 1;
+
+                PVBOXWDDM_OPENALLOCATION pConcurrentOa;
+                KeAcquireSpinLock(&pAllocation->OpenLock, &OldIrql);
+                pConcurrentOa = VBoxWddmOaSearchLocked(pDevice, pAllocation);
+                if (!pConcurrentOa)
+                    InsertHeadList(&pAllocation->OpenList, &pOa->ListEntry);
+                else
+                    ++pConcurrentOa->cOpens;
+                ++pAllocation->cOpens;
+                KeReleaseSpinLock(&pAllocation->OpenLock, OldIrql);
+                if (pConcurrentOa)
+                {
+                    vboxWddmMemFree(pOa);
+                    pOa = pConcurrentOa;
+                }
+            }
+
+            pInfo->hDeviceSpecificAllocation = pOa;
         }
 
@@ -4978,9 +5029,5 @@
                 DXGK_OPENALLOCATIONINFO* pInfo2Free = &pOpenAllocation->pOpenAllocation[j];
                 PVBOXWDDM_OPENALLOCATION pOa2Free = (PVBOXWDDM_OPENALLOCATION)pInfo2Free->hDeviceSpecificAllocation;
-                PVBOXWDDM_ALLOCATION pAllocation = pOa2Free->pAllocation;
-                RemoveEntryList(&pOa2Free->ListEntry);
-                Assert(pAllocation->cOpens);
-                --pAllocation->cOpens;
-                vboxWddmMemFree(pOa2Free);
+                VBoxWddmOaRelease(pOa2Free);
             }
         }
@@ -5011,10 +5058,7 @@
         PVBOXWDDM_OPENALLOCATION pOa2Free = (PVBOXWDDM_OPENALLOCATION)pCloseAllocation->pOpenHandleList[i];
         PVBOXWDDM_ALLOCATION pAllocation = pOa2Free->pAllocation;
-        RemoveEntryList(&pOa2Free->ListEntry);
         Assert(pAllocation->cShRcRefs >= pOa2Free->cShRcRefs);
         pAllocation->cShRcRefs -= pOa2Free->cShRcRefs;
-        Assert(pAllocation->cOpens);
-        --pAllocation->cOpens;
-        vboxWddmMemFree(pOa2Free);
+        VBoxWddmOaRelease(pOa2Free);
     }
 
