From 404251dd0f5001c68f2c0b3d7b84530f3e1b5a40 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 13 Sep 2010 16:59:04 +0200 Subject: Protect all references to cmd_ring with cmd_sem --- display/res.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/display/res.c b/display/res.c index 5dc72c5..a31832d 100644 --- a/display/res.c +++ b/display/res.c @@ -78,12 +78,10 @@ static BOOL SetClip(PDev *pdev, CLIPOBJ *clip, QXLDrawable *drawable); #define PUSH_CMD(pdev) do { \ int notify; \ - EngAcquireSemaphore(pdev->Res->cmd_sem); \ SPICE_RING_PUSH(pdev->cmd_ring, notify); \ if (notify) { \ WRITE_PORT_UCHAR(pdev->notify_cmd_port, 0); \ } \ - EngReleaseSemaphore(pdev->Res->cmd_sem); \ } while (0); #define PUSH_CURSOR_CMD(pdev) do { \ @@ -196,6 +194,7 @@ static void WaitForCursorRing(PDev* pdev) } } +/* Called with cmd_sem held */ static void WaitForCmdRing(PDev* pdev) { int wait; @@ -581,11 +580,13 @@ void PushDrawable(PDev *pdev, QXLDrawable *drawable) { QXLCommand *cmd; + EngAcquireSemaphore(pdev->Res->cmd_sem); \ WaitForCmdRing(pdev); cmd = SPICE_RING_PROD_ITEM(pdev->cmd_ring); cmd->type = QXL_CMD_DRAW; cmd->data = PA(pdev, drawable, pdev->main_mem_slot); PUSH_CMD(pdev); + EngReleaseSemaphore(pdev->Res->cmd_sem); \ } static QXLSurfaceCmd *GetSurfaceCmd(PDev *pdev) @@ -618,11 +619,13 @@ void PushSurfaceCmd(PDev *pdev, QXLSurfaceCmd *surface_cmd) { QXLCommand *cmd; + EngAcquireSemaphore(pdev->Res->cmd_sem); \ WaitForCmdRing(pdev); cmd = SPICE_RING_PROD_ITEM(pdev->cmd_ring); cmd->type = QXL_CMD_SURFACE; cmd->data = PA(pdev, surface_cmd, pdev->main_mem_slot); PUSH_CMD(pdev); + EngReleaseSemaphore(pdev->Res->cmd_sem); \ } @@ -2426,11 +2429,13 @@ void UpdateArea(PDev *pdev, RECTL *area, UINT32 surface_id) updat_cmd->update_id = ++pdev->Res->update_id; updat_cmd->surface_id = surface_id; + EngAcquireSemaphore(pdev->Res->cmd_sem); \ WaitForCmdRing(pdev); cmd = SPICE_RING_PROD_ITEM(pdev->cmd_ring); cmd->type = QXL_CMD_UPDATE; cmd->data = PA(pdev, updat_cmd, pdev->main_mem_slot); PUSH_CMD(pdev); + EngReleaseSemaphore(pdev->Res->cmd_sem); \ do { #ifdef DBG { -- cgit v1.2.3