VirtualBox

Changeset 37467 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Jun 15, 2011 1:08:45 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
72281
Message:

IOM: Clean up locking now that all devices has its own CS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/IOM.cpp

    r37466 r37467  
    149149    AssertCompileMemberAlignment(VM, iom.s, 32);
    150150    AssertCompile(sizeof(pVM->iom.s) <= sizeof(pVM->iom.padding));
    151     AssertCompileMemberAlignment(IOM, EmtLock, sizeof(uintptr_t));
     151    AssertCompileMemberAlignment(IOM, CritSect, sizeof(uintptr_t));
    152152
    153153    /*
     
    159159     * Initialize the REM critical section.
    160160     */
    161     int rc = PDMR3CritSectInit(pVM, &pVM->iom.s.EmtLock, RT_SRC_POS, "IOM Lock");
     161    int rc = PDMR3CritSectInit(pVM, &pVM->iom.s.CritSect, RT_SRC_POS, "IOM Lock");
    162162    AssertRCReturn(rc, rc);
    163163
     
    227227static void iomR3FlushCache(PVM pVM)
    228228{
    229     iomLock(pVM);
     229    IOM_LOCK(pVM);
     230
    230231    /*
    231232     * Caching of port and statistics (saves some time in rep outs/ins instruction emulation)
     
    252253    pVM->iom.s.pMMIOStatsLastRC  = NIL_RTRCPTR;
    253254
    254     iomUnlock(pVM);
     255    IOM_UNLOCK(pVM);
    255256}
    256257
     
    562563         * Try Insert it.
    563564         */
    564         iomLock(pVM);
     565        IOM_LOCK(pVM);
    565566        if (RTAvlroIOPortInsert(&pVM->iom.s.pTreesR3->IOPortTreeR3, &pRange->Core))
    566567        {
    567             #ifdef VBOX_WITH_STATISTICS
     568#ifdef VBOX_WITH_STATISTICS
    568569            for (unsigned iPort = 0; iPort < cPorts; iPort++)
    569570                iomR3IOPortStatsCreate(pVM, PortStart + iPort, pszDesc);
    570             #endif
    571             iomUnlock(pVM);
     571#endif
     572            IOM_UNLOCK(pVM);
    572573            return VINF_SUCCESS;
    573574        }
    574         iomUnlock(pVM);
     575        IOM_UNLOCK(pVM);
    575576
    576577        /* conflict. */
     
    628629    }
    629630
    630     iomLock(pVM);
     631    IOM_LOCK(pVM);
    631632
    632633    /*
     
    640641        {
    641642            AssertMsgFailed(("No R3! Port=#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc));
    642             iomUnlock(pVM);
     643            IOM_UNLOCK(pVM);
    643644            return VERR_IOM_NO_HC_IOPORT_RANGE;
    644645        }
     
    651652        {
    652653            AssertMsgFailed(("Not owner! Port=%#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc));
    653             iomUnlock(pVM);
     654            IOM_UNLOCK(pVM);
    654655            return VERR_IOM_NOT_IOPORT_RANGE_OWNER;
    655656        }
     
    685686        if (RTAvlroIOPortInsert(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeRC, &pRange->Core))
    686687        {
    687             iomUnlock(pVM);
     688            IOM_UNLOCK(pVM);
    688689            return VINF_SUCCESS;
    689690        }
     
    694695        rc = VERR_IOM_IOPORT_RANGE_CONFLICT;
    695696    }
    696     iomUnlock(pVM);
     697    IOM_UNLOCK(pVM);
    697698    return rc;
    698699}
     
    743744    }
    744745
    745     iomLock(pVM);
     746    IOM_LOCK(pVM);
    746747    /*
    747748     * Validate that there are ring-3 ranges for the ports.
     
    754755        {
    755756            AssertMsgFailed(("No R3! Port=#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc));
    756             iomUnlock(pVM);
     757            IOM_UNLOCK(pVM);
    757758            return VERR_IOM_NO_HC_IOPORT_RANGE;
    758759        }
     
    765766        {
    766767            AssertMsgFailed(("Not owner! Port=%#x %#x-%#x! (%s)\n", Port, PortStart, (unsigned)PortStart + cPorts - 1, pszDesc));
    767             iomUnlock(pVM);
     768            IOM_UNLOCK(pVM);
    768769            return VERR_IOM_NOT_IOPORT_RANGE_OWNER;
    769770        }
     
    799800        if (RTAvlroIOPortInsert(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeR0, &pRange->Core))
    800801        {
    801             iomUnlock(pVM);
     802            IOM_UNLOCK(pVM);
    802803            return VINF_SUCCESS;
    803804        }
     
    808809        rc = VERR_IOM_IOPORT_RANGE_CONFLICT;
    809810    }
    810     iomUnlock(pVM);
     811    IOM_UNLOCK(pVM);
    811812    return rc;
    812813}
     
    846847    }
    847848
    848     iomLock(pVM);
     849    IOM_LOCK(pVM);
    849850
    850851    /* Flush the IO port lookup cache */
     
    867868                AssertMsgFailed(("Removal of ports in range %#x-%#x rejected because not owner of %#x-%#x (%s)\n",
    868869                                 PortStart, PortLast, pRange->Core.Key, pRange->Core.KeyLast, pRange->pszDesc));
    869                 iomUnlock(pVM);
     870                IOM_UNLOCK(pVM);
    870871                return VERR_IOM_NOT_IOPORT_RANGE_OWNER;
    871872            }
     
    931932                if (RT_FAILURE(rc2))
    932933                {
    933                     iomUnlock(pVM);
     934                    IOM_UNLOCK(pVM);
    934935                    return rc2;
    935936                }
     
    10141015                if (RT_FAILURE(rc2))
    10151016                {
    1016                     iomUnlock(pVM);
     1017                    IOM_UNLOCK(pVM);
    10171018                    return rc2;
    10181019                }
     
    10961097                if (RT_FAILURE(rc2))
    10971098                {
    1098                     iomUnlock(pVM);
     1099                    IOM_UNLOCK(pVM);
    10991100                    return rc2;
    11001101                }
     
    11251126
    11261127    /* done */
    1127     iomUnlock(pVM);
     1128    IOM_UNLOCK(pVM);
    11281129    return rc;
    11291130}
     
    14711472         * Try register it with PGM and then insert it into the tree.
    14721473         */
    1473         iomLock(pVM);
     1474        IOM_LOCK(pVM);
    14741475        iomR3FlushCache(pVM);
    14751476        rc = PGMR3PhysMMIORegister(pVM, GCPhysStart, cbRange,
     
    14811482            if (RTAvlroGCPhysInsert(&pVM->iom.s.pTreesR3->MMIOTree, &pRange->Core))
    14821483            {
    1483                 iomUnlock(pVM);
     1484                IOM_UNLOCK(pVM);
    14841485                return VINF_SUCCESS;
    14851486            }
    14861487
    14871488            /* bail out */
    1488             iomUnlock(pVM);
     1489            IOM_UNLOCK(pVM);
    14891490            DBGFR3Info(pVM, "mmio", NULL, NULL);
    14901491            AssertMsgFailed(("This cannot happen!\n"));
     
    14921493        }
    14931494        else
    1494             iomUnlock(pVM);
     1495            IOM_UNLOCK(pVM);
    14951496
    14961497        MMHyperFree(pVM, pRange);
     
    15401541     * Find the MMIO range and check that the input matches.
    15411542     */
    1542     iomLock(pVM);
     1543    IOM_LOCK(pVM);
    15431544    PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhysStart);
    1544     AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);
    1545     AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);
    1546     AssertReturnStmt(pRange->GCPhys == GCPhysStart, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);
    1547     AssertReturnStmt(pRange->cb == cbRange, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);
     1545    AssertReturnStmt(pRange, IOM_UNLOCK(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     1546    AssertReturnStmt(pRange->pDevInsR3 == pDevIns, IOM_UNLOCK(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);
     1547    AssertReturnStmt(pRange->GCPhys == GCPhysStart, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE);
     1548    AssertReturnStmt(pRange->cb == cbRange, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE);
    15481549
    15491550    pRange->pvUserRC          = pvUser;
     
    15521553    pRange->pfnFillCallbackRC = pfnFillCallback;
    15531554    pRange->pDevInsRC         = MMHyperCCToRC(pVM, pDevIns);
    1554     iomUnlock(pVM);
     1555    IOM_UNLOCK(pVM);
    15551556
    15561557    return VINF_SUCCESS;
     
    15971598     * Find the MMIO range and check that the input matches.
    15981599     */
    1599     iomLock(pVM);
     1600    IOM_LOCK(pVM);
    16001601    PIOMMMIORANGE pRange = iomMmioGetRange(pVM, GCPhysStart);
    1601     AssertReturnStmt(pRange, iomUnlock(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);
    1602     AssertReturnStmt(pRange->pDevInsR3 == pDevIns, iomUnlock(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);
    1603     AssertReturnStmt(pRange->GCPhys == GCPhysStart, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);
    1604     AssertReturnStmt(pRange->cb == cbRange, iomUnlock(pVM), VERR_IOM_INVALID_MMIO_RANGE);
     1602    AssertReturnStmt(pRange, IOM_UNLOCK(pVM), VERR_IOM_MMIO_RANGE_NOT_FOUND);
     1603    AssertReturnStmt(pRange->pDevInsR3 == pDevIns, IOM_UNLOCK(pVM), VERR_IOM_NOT_MMIO_RANGE_OWNER);
     1604    AssertReturnStmt(pRange->GCPhys == GCPhysStart, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE);
     1605    AssertReturnStmt(pRange->cb == cbRange, IOM_UNLOCK(pVM), VERR_IOM_INVALID_MMIO_RANGE);
    16051606
    16061607    pRange->pvUserR0          = pvUser;
     
    16091610    pRange->pfnFillCallbackR0 = pfnFillCallback;
    16101611    pRange->pDevInsR0         = MMHyperCCToR0(pVM, pDevIns);
    1611     iomUnlock(pVM);
     1612    IOM_UNLOCK(pVM);
    16121613
    16131614    return VINF_SUCCESS;
     
    16441645    }
    16451646
    1646     iomLock(pVM);
     1647    IOM_LOCK(pVM);
    16471648
    16481649    /*
     
    16551656        if (!pRange)
    16561657        {
    1657             iomUnlock(pVM);
     1658            IOM_UNLOCK(pVM);
    16581659            return VERR_IOM_MMIO_RANGE_NOT_FOUND;
    16591660        }
    16601661        AssertMsgReturnStmt(pRange->pDevInsR3 == pDevIns,
    16611662                            ("Not owner! GCPhys=%RGp %RGp LB%#x %s\n", GCPhys, GCPhysStart, cbRange, pRange->pszDesc),
    1662                             iomUnlock(pVM),
     1663                            IOM_UNLOCK(pVM),
    16631664                            VERR_IOM_NOT_MMIO_RANGE_OWNER);
    16641665        AssertMsgReturnStmt(pRange->Core.KeyLast <= GCPhysLast,
    16651666                            ("Incomplete R3 range! GCPhys=%RGp %RGp LB%#x %s\n", GCPhys, GCPhysStart, cbRange, pRange->pszDesc),
    1666                             iomUnlock(pVM),
     1667                            IOM_UNLOCK(pVM),
    16671668                            VERR_IOM_INCOMPLETE_MMIO_RANGE);
    16681669
     
    16831684        Assert(pRange);
    16841685        Assert(pRange->Core.Key == GCPhys && pRange->Core.KeyLast <= GCPhysLast);
    1685         iomUnlock(pVM); /** @todo r=bird: Why are we leving the lock here? We don't leave it when registering the range above... */
     1686        IOM_UNLOCK(pVM); /** @todo r=bird: Why are we leaving the lock here? We don't leave it when registering the range above... */
    16861687
    16871688        /* remove it from PGM */
     
    16891690        AssertRC(rc);
    16901691
    1691         iomLock(pVM);
     1692        IOM_LOCK(pVM);
    16921693
    16931694        /* advance and free. */
     
    17011702    }
    17021703
    1703     iomUnlock(pVM);
     1704    IOM_UNLOCK(pVM);
    17041705    return VINF_SUCCESS;
    17051706}
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