summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-09-13 20:11:37 +0200
committerAlexander Larsson <alexl@redhat.com>2010-09-20 10:25:16 +0200
commitb12ee84241ee004fd540b3146f50ad786abf36a9 (patch)
tree76fe7eac7539df529482374f2cd04f248ee52392
parentf599cd2226ecebe925db4c88c448c1dcda926748 (diff)
Add protection for cursor_ring
-rw-r--r--display/qxldd.h1
-rw-r--r--display/res.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/display/qxldd.h b/display/qxldd.h
index 1a9bfe6..956f152 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -185,6 +185,7 @@ typedef struct DevRes {
HSEMAPHORE print_sem;
HSEMAPHORE cmd_sem;
+ HSEMAPHORE cursor_sem; /* Protects cursor_ring */
HSEMAPHORE surface_sem; /* Protects surfaces allocation */
CacheImage cache_image_pool[IMAGE_POOL_SIZE];
diff --git a/display/res.c b/display/res.c
index 379ba86..33abd31 100644
--- a/display/res.c
+++ b/display/res.c
@@ -158,6 +158,7 @@ static _inline void CursorCmdAddRes(PDev *pdev, QXLCursorCmd *cmd, Resource *res
AddRes(pdev, output, res);
}
+/* Called with cursor_sem held */
static void WaitForCursorRing(PDev* pdev)
{
int wait;
@@ -394,6 +395,10 @@ void CleanGlobalRes()
EngDeleteSemaphore(res->cmd_sem);
res->cmd_sem = NULL;
}
+ if (res->cursor_sem) {
+ EngDeleteSemaphore(res->cursor_sem);
+ res->cursor_sem = NULL;
+ }
if (res->print_sem) {
EngDeleteSemaphore(res->print_sem);
res->print_sem = NULL;
@@ -459,6 +464,10 @@ static void InitRes(PDev *pdev)
if (!pdev->Res->cmd_sem) {
PANIC(pdev, "Res cmd sem creation failed\n");
}
+ pdev->Res->cursor_sem = EngCreateSemaphore();
+ if (!pdev->Res->cursor_sem) {
+ PANIC(pdev, "Res cursor sem creation failed\n");
+ }
pdev->Res->print_sem = EngCreateSemaphore();
if (!pdev->Res->print_sem) {
PANIC(pdev, "Res print sem creation failed\n");
@@ -2695,11 +2704,13 @@ void PushCursorCmd(PDev *pdev, QXLCursorCmd *cursor_cmd)
QXLCommand *cmd;
DEBUG_PRINT((pdev, 6, "%s\n", __FUNCTION__));
+ EngAcquireSemaphore(pdev->Res->cursor_sem);
WaitForCursorRing(pdev);
cmd = SPICE_RING_PROD_ITEM(pdev->cursor_ring);
cmd->type = QXL_CMD_CURSOR;
cmd->data = PA(pdev, cursor_cmd, pdev->main_mem_slot);
PUSH_CURSOR_CMD(pdev);
+ EngReleaseSemaphore(pdev->Res->cursor_sem);
DEBUG_PRINT((pdev, 8, "%s: done\n", __FUNCTION__));
}