VirtualBox

Changeset 81752 in vbox for trunk/src/VBox/Devices/Storage


Ignore:
Timestamp:
Nov 9, 2019 10:21:23 AM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
134540
Message:

DevLsiLogicSCSI: Switched critsects and sup semaphores to device helper. Use fixed size buffer for controller type, avoiding the free call. bugref:9218

File:
1 edited

Legend:

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

    r81751 r81752  
    362362    };
    363363
    364     /** The support driver session handle. */
    365     R3R0PTRTYPE(PSUPDRVSESSION)      pSupDrvSession;
    366364    /** Worker thread. */
    367365    R3PTRTYPE(PPDMTHREAD)            pThreadWrk;
     
    643641
    644642    /* Write message context ID into reply post queue. */
    645     rc = PDMCritSectEnter(&pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
     643    rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
    646644    AssertRC(rc);
    647645
     
    651649        /* Set error code. */
    652650        lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    653         PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
     651        PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
    654652        return;
    655653    }
     
    663661    lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    664662
    665     PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
     663    PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
    666664}
    667665
     
    700698        int rc;
    701699        /* Grab a free reply message from the queue. */
    702         rc = PDMCritSectEnter(&pThis->ReplyFreeQueueCritSect, VINF_SUCCESS);
     700        rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueCritSect, VINF_SUCCESS);
    703701        AssertRC(rc);
    704702
     
    708706            /* Set error code. */
    709707            lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    710             PDMCritSectLeave(&pThis->ReplyFreeQueueCritSect);
     708            PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueCritSect);
    711709            return;
    712710        }
     
    717715        pThis->uReplyFreeQueueNextAddressRead %= pThis->cReplyQueueEntries;
    718716
    719         PDMCritSectLeave(&pThis->ReplyFreeQueueCritSect);
     717        PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueCritSect);
    720718
    721719        /* Build 64bit physical address. */
     
    727725
    728726        /* Write low 32bits of reply frame into post reply queue. */
    729         rc = PDMCritSectEnter(&pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
     727        rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect, VINF_SUCCESS);
    730728        AssertRC(rc);
    731729
     
    735733            /* Set error code. */
    736734            lsilogicSetIOCFaultCode(pThis, LSILOGIC_IOCSTATUS_INSUFFICIENT_RESOURCES);
    737             PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
     735            PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
    738736            return;
    739737        }
     
    754752        lsilogicSetInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    755753
    756         PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
     754        PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
    757755# else
    758756        AssertMsgFailed(("This is not allowed to happen.\n"));
     
    12571255        case LSILOGIC_REG_REPLY_QUEUE:
    12581256        {
    1259             int rc = PDMCritSectEnter(&pThis->ReplyFreeQueueWriteCritSect, VINF_IOM_R3_MMIO_WRITE);
     1257            int rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueWriteCritSect, VINF_IOM_R3_MMIO_WRITE);
    12601258            if (rc != VINF_SUCCESS)
    12611259                return rc;
     
    12641262            pThis->uReplyFreeQueueNextEntryFreeWrite++;
    12651263            pThis->uReplyFreeQueueNextEntryFreeWrite %= pThis->cReplyQueueEntries;
    1266             PDMCritSectLeave(&pThis->ReplyFreeQueueWriteCritSect);
     1264            PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyFreeQueueWriteCritSect);
    12671265            break;
    12681266        }
    12691267        case LSILOGIC_REG_REQUEST_QUEUE:
    12701268        {
    1271             int rc = PDMCritSectEnter(&pThis->RequestQueueCritSect, VINF_IOM_R3_MMIO_WRITE);
     1269            int rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->RequestQueueCritSect, VINF_IOM_R3_MMIO_WRITE);
    12721270            if (rc != VINF_SUCCESS)
    12731271                return rc;
     
    12861284            uNextWrite %= pThis->cRequestQueueEntries;
    12871285            ASMAtomicWriteU32(&pThis->uRequestQueueNextEntryFreeWrite, uNextWrite);
    1288             PDMCritSectLeave(&pThis->RequestQueueCritSect);
     1286            PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->RequestQueueCritSect);
    12891287
    12901288            /* Send notification to R3 if there is not one sent already. Do this
     
    12951293                {
    12961294                    LogFlowFunc(("Signal event semaphore\n"));
    1297                     rc = SUPSemEventSignal(pThis->pSupDrvSession, pThis->hEvtProcess);
     1295                    rc = PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
    12981296                    AssertRC(rc);
    12991297                }
     
    15311529        case LSILOGIC_REG_REPLY_QUEUE:
    15321530        {
    1533             rc = PDMCritSectEnter(&pThis->ReplyPostQueueCritSect, VINF_IOM_R3_MMIO_READ);
     1531            rc = PDMDevHlpCritSectEnter(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect, VINF_IOM_R3_MMIO_READ);
    15341532            if (rc != VINF_SUCCESS)
    15351533                break;
     
    15511549                lsilogicClearInterrupt(pThis, LSILOGIC_REG_HOST_INTR_STATUS_REPLY_INTR);
    15521550            }
    1553             PDMCritSectLeave(&pThis->ReplyPostQueueCritSect);
     1551            PDMDevHlpCritSectLeave(pThis->CTX_SUFF(pDevIns), &pThis->ReplyPostQueueCritSect);
    15541552
    15551553            Log(("%s: Returning address %#x\n", __FUNCTION__, u32));
     
    39163914        /* Notify the worker thread that there are pending requests. */
    39173915        LogFlowFunc(("Signal event semaphore\n"));
    3918         rc = SUPSemEventSignal(pThis->pSupDrvSession, pThis->hEvtProcess);
     3916        rc = PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
    39193917        AssertRC(rc);
    39203918    }
     
    39453943        /* Notify the worker thread that there are pending requests. */
    39463944        LogFlowFunc(("Signal event semaphore\n"));
    3947         rc = SUPSemEventSignal(pThis->pSupDrvSession, pThis->hEvtProcess);
     3945        rc = PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
    39483946        AssertRC(rc);
    39493947    }
     
    41984196        {
    41994197            Assert(ASMAtomicReadBool(&pThis->fWrkThreadSleeping));
    4200             rc = SUPSemEventWaitNoResume(pThis->pSupDrvSession, pThis->hEvtProcess, RT_INDEFINITE_WAIT);
     4198            rc = PDMDevHlpSUPSemEventWaitNoResume(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess, RT_INDEFINITE_WAIT);
    42014199            AssertLogRelMsgReturn(RT_SUCCESS(rc) || rc == VERR_INTERRUPTED, ("%Rrc\n", rc), rc);
    42024200            if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING))
     
    43134311    RT_NOREF(pThread);
    43144312    PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    4315     return SUPSemEventSignal(pThis->pSupDrvSession, pThis->hEvtProcess);
     4313    return PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
    43164314}
    43174315
     
    43304328        /* Notify the worker thread that there are pending requests. */
    43314329        LogFlowFunc(("Signal event semaphore\n"));
    4332         int rc = SUPSemEventSignal(pThis->pSupDrvSession, pThis->hEvtProcess);
     4330        int rc = PDMDevHlpSUPSemEventSignal(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
    43334331        AssertRC(rc);
    43344332    }
     
    52245222static DECLCALLBACK(int) lsilogicR3Destruct(PPDMDEVINS pDevIns)
    52255223{
     5224    PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    52265225    PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    5227     PDMDEV_CHECK_VERSIONS_RETURN_QUIET(pDevIns);
    5228 
    5229     PDMR3CritSectDelete(&pThis->ReplyFreeQueueCritSect);
    5230     PDMR3CritSectDelete(&pThis->ReplyPostQueueCritSect);
    5231     PDMR3CritSectDelete(&pThis->RequestQueueCritSect);
    5232     PDMR3CritSectDelete(&pThis->ReplyFreeQueueWriteCritSect);
     5226
     5227    PDMDevHlpCritSectDelete(pDevIns, &pThis->ReplyFreeQueueCritSect);
     5228    PDMDevHlpCritSectDelete(pDevIns, &pThis->ReplyPostQueueCritSect);
     5229    PDMDevHlpCritSectDelete(pDevIns, &pThis->RequestQueueCritSect);
     5230    PDMDevHlpCritSectDelete(pDevIns, &pThis->ReplyFreeQueueWriteCritSect);
    52335231
    52345232    RTMemFree(pThis->paDeviceStates);
     
    52375235    if (pThis->hEvtProcess != NIL_SUPSEMEVENT)
    52385236    {
    5239         SUPSemEventClose(pThis->pSupDrvSession, pThis->hEvtProcess);
     5237        PDMDevHlpSUPSemEventClose(pThis->CTX_SUFF(pDevIns), pThis->hEvtProcess);
    52405238        pThis->hEvtProcess = NIL_SUPSEMEVENT;
    52415239    }
     
    52525250static DECLCALLBACK(int) lsilogicR3Construct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
    52535251{
     5252    PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    52545253    PLSILOGICSCSI pThis = PDMDEVINS_2_DATA(pDevIns, PLSILOGICSCSI);
    52555254    PCPDMDEVHLPR3 pHlp  = pDevIns->pHlpR3;
    52565255    int           rc    = VINF_SUCCESS;
    5257     PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
    52585256
    52595257    /*
     
    53035301    Log(("%s: RequestQueueDepth=%u\n", __FUNCTION__, pThis->cRequestQueueEntries));
    53045302
    5305     char *pszCtrlType;
    5306     rc = pHlp->pfnCFGMQueryStringAllocDef(pCfg, "ControllerType", &pszCtrlType, LSILOGICSCSI_PCI_SPI_CTRLNAME);
     5303    char szCtrlType[64];
     5304    rc = pHlp->pfnCFGMQueryStringDef(pCfg, "ControllerType", szCtrlType, sizeof(szCtrlType), LSILOGICSCSI_PCI_SPI_CTRLNAME);
    53075305    if (RT_FAILURE(rc))
    53085306        return PDMDEV_SET_ERROR(pDevIns, rc,
    53095307                                N_("LsiLogic configuration error: failed to read ControllerType as string"));
    5310     Log(("%s: ControllerType=%s\n", __FUNCTION__, pszCtrlType));
    5311 
    5312     rc = lsilogicR3GetCtrlTypeFromString(pThis, pszCtrlType);
    5313     MMR3HeapFree(pszCtrlType);
     5308    Log(("%s: ControllerType=%s\n", __FUNCTION__, szCtrlType));
     5309    rc = lsilogicR3GetCtrlTypeFromString(pThis, szCtrlType);
     5310    if (RT_FAILURE(rc))
     5311        return PDMDEV_SET_ERROR(pDevIns, rc, N_("LsiLogic configuration error: failed to determine controller type from string"));
    53145312
    53155313    char szDevTag[20];
     
    53175315                pThis->enmCtrlType == LSILOGICCTRLTYPE_SCSI_SPI ? "SPI" : "SAS",
    53185316                iInstance);
    5319 
    5320     if (RT_FAILURE(rc))
    5321         return PDMDEV_SET_ERROR(pDevIns, rc, N_("LsiLogic configuration error: failed to determine controller type from string"));
    53225317
    53235318    rc = pHlp->pfnCFGMQueryU8(pCfg, "NumPorts", &pThis->cPorts);
     
    53755370    pThis->pDevInsR0 = PDMDEVINS_2_R0PTR(pDevIns);
    53765371    pThis->pDevInsRC = PDMDEVINS_2_RCPTR(pDevIns);
    5377     pThis->pSupDrvSession = PDMDevHlpGetSupDrvSession(pDevIns);
    53785372    pThis->IBase.pfnQueryInterface = lsilogicR3StatusQueryInterface;
    53795373    pThis->ILeds.pfnQueryStatusLed = lsilogicR3StatusQueryStatusLed;
     
    54625456        pThis->cDeviceStates = pThis->cPorts * LSILOGICSCSI_PCI_SAS_DEVICES_PER_PORT_MAX;
    54635457    else
    5464         AssertMsgFailed(("Invalid controller type: %d\n", pThis->enmCtrlType));
     5458        AssertLogRelMsgFailedReturn(("Invalid controller type: %d\n", pThis->enmCtrlType), VERR_INTERNAL_ERROR_4);
    54655459
    54665460    /*
     
    54735467                                   N_("LsiLogic: Failed to create worker thread %s"), szDevTag);
    54745468
    5475     rc = SUPSemEventCreate(pThis->pSupDrvSession, &pThis->hEvtProcess);
     5469    rc = PDMDevHlpSUPSemEventCreate(pThis->CTX_SUFF(pDevIns), &pThis->hEvtProcess);
    54765470    if (RT_FAILURE(rc))
    54775471        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
Note: See TracChangeset for help on using the changeset viewer.

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