VirtualBox

Changeset 49434 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 11, 2013 11:09:01 AM (11 years ago)
Author:
vboxsync
Message:

VHWA: smp guests syncronization

Location:
trunk/src/VBox/Devices/Graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA.h

    r49420 r49434  
    434434
    435435    struct {
    436         uint32_t cPending;
     436        volatile uint32_t cPending;
    437437        uint32_t Padding1;
    438438        union
  • trunk/src/VBox/Devices/Graphics/DevVGA_VBVA.cpp

    r49427 r49434  
    813813static void vbvaVHWACommandCompleteAllPending(PVGASTATE pVGAState, int rc)
    814814{
    815     if (!pVGAState->pendingVhwaCommands.cPending)
     815    if (!ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending))
    816816        return;
    817817
    818818    VBOX_VHWA_PENDINGCMD *pIter, *pNext;
     819
     820    PDMCritSectEnter(&pVGAState->lock, VERR_SEM_BUSY);
     821
    819822    RTListForEachSafe(&pVGAState->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
    820823    {
     
    824827        /* the command is submitted/processed, remove from the pend list */
    825828        RTListNodeRemove(&pIter->Node);
    826         --pVGAState->pendingVhwaCommands.cPending;
     829        ASMAtomicDecU32(&pVGAState->pendingVhwaCommands.cPending);
    827830        RTMemFree(pIter);
    828831    }
    829 }
    830 
    831 static void vbvaVHWACommandCClearAllPending(PVGASTATE pVGAState)
    832 {
    833     if (!pVGAState->pendingVhwaCommands.cPending)
     832
     833    PDMCritSectLeave(&pVGAState->lock);
     834}
     835
     836static void vbvaVHWACommandClearAllPending(PVGASTATE pVGAState)
     837{
     838    if (!ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending))
    834839        return;
    835840
    836841    VBOX_VHWA_PENDINGCMD *pIter, *pNext;
     842
     843    PDMCritSectEnter(&pVGAState->lock, VERR_SEM_BUSY);
     844
    837845    RTListForEachSafe(&pVGAState->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
    838846    {
    839847        RTListNodeRemove(&pIter->Node);
    840         --pVGAState->pendingVhwaCommands.cPending;
     848        ASMAtomicDecU32(&pVGAState->pendingVhwaCommands.cPending);
    841849        RTMemFree(pIter);
    842850    }
     851
     852    PDMCritSectLeave(&pVGAState->lock);
    843853}
    844854
     
    847857    int rc = VERR_BUFFER_OVERFLOW;
    848858
    849     if (pVGAState->pendingVhwaCommands.cPending < VBOX_VHWA_MAX_PENDING_COMMANDS)
     859    if (ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending) < VBOX_VHWA_MAX_PENDING_COMMANDS)
    850860    {
    851861        VBOX_VHWA_PENDINGCMD *pPend = (VBOX_VHWA_PENDINGCMD*)RTMemAlloc(sizeof (*pPend));
     
    854864            pCommand->Flags |= VBOXVHWACMD_FLAG_HG_ASYNCH;
    855865            pPend->pCommand = pCommand;
    856             RTListAppend(&pVGAState->pendingVhwaCommands.PendingList, &pPend->Node);
    857             ++pVGAState->pendingVhwaCommands.cPending;
    858             return;
     866            PDMCritSectEnter(&pVGAState->lock, VERR_SEM_BUSY);
     867            if (ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending) < VBOX_VHWA_MAX_PENDING_COMMANDS)
     868            {
     869                RTListAppend(&pVGAState->pendingVhwaCommands.PendingList, &pPend->Node);
     870                ASMAtomicIncU32(&pVGAState->pendingVhwaCommands.cPending);
     871                PDMCritSectLeave(&pVGAState->lock);
     872                return;
     873            }
     874            PDMCritSectLeave(&pVGAState->lock);
     875            LogRel(("Pending command count has reached its threshold.. completing them all.."));
     876            RTMemFree(pPend);
    859877        }
    860878        else
     
    862880    }
    863881    else
    864     {
    865882        LogRel(("Pending command count has reached its threshold, completing them all.."));
    866     }
    867883
    868884    vbvaVHWACommandCompleteAllPending(pVGAState, rc);
     
    973989static bool vbvaVHWACheckPendingCommands(PVGASTATE pVGAState)
    974990{
    975     if (!pVGAState->pendingVhwaCommands.cPending)
     991    if (!ASMAtomicUoReadU32(&pVGAState->pendingVhwaCommands.cPending))
    976992        return true;
    977993
    978994    VBOX_VHWA_PENDINGCMD *pIter, *pNext;
     995
     996    PDMCritSectEnter(&pVGAState->lock, VERR_SEM_BUSY);
     997
    979998    RTListForEachSafe(&pVGAState->pendingVhwaCommands.PendingList, pIter, pNext, VBOX_VHWA_PENDINGCMD, Node)
    980999    {
    9811000        if (!vbvaVHWACommandSubmit(pVGAState, pIter->pCommand, true))
     1001        {
     1002            PDMCritSectLeave(&pVGAState->lock);
    9821003            return false; /* the command should be pended still */
     1004        }
    9831005
    9841006        /* the command is submitted/processed, remove from the pend list */
    9851007        RTListNodeRemove(&pIter->Node);
    986         --pVGAState->pendingVhwaCommands.cPending;
     1008        ASMAtomicDecU32(&pVGAState->pendingVhwaCommands.cPending);
    9871009        RTMemFree(pIter);
    9881010    }
     1011
     1012    PDMCritSectLeave(&pVGAState->lock);
    9891013
    9901014    return true;
     
    10451069    pVGAState->pendingVhwaCommands.cPending = 0;
    10461070    RTListInit(&pVGAState->pendingVhwaCommands.PendingList);
     1071
    10471072    VBOXVHWACMD *pCmd = vbvaVHWAHHCommandCreate(pVGAState, VBOXVHWACMD_TYPE_HH_CONSTRUCT, 0, sizeof(VBOXVHWACMD_HH_CONSTRUCT));
    10481073    Assert(pCmd);
     
    10981123int vbvaVHWAReset (PVGASTATE pVGAState)
    10991124{
    1100     vbvaVHWACommandCClearAllPending(pVGAState);
     1125    vbvaVHWACommandClearAllPending(pVGAState);
    11011126
    11021127    /* ensure we have all pending cmds processed and h->g cmds disabled */
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