vmwlegacy: Fix device fifo communication

This fixes two issues with the device fifo communication:
1) Idle the fifo before initializing it. If the fifo is already up and
processing data due to an uncleanly shut down server, and init could
otherwise confuse the device.

2) Mark fifo memory volatile when writing to it and make sure commands
are written before telling the device they are available.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
This commit is contained in:
Thomas Hellstrom
2011-11-16 10:23:10 +01:00
parent 4c08c26009
commit be23efbc91

View File

@@ -299,7 +299,7 @@ vmwareWriteReg(VMWAREPtr pVMWARE, int index, CARD32 value)
void
vmwareWriteWordToFIFO(VMWAREPtr pVMWARE, CARD32 value)
{
CARD32* vmwareFIFO = pVMWARE->vmwareFIFO;
volatile CARD32* vmwareFIFO = pVMWARE->vmwareFIFO;
/* Need to sync? */
if ((vmwareFIFO[SVGA_FIFO_NEXT_CMD] + sizeof(CARD32) == vmwareFIFO[SVGA_FIFO_STOP])
@@ -310,6 +310,9 @@ vmwareWriteWordToFIFO(VMWAREPtr pVMWARE, CARD32 value)
}
vmwareFIFO[vmwareFIFO[SVGA_FIFO_NEXT_CMD] / sizeof(CARD32)] = value;
write_mem_barrier();
if(vmwareFIFO[SVGA_FIFO_NEXT_CMD] == vmwareFIFO[SVGA_FIFO_MAX] -
sizeof(CARD32)) {
vmwareFIFO[SVGA_FIFO_NEXT_CMD] = vmwareFIFO[SVGA_FIFO_MIN];
@@ -1342,7 +1345,7 @@ VMWAREInitFIFO(ScrnInfoPtr pScrn)
int err;
void *mmioVirtBase;
#endif
CARD32* vmwareFIFO;
volatile CARD32* vmwareFIFO;
Bool extendedFifo;
int min;
@@ -1373,6 +1376,9 @@ VMWAREInitFIFO(ScrnInfoPtr pScrn)
extendedFifo = pVMWARE->vmwareCapability & SVGA_CAP_EXTENDED_FIFO;
min = extendedFifo ? vmwareReadReg(pVMWARE, SVGA_REG_MEM_REGS) : 4;
vmwareWaitForFB(pVMWARE);
vmwareWriteReg(pVMWARE, SVGA_REG_CONFIG_DONE, 0);
vmwareFIFO[SVGA_FIFO_MIN] = min * sizeof(CARD32);
vmwareFIFO[SVGA_FIFO_MAX] = pVMWARE->mmioSize;
vmwareFIFO[SVGA_FIFO_NEXT_CMD] = min * sizeof(CARD32);