VirtualBox

Changeset 52026 in vbox for trunk/src


Ignore:
Timestamp:
Jul 14, 2014 9:43:00 PM (11 years ago)
Author:
vboxsync
Message:

Storage/AHCI: Switch to PDMIBLOCK I/O buffer allocator callbacks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/DevAHCI.cpp

    r51638 r52026  
    54315431 *
    54325432 * @returns Pointer to the memory or NULL on failure
     5433 * @param   pAhciPort   The AHCI port.
    54335434 * @param   pAhciReq    The request to allocate memory for.
    54345435 * @param   cb          The amount of memory to allocate.
    54355436 */
    5436 static void *ahciReqMemAlloc(PAHCIREQ pAhciReq, size_t cb)
     5437static void *ahciReqMemAlloc(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, size_t cb)
    54375438{
    54385439    if (pAhciReq->cbAlloc > cb)
     
    54435444    {
    54445445        if (pAhciReq->cbAlloc)
    5445             RTMemPageFree(pAhciReq->pvAlloc, pAhciReq->cbAlloc);
    5446 
     5446            pAhciPort->pDrvBlock->pfnIoBufFree(pAhciPort->pDrvBlock, pAhciReq->pvAlloc, pAhciReq->cbAlloc);
     5447
     5448        pAhciReq->pvAlloc = NULL;
    54475449        pAhciReq->cbAlloc = RT_ALIGN_Z(cb, _4K);
    5448         pAhciReq->pvAlloc = RTMemPageAlloc(pAhciReq->cbAlloc);
     5450        int rc = pAhciPort->pDrvBlock->pfnIoBufAlloc(pAhciPort->pDrvBlock, pAhciReq->cbAlloc, &pAhciReq->pvAlloc);
     5451        if (RT_FAILURE(rc))
     5452            pAhciReq->pvAlloc = NULL;
     5453
    54495454        pAhciReq->cAllocTooMuch = 0;
    54505455        if (RT_UNLIKELY(!pAhciReq->pvAlloc))
     
    54595464 *
    54605465 * @returns nothing.
     5466 * @param   pAhciPort   The AHCI port.
    54615467 * @param   pAhciReq    The request.
    5462  */
    5463 static void ahciReqMemFree(PAHCIREQ pAhciReq)
    5464 {
    5465     if (pAhciReq->cAllocTooMuch >= AHCI_MAX_ALLOC_TOO_MUCH)
    5466     {
    5467         RTMemPageFree(pAhciReq->pvAlloc, pAhciReq->cbAlloc);
    5468         pAhciReq->cbAlloc = 0;
    5469         pAhciReq->cAllocTooMuch = 0;
     5468 * @param   fForceFree  Flag whether to force a free
     5469 */
     5470static void ahciReqMemFree(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, bool fForceFree)
     5471{
     5472    if (   pAhciReq->cAllocTooMuch >= AHCI_MAX_ALLOC_TOO_MUCH
     5473        || fForceFree)
     5474    {
     5475        if (pAhciReq->cbAlloc)
     5476        {
     5477            pAhciPort->pDrvBlock->pfnIoBufFree(pAhciPort->pDrvBlock, pAhciReq->pvAlloc, pAhciReq->cbAlloc);
     5478            pAhciReq->cbAlloc = 0;
     5479            pAhciReq->cAllocTooMuch = 0;
     5480        }
    54705481    }
    54715482}
     
    55815592 *
    55825593 * @returns VBox status code.
    5583  * @param   pDevIns     The device instance.
     5594 * @param   pAhciPort   The AHCI port.
    55845595 * @param   pAhciReq    The request state.
    55855596 * @param   cbTransfer  Amount of bytes to allocate.
    55865597 */
    5587 static int ahciIoBufAllocate(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq, size_t cbTransfer)
     5598static int ahciIoBufAllocate(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, size_t cbTransfer)
    55885599{
    55895600    AssertMsg(   pAhciReq->enmTxDir == AHCITXDIR_READ
     
    55915602              ("Allocating I/O memory for a non I/O request is not allowed\n"));
    55925603
    5593     pAhciReq->u.Io.DataSeg.pvSeg = ahciReqMemAlloc(pAhciReq, cbTransfer);
     5604    pAhciReq->u.Io.DataSeg.pvSeg = ahciReqMemAlloc(pAhciPort, pAhciReq, cbTransfer);
    55945605    if (!pAhciReq->u.Io.DataSeg.pvSeg)
    55955606        return VERR_NO_MEMORY;
     
    55985609    if (pAhciReq->enmTxDir == AHCITXDIR_WRITE)
    55995610    {
    5600         ahciCopyFromPrdtl(pDevIns, pAhciReq,
     5611        ahciCopyFromPrdtl(pAhciPort->pDevInsR3, pAhciReq,
    56015612                          pAhciReq->u.Io.DataSeg.pvSeg,
    56025613                          cbTransfer);
     
    56095620 *
    56105621 * @returns nothing.
    5611  * @param   pDevIns      The device instance.
     5622 * @param   pAhciPort    The AHCI port.
    56125623 * @param   pAhciReq     The request state.
    56135624 * @param   fCopyToGuest Flag whether to update the guest buffer if necessary.
    56145625 *                       Nothing is copied if false even if the request was a read.
    56155626 */
    5616 static void ahciIoBufFree(PPDMDEVINS pDevIns, PAHCIREQ pAhciReq,
     5627static void ahciIoBufFree(PAHCIPort pAhciPort, PAHCIREQ pAhciReq,
    56175628                          bool fCopyToGuest)
    56185629{
     
    56325643            if (RT_SUCCESS(rc))
    56335644            {
    5634                 pAhciReq->cbTransfer = ahciCopyToPrdtl(pDevIns, pAhciReq, pv, cb);
     5645                pAhciReq->cbTransfer = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, pv, cb);
    56355646                RTMemFree(pv);
    56365647            }
    56375648        }
    56385649        else
    5639             ahciCopyToPrdtl(pDevIns, pAhciReq,
     5650            ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq,
    56405651                            pAhciReq->u.Io.DataSeg.pvSeg,
    56415652                            pAhciReq->u.Io.DataSeg.cbSeg);
    56425653    }
    56435654
    5644     ahciReqMemFree(pAhciReq);
     5655    ahciReqMemFree(pAhciPort, pAhciReq, false /* fForceFree */);
    56455656    pAhciReq->u.Io.DataSeg.pvSeg = NULL;
    56465657    pAhciReq->u.Io.DataSeg.cbSeg = 0;
     
    59565967        if (pAhciReq->enmTxDir == AHCITXDIR_READ)
    59575968        {
    5958             ahciIoBufFree(pAhciPort->pDevInsR3, pAhciReq, true /* fCopyToGuest */);
     5969            ahciIoBufFree(pAhciPort, pAhciReq, true /* fCopyToGuest */);
    59595970            STAM_REL_COUNTER_ADD(&pAhciPort->StatBytesRead, pAhciReq->cbTransfer);
    59605971            pAhciPort->Led.Actual.s.fReading = 0;
     
    59625973        else if (pAhciReq->enmTxDir == AHCITXDIR_WRITE)
    59635974        {
    5964             ahciIoBufFree(pAhciPort->pDevInsR3, pAhciReq, false /* fCopyToGuest */);
     5975            ahciIoBufFree(pAhciPort, pAhciReq, false /* fCopyToGuest */);
    59655976            STAM_REL_COUNTER_ADD(&pAhciPort->StatBytesWritten, pAhciReq->cbTransfer);
    59665977            pAhciPort->Led.Actual.s.fWriting = 0;
     
    60776088            ahciTrimRangesDestroy(pAhciReq);
    60786089        else if (pAhciReq->enmTxDir != AHCITXDIR_FLUSH)
    6079             ahciIoBufFree(pAhciPort->pDevInsR3, pAhciReq, false /* fCopyToGuest */);
     6090            ahciIoBufFree(pAhciPort, pAhciReq, false /* fCopyToGuest */);
    60806091
    60816092        /* Leave a log message about the canceled request. */
     
    63686379                                ahciTrimRangesDestroy(pTaskErr);
    63696380                            else if (pTaskErr->enmTxDir != AHCITXDIR_FLUSH)
    6370                                 ahciIoBufFree(pAhciPort->pDevInsR3, pTaskErr, false /* fCopyToGuest */);
     6381                                ahciIoBufFree(pAhciPort, pTaskErr, false /* fCopyToGuest */);
    63716382
    63726383                            /* Finally free the error task state structure because it is completely unused now. */
     
    66996710                        STAM_REL_COUNTER_INC(&pAhciPort->StatDMA);
    67006711
    6701                         rc = ahciIoBufAllocate(pAhciPort->pDevInsR3, pAhciReq, pAhciReq->cbTransfer);
     6712                        rc = ahciIoBufAllocate(pAhciPort, pAhciReq, pAhciReq->cbTransfer);
    67026713                        if (RT_FAILURE(rc))
    67036714                            AssertMsgFailed(("%s: Failed to process command %Rrc\n", __FUNCTION__, rc));
     
    80498060                if (pAhciPort->aCachedTasks[i])
    80508061                {
     8062                    ahciReqMemFree(pAhciPort, pAhciPort->aCachedTasks[i], true /* fForceFree */);
    80518063                    RTMemFree(pAhciPort->aCachedTasks[i]);
    80528064                    pAhciPort->aCachedTasks[i] = NULL;
Note: See TracChangeset for help on using the changeset viewer.

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