Patch for DevAHCI model to really kick the consumer of requests (WiP)

+++ a/src/virtualbox6/src/VBox/Devices/Storage/DevAHCI.cpp
+++ b/src/virtualbox6/src/VBox/Devices/Storage/DevAHCI.cpp
@@ -384,6 +384,7 @@
 
     /** The event semaphore the processing thread waits on. */
     SUPSEMEVENT                     hEvtProcess;
+    SUPSEMEVENT                     hEvtProcessAck;
 
     /** The serial numnber to use for IDENTIFY DEVICE commands. */
     char                            szSerialNumber[AHCI_SERIAL_NUMBER_LENGTH+1]; /** < one extra byte for termination */
@@ -1048,6 +1049,7 @@
 {
     LogFlowFunc(("Signal event semaphore\n"));
     int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess);
+    PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pAhciPort->hEvtProcessAck, RT_INDEFINITE_WAIT);
     AssertRC(rc);
 }
 
@@ -1324,6 +1326,7 @@
                     ASMAtomicOrU32(&pAhciPort->u32TasksNew, pAhciPort->regCI);
                     LogFlowFunc(("Signal event semaphore\n"));
                     int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess);
+                    PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pAhciPort->hEvtProcessAck, RT_INDEFINITE_WAIT);
                     AssertRC(rc);
                 }
             }
@@ -1480,6 +1483,13 @@
  */
 static VBOXSTRICTRC PortIntrSts_r(PPDMDEVINS pDevIns, PAHCI pThis, PAHCIPORT pAhciPort, uint32_t iReg, uint32_t *pu32Value)
 {
+	if (pAhciPort->regIS == 0) {
+		if (pAhciPort->hEvtProcess != NIL_SUPSEMEVENT) {
+			PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess);
+			PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pAhciPort->hEvtProcessAck, RT_INDEFINITE_WAIT);
+		}
+	}
+
     RT_NOREF(pDevIns, pThis, iReg);
     ahciLog(("%s: read regIS=%#010x\n", __FUNCTION__, pAhciPort->regIS));
     ahciLog(("%s: CPDS=%d TFES=%d HBFS=%d HBDS=%d IFS=%d INFS=%d OFS=%d IPMS=%d PRCS=%d DIS=%d PCS=%d DPS=%d UFS=%d SDBS=%d DSS=%d PSS=%d DHRS=%d\n",
@@ -4518,6 +4528,7 @@
         {
             Assert(ASMAtomicReadBool(&pAhciPort->fWrkThreadSleeping));
             rc = PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pAhciPort->hEvtProcess, RT_INDEFINITE_WAIT);
+            PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcessAck);
             AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_INTERRUPTED, ("%Rrc\n", rc), rc);
             if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))
                 break;
@@ -4639,7 +4650,9 @@
     PAHCIPORTR3 pAhciPortR3 = (PAHCIPORTR3)pThread->pvUser;
     PAHCI       pThis       = PDMDEVINS_2_DATA(pDevIns, PAHCI);
     PAHCIPORT   pAhciPort   = &RT_SAFE_SUBSCRIPT(pThis->aPorts, pAhciPortR3->iLUN);
-    return PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess);
+    int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess);
+    PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pAhciPort->hEvtProcessAck, RT_INDEFINITE_WAIT);
+    return rc;
 }
 
 /* -=-=-=-=- DBGF -=-=-=-=- */
@@ -5339,6 +5352,7 @@
 
             /* Notify the async IO thread. */
             int rc = PDMDevHlpSUPSemEventSignal(pDevIns, pAhciPort->hEvtProcess);
+            PDMDevHlpSUPSemEventWaitNoResume(pDevIns, pAhciPort->hEvtProcessAck, RT_INDEFINITE_WAIT);
             AssertRC(rc);
         }
     }
@@ -5577,6 +5591,10 @@
         if (RT_FAILURE(rc))
             return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
                                        N_("AHCI: Failed to create SUP event semaphore"));
+        rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pAhciPort->hEvtProcessAck);
+        if (RT_FAILURE(rc))
+            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
+                                       N_("AHCI: Failed to create SUP event semaphore"));
 
         /* Create the async IO thread. */
         rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPortR3->pAsyncIOThread, pAhciPortR3, ahciAsyncIOLoop,
@@ -5724,6 +5742,11 @@
                 PDMDevHlpSUPSemEventClose(pDevIns, pAhciPort->hEvtProcess);
                 pAhciPort->hEvtProcess = NIL_SUPSEMEVENT;
             }
+            if (pAhciPort->hEvtProcessAck != NIL_SUPSEMEVENT)
+            {
+                PDMDevHlpSUPSemEventClose(pDevIns, pAhciPort->hEvtProcessAck);
+                pAhciPort->hEvtProcessAck = NIL_SUPSEMEVENT;
+            }
         }
 
         PDMDevHlpCritSectDelete(pDevIns, &pThis->lock);
@@ -5805,6 +5828,7 @@
         pAhciPortR3->pDrvBase           = NULL;
         pAhciPortR3->pAsyncIOThread     = NULL;
         pAhciPort->hEvtProcess          = NIL_SUPSEMEVENT;
+        pAhciPort->hEvtProcessAck       = NIL_SUPSEMEVENT;
         pAhciPort->fHotpluggable        = true;
     }
 
@@ -6009,6 +6033,10 @@
             if (RT_FAILURE(rc))
                 return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
                                            N_("AHCI: Failed to create SUP event semaphore"));
+            rc = PDMDevHlpSUPSemEventCreate(pDevIns, &pAhciPort->hEvtProcessAck);
+            if (RT_FAILURE(rc))
+                return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
+                                           N_("AHCI: Failed to create SUP event semaphore"));
 
             rc = PDMDevHlpThreadCreate(pDevIns, &pAhciPortR3->pAsyncIOThread, pAhciPortR3, ahciAsyncIOLoop,
                                        ahciAsyncIOLoopWakeUp, 0, RTTHREADTYPE_IO, pAhciPortR3->szDesc);
