From 611e93a5f2f0b78cb53166dd57f10beee783b1c5 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Fri, 18 Jun 2021 13:32:03 +0200 Subject: [PATCH] vbox6: kick AHCI asynchronous IO thread Issue #4031 --- repos/ports/ports/virtualbox6.hash | 2 +- .../src/virtualbox6/patches/devahci.patch | 111 ++++++++++++++++++ repos/ports/src/virtualbox6/patches/series | 1 + 3 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 repos/ports/src/virtualbox6/patches/devahci.patch diff --git a/repos/ports/ports/virtualbox6.hash b/repos/ports/ports/virtualbox6.hash index a5705bfd12..2970b56ad2 100644 --- a/repos/ports/ports/virtualbox6.hash +++ b/repos/ports/ports/virtualbox6.hash @@ -1 +1 @@ -3d6230564eddb5ab205780c7b31acdc169702e0f +54c91c57163a91b6e4f991d3c25e8624899e9eac diff --git a/repos/ports/src/virtualbox6/patches/devahci.patch b/repos/ports/src/virtualbox6/patches/devahci.patch new file mode 100644 index 0000000000..ace9410e37 --- /dev/null +++ b/repos/ports/src/virtualbox6/patches/devahci.patch @@ -0,0 +1,111 @@ +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); diff --git a/repos/ports/src/virtualbox6/patches/series b/repos/ports/src/virtualbox6/patches/series index 2fec67e0db..1d485a3d0d 100644 --- a/repos/ports/src/virtualbox6/patches/series +++ b/repos/ports/src/virtualbox6/patches/series @@ -3,3 +3,4 @@ drvtap.patch qemu-xhci.patch narrowing.patch network.patch +devahci.patch