From be23efbc91f47a6a34fbe24f167ee29fdf58f541 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 16 Nov 2011 10:23:10 +0100 Subject: 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 Reviewed-by: Jakob Bornecrantz --- src/vmware.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vmware.c b/src/vmware.c index 55bde22..fa01dca 100644 --- a/src/vmware.c +++ b/src/vmware.c @@ -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); -- cgit v1.2.3