- Timestamp:
- Jul 14, 2014 9:43:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r51638 r52026 5431 5431 * 5432 5432 * @returns Pointer to the memory or NULL on failure 5433 * @param pAhciPort The AHCI port. 5433 5434 * @param pAhciReq The request to allocate memory for. 5434 5435 * @param cb The amount of memory to allocate. 5435 5436 */ 5436 static void *ahciReqMemAlloc(PAHCI REQ pAhciReq, size_t cb)5437 static void *ahciReqMemAlloc(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, size_t cb) 5437 5438 { 5438 5439 if (pAhciReq->cbAlloc > cb) … … 5443 5444 { 5444 5445 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; 5447 5449 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 5449 5454 pAhciReq->cAllocTooMuch = 0; 5450 5455 if (RT_UNLIKELY(!pAhciReq->pvAlloc)) … … 5459 5464 * 5460 5465 * @returns nothing. 5466 * @param pAhciPort The AHCI port. 5461 5467 * @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 */ 5470 static 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 } 5470 5481 } 5471 5482 } … … 5581 5592 * 5582 5593 * @returns VBox status code. 5583 * @param p DevIns The device instance.5594 * @param pAhciPort The AHCI port. 5584 5595 * @param pAhciReq The request state. 5585 5596 * @param cbTransfer Amount of bytes to allocate. 5586 5597 */ 5587 static int ahciIoBufAllocate(P PDMDEVINS pDevIns, PAHCIREQ pAhciReq, size_t cbTransfer)5598 static int ahciIoBufAllocate(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, size_t cbTransfer) 5588 5599 { 5589 5600 AssertMsg( pAhciReq->enmTxDir == AHCITXDIR_READ … … 5591 5602 ("Allocating I/O memory for a non I/O request is not allowed\n")); 5592 5603 5593 pAhciReq->u.Io.DataSeg.pvSeg = ahciReqMemAlloc(pAhci Req, cbTransfer);5604 pAhciReq->u.Io.DataSeg.pvSeg = ahciReqMemAlloc(pAhciPort, pAhciReq, cbTransfer); 5594 5605 if (!pAhciReq->u.Io.DataSeg.pvSeg) 5595 5606 return VERR_NO_MEMORY; … … 5598 5609 if (pAhciReq->enmTxDir == AHCITXDIR_WRITE) 5599 5610 { 5600 ahciCopyFromPrdtl(p DevIns, pAhciReq,5611 ahciCopyFromPrdtl(pAhciPort->pDevInsR3, pAhciReq, 5601 5612 pAhciReq->u.Io.DataSeg.pvSeg, 5602 5613 cbTransfer); … … 5609 5620 * 5610 5621 * @returns nothing. 5611 * @param p DevIns The device instance.5622 * @param pAhciPort The AHCI port. 5612 5623 * @param pAhciReq The request state. 5613 5624 * @param fCopyToGuest Flag whether to update the guest buffer if necessary. 5614 5625 * Nothing is copied if false even if the request was a read. 5615 5626 */ 5616 static void ahciIoBufFree(P PDMDEVINS pDevIns, PAHCIREQ pAhciReq,5627 static void ahciIoBufFree(PAHCIPort pAhciPort, PAHCIREQ pAhciReq, 5617 5628 bool fCopyToGuest) 5618 5629 { … … 5632 5643 if (RT_SUCCESS(rc)) 5633 5644 { 5634 pAhciReq->cbTransfer = ahciCopyToPrdtl(p DevIns, pAhciReq, pv, cb);5645 pAhciReq->cbTransfer = ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, pv, cb); 5635 5646 RTMemFree(pv); 5636 5647 } 5637 5648 } 5638 5649 else 5639 ahciCopyToPrdtl(p DevIns, pAhciReq,5650 ahciCopyToPrdtl(pAhciPort->pDevInsR3, pAhciReq, 5640 5651 pAhciReq->u.Io.DataSeg.pvSeg, 5641 5652 pAhciReq->u.Io.DataSeg.cbSeg); 5642 5653 } 5643 5654 5644 ahciReqMemFree(pAhci Req);5655 ahciReqMemFree(pAhciPort, pAhciReq, false /* fForceFree */); 5645 5656 pAhciReq->u.Io.DataSeg.pvSeg = NULL; 5646 5657 pAhciReq->u.Io.DataSeg.cbSeg = 0; … … 5956 5967 if (pAhciReq->enmTxDir == AHCITXDIR_READ) 5957 5968 { 5958 ahciIoBufFree(pAhciPort ->pDevInsR3, pAhciReq, true /* fCopyToGuest */);5969 ahciIoBufFree(pAhciPort, pAhciReq, true /* fCopyToGuest */); 5959 5970 STAM_REL_COUNTER_ADD(&pAhciPort->StatBytesRead, pAhciReq->cbTransfer); 5960 5971 pAhciPort->Led.Actual.s.fReading = 0; … … 5962 5973 else if (pAhciReq->enmTxDir == AHCITXDIR_WRITE) 5963 5974 { 5964 ahciIoBufFree(pAhciPort ->pDevInsR3, pAhciReq, false /* fCopyToGuest */);5975 ahciIoBufFree(pAhciPort, pAhciReq, false /* fCopyToGuest */); 5965 5976 STAM_REL_COUNTER_ADD(&pAhciPort->StatBytesWritten, pAhciReq->cbTransfer); 5966 5977 pAhciPort->Led.Actual.s.fWriting = 0; … … 6077 6088 ahciTrimRangesDestroy(pAhciReq); 6078 6089 else if (pAhciReq->enmTxDir != AHCITXDIR_FLUSH) 6079 ahciIoBufFree(pAhciPort ->pDevInsR3, pAhciReq, false /* fCopyToGuest */);6090 ahciIoBufFree(pAhciPort, pAhciReq, false /* fCopyToGuest */); 6080 6091 6081 6092 /* Leave a log message about the canceled request. */ … … 6368 6379 ahciTrimRangesDestroy(pTaskErr); 6369 6380 else if (pTaskErr->enmTxDir != AHCITXDIR_FLUSH) 6370 ahciIoBufFree(pAhciPort ->pDevInsR3, pTaskErr, false /* fCopyToGuest */);6381 ahciIoBufFree(pAhciPort, pTaskErr, false /* fCopyToGuest */); 6371 6382 6372 6383 /* Finally free the error task state structure because it is completely unused now. */ … … 6699 6710 STAM_REL_COUNTER_INC(&pAhciPort->StatDMA); 6700 6711 6701 rc = ahciIoBufAllocate(pAhciPort ->pDevInsR3, pAhciReq, pAhciReq->cbTransfer);6712 rc = ahciIoBufAllocate(pAhciPort, pAhciReq, pAhciReq->cbTransfer); 6702 6713 if (RT_FAILURE(rc)) 6703 6714 AssertMsgFailed(("%s: Failed to process command %Rrc\n", __FUNCTION__, rc)); … … 8049 8060 if (pAhciPort->aCachedTasks[i]) 8050 8061 { 8062 ahciReqMemFree(pAhciPort, pAhciPort->aCachedTasks[i], true /* fForceFree */); 8051 8063 RTMemFree(pAhciPort->aCachedTasks[i]); 8052 8064 pAhciPort->aCachedTasks[i] = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.