[Spice-commits] 8 commits - display/driver.c display/quic.c display/res.c display/surface.c display/surface.h miniport/qxl.c
Alon Levy
alon at kemper.freedesktop.org
Mon Jun 20 06:16:05 PDT 2011
display/driver.c | 17 +++----------
display/quic.c | 4 +++
display/res.c | 70 ++++++++++++++++++++----------------------------------
display/surface.c | 7 ++---
display/surface.h | 4 ---
miniport/qxl.c | 4 +--
6 files changed, 41 insertions(+), 65 deletions(-)
New commits:
commit 66db878a8473b701ea4e71124201e13e57872323
Author: Alon Levy <alevy at redhat.com>
Date: Sun Jun 5 17:53:09 2011 +0300
display/driver: DebugPrintV: check for pdev->Res before dereferencing it
diff --git a/display/driver.c b/display/driver.c
index b452a4f..f82c744 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -107,7 +107,7 @@ static CallCounterInfo counters_info[NUM_CALL_COUNTERS] = {
void DebugPrintV(PDev *pdev, const char *message, va_list ap)
{
- if (pdev && pdev->log_buf) {
+ if (pdev && pdev->log_buf && pdev->Res) {
EngAcquireSemaphore(pdev->Res->print_sem);
_snprintf(pdev->log_buf, QXL_LOG_BUF_SIZE, QXLDD_DEBUG_PREFIX);
_vsnprintf(pdev->log_buf + strlen(QXLDD_DEBUG_PREFIX),
commit b264a129fd9d6730f26a2062f857f48fd0fd2e19
Author: Alon Levy <alevy at redhat.com>
Date: Sun Jun 5 14:28:28 2011 +0300
display/surface: CreateDeviceBitmap: remove redundant FreeSurface
on error2 path, if we failed QXLGetSurface, we free the surface info but then
the caller (DrvCreateDeviceBitmap) frees it again. In addition, we cannot free
the SurfaceInfo since it is the handle given to GDI and is accessed on callback
from EngDestroySurface (which is called immediatelly after in the same error
path).
diff --git a/display/surface.c b/display/surface.c
index d6e1be3..0a93abf 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -152,7 +152,6 @@ HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *ph
out_error3:
QXLDelSurface(pdev, *base_mem, allocation_type);
out_error2:
- FreeSurface(pdev, surface_id);
EngDeleteSurface((HSURF)surf);
out_error1:
return 0;
commit 7014aa88bdcc70ee56badb3fae3ea9c34cd479eb
Author: Alon Levy <alevy at redhat.com>
Date: Thu May 26 14:21:24 2011 +0300
treewide: staticfy some functions, small indentation fixes
diff --git a/display/driver.c b/display/driver.c
index 6bc0830..b452a4f 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -50,7 +50,7 @@ static DRVFN drv_calls[] = {
{INDEX_DrvDisablePDEV, (PFN)DrvDisablePDEV},
{INDEX_DrvCompletePDEV, (PFN)DrvCompletePDEV},
{INDEX_DrvEnableSurface, (PFN)DrvEnableSurface},
- {INDEX_DrvDisableSurface, (PFN) DrvDisableSurface},
+ {INDEX_DrvDisableSurface, (PFN)DrvDisableSurface},
{INDEX_DrvAssertMode, (PFN)DrvAssertMode},
{INDEX_DrvGetModes, (PFN)DrvGetModes},
{INDEX_DrvSynchronize, (PFN)DrvSynchronize},
@@ -219,7 +219,7 @@ DEVINFO dev_default = {
GCAPS2_ALPHACURSOR,
};
-BOOL PrepareHardware(PDev *pdev);
+static BOOL PrepareHardware(PDev *pdev);
static void mspace_print(void *user_data, char *format, ...)
{
@@ -663,7 +663,7 @@ static BOOLEAN CreateVRamSlot(PDev *pdev)
}
-BOOL PrepareHardware(PDev *pdev)
+static BOOL PrepareHardware(PDev *pdev)
{
VIDEO_MEMORY video_mem;
VIDEO_MEMORY_INFORMATION video_mem_Info;
diff --git a/display/res.c b/display/res.c
index c39e022..c69b600 100644
--- a/display/res.c
+++ b/display/res.c
@@ -560,10 +560,10 @@ void InitResources(PDev *pdev)
if (global_res[id] == NULL) {
global_res[id] = EngAllocMem(FL_ZERO_MEMORY, sizeof(DevRes), ALLOC_TAG);
- pdev->Res = global_res[id];
+ pdev->Res = global_res[id];
InitRes(pdev);
} else {
- pdev->Res = global_res[id];
+ pdev->Res = global_res[id];
}
EngReleaseSemaphore(res_sem);
}
@@ -1410,14 +1410,14 @@ static CacheImage *AllocCacheImage(PDev* pdev)
{
RingItem *item;
while (!(item = RingGetTail(pdev, &pdev->Res->cache_image_lru))) {
- /* malloc_sem protects release_ring too */
+ /* malloc_sem protects release_ring too */
EngAcquireSemaphore(pdev->Res->malloc_sem);
if (pdev->Res->free_outputs == 0 &&
SPICE_RING_IS_EMPTY(pdev->release_ring)) {
WaitForReleaseRing(pdev);
}
FlushReleaseRing(pdev);
- EngReleaseSemaphore(pdev->Res->malloc_sem);
+ EngReleaseSemaphore(pdev->Res->malloc_sem);
}
RingRemove(pdev, item);
return CONTAINEROF(item, CacheImage, lru_link);
diff --git a/display/surface.c b/display/surface.c
index 7146b32..d6e1be3 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -40,8 +40,8 @@
#include "res.h"
#include "surface.h"
-BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, ULONG format, UINT32 cx, UINT32 cy, UINT32 stride,
- UINT32 surface_id)
+static BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, ULONG format, UINT32 cx, UINT32 cy,
+ UINT32 stride, UINT32 surface_id)
{
SIZEL size;
DrawArea *drawarea;
@@ -74,7 +74,7 @@ error:
return FALSE;
}
-VOID FreeDrawArea(DrawArea *drawarea)
+static VOID FreeDrawArea(DrawArea *drawarea)
{
if (drawarea->surf_obj) {
EngUnlockSurface(drawarea->surf_obj);
diff --git a/display/surface.h b/display/surface.h
index d741690..608696c 100644
--- a/display/surface.h
+++ b/display/surface.h
@@ -76,10 +76,6 @@ enum {
DEVICE_BITMAP_ALLOCATION_TYPE_VRAM,
};
-BOOL CreateDrawArea(PDev *pdev, UINT8 *base_mem, ULONG format, UINT32 cx, UINT32 cy, UINT32 stride,
- UINT32 surface_id);
-VOID FreeDrawArea(DrawArea *drawarea);
-
HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *phys_mem,
UINT8 **base_mem, UINT32 surface_id, UINT8 allocation_type);
VOID DeleteDeviceBitmap(PDev *pdev, UINT32 surface_id, UINT8 allocation_type);
diff --git a/miniport/qxl.c b/miniport/qxl.c
index 855b08b..9d8ab36 100644
--- a/miniport/qxl.c
+++ b/miniport/qxl.c
@@ -204,7 +204,7 @@ VP_STATUS InitRom(QXLExtension *dev, PVIDEO_ACCESS_RANGE range)
__FUNCTION__, (ULONG)range->RangeStart.QuadPart, range->RangeLength));
return NO_ERROR;
- err:
+err:
VideoPortUnmapMemory(dev, rom, NULL);
DEBUG_PRINT((0, "%s ERR\n", __FUNCTION__));
return error;
@@ -1005,7 +1005,7 @@ BOOLEAN StartIO(PVOID dev_extension, PVIDEO_REQUEST_PACKET packet)
packet->StatusBlock->Status = NO_ERROR;
DEBUG_PRINT((0, "%s: OK\n", __FUNCTION__));
return TRUE;
- err:
+err:
packet->StatusBlock->Information = 0;
packet->StatusBlock->Status = error;
DEBUG_PRINT((0, "%s: ERR\n", __FUNCTION__));
commit dfd77bd0399821a2ada9ee4cb8cb5114feb34ce2
Author: Alon Levy <alevy at redhat.com>
Date: Fri Jun 17 21:25:32 2011 +0200
display/res: better error message for FreeMem assert
diff --git a/display/res.c b/display/res.c
index 1b8cf84..c39e022 100644
--- a/display/res.c
+++ b/display/res.c
@@ -344,8 +344,15 @@ static void *__AllocMem(PDev* pdev, UINT32 mspace_type, size_t size, BOOL force)
static void FreeMem(PDev* pdev, UINT32 mspace_type, void *ptr)
{
ASSERT(pdev, pdev && pdev->Res->mspaces[mspace_type]._mspace);
- ASSERT(pdev, (UINT8 *)ptr >= pdev->Res->mspaces[mspace_type].mspace_start &&
- (UINT8 *)ptr < pdev->Res->mspaces[mspace_type].mspace_end);
+#ifdef DBG
+ if (!((UINT8 *)ptr >= pdev->Res->mspaces[mspace_type].mspace_start &&
+ (UINT8 *)ptr < pdev->Res->mspaces[mspace_type].mspace_end)) {
+ DebugPrint(pdev, 0, "ASSERT failed @ %s, %p not in [%p, %p) (%d)\n", __FUNCTION__,
+ ptr, pdev->Res->mspaces[mspace_type].mspace_start,
+ pdev->Res->mspaces[mspace_type].mspace_end, mspace_type);
+ EngDebugBreak();
+ }
+#endif
EngAcquireSemaphore(pdev->Res->malloc_sem);
mspace_free(pdev->Res->mspaces[mspace_type]._mspace, ptr);
EngReleaseSemaphore(pdev->Res->malloc_sem);
commit 3fc73fcdc01bbe254f977c73599e14933948c235
Author: Alon Levy <alevy at redhat.com>
Date: Tue Apr 19 21:02:08 2011 +0300
display/driver: DebugPrint: check for log_level being set (allow using DebugPrint with pdev early)
diff --git a/display/driver.c b/display/driver.c
index 871aecb..6bc0830 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -123,7 +123,7 @@ void DebugPrint(PDev *pdev, int level, const char *message, ...)
{
va_list ap;
- if (level > (pdev ? (int)*pdev->log_level : DBG_LEVEL)) {
+ if (level > (pdev && pdev->log_level ? (int)*pdev->log_level : DBG_LEVEL)) {
return;
}
va_start(ap, message);
commit 811600ecce978293710ec89b39166935e910d605
Author: Alon Levy <alevy at redhat.com>
Date: Mon Apr 4 15:52:02 2011 +0300
display/res: turn two asserts in CursorCacheRemove to debug prints
In Free build this is defined out anyway, but in checked build this assert
triggers, so change it to a debug print (pending investigation on why
someone thought at some point it should never happen).
The asserts were on:
cursor->unique != 0
function end not reached
diff --git a/display/res.c b/display/res.c
index 5dc6e10..1b8cf84 100644
--- a/display/res.c
+++ b/display/res.c
@@ -2778,7 +2778,10 @@ static void CursorCacheRemove(PDev *pdev, InternalCursor *cursor)
DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__));
- ASSERT(pdev, cursor->unique);
+ if (!cursor->unique) {
+ DEBUG_PRINT((pdev, 1, "%s: cursor not unique\n", __FUNCTION__));
+ return;
+ }
internal = &pdev->Res->cursor_cache[CURSOR_HASH_VAL(cursor->hsurf)];
while (*internal) {
@@ -2794,7 +2797,7 @@ static void CursorCacheRemove(PDev *pdev, InternalCursor *cursor)
}
internal = &(*internal)->next;
}
- ASSERT(pdev, FALSE);
+ DEBUG_PRINT((pdev, 0, "%s: Error: should not reach this\n", __FUNCTION__));
}
static void CursorCacheAdd(PDev *pdev, InternalCursor *cursor)
commit bddc0cff3460b29a3e56112bddbccff97186e0be
Author: Alon Levy <alevy at redhat.com>
Date: Mon Jun 20 14:21:55 2011 +0200
display: fix broken debug in checked
The dropped ASSERTS in GetCosmeticAttr contain undefined allcaps defines,
so dropping them.
The rest are mostly moved structs that didn't update the ASSERT contents.
diff --git a/display/driver.c b/display/driver.c
index dbe6978..871aecb 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -1074,10 +1074,6 @@ FIX FlotaToFixed(FLOATL val, FLOATL scale)
static BOOL GetCosmeticAttr(PDev *pdev, QXLDrawable *drawable, QXLLineAttr *q_line_attr,
LINEATTRS *line_attr)
{
- ASSERT(pdev, LINE_CAP_ROUND == ENDCAP_ROUND && LINE_CAP_SQUARE == ENDCAP_SQUARE &&
- LINE_CAP_BUTT == ENDCAP_BUTT && LINE_JOIN_ROUND == JOIN_ROUND &&
- LINE_JOIN_BEVEL == JOIN_BEVEL && LINE_JOIN_MITER == JOIN_MITER);
-
q_line_attr->join_style = JOIN_MITER;
q_line_attr->end_style = ENDCAP_BUTT;
q_line_attr->width = 1 << 4;
@@ -1089,8 +1085,6 @@ static BOOL GetCosmeticAttr(PDev *pdev, QXLDrawable *drawable, QXLLineAttr *q_li
FIX *end;
UINT32 nseg;
- ASSERT(pdev, LA_STYLED == LINE_STYLED);
- ASSERT(pdev, LA_STARTGAP == LINE_START_WITH_GAP);
q_line_attr->flags = (UINT8)(line_attr->fl & (LA_STYLED | LA_STARTGAP));
nseg = (line_attr->fl & LA_ALTERNATE) ? 2 : line_attr->cstyle;
if ( nseg > 100) {
diff --git a/display/quic.c b/display/quic.c
index 2c23d9a..5dc66d4 100644
--- a/display/quic.c
+++ b/display/quic.c
@@ -63,6 +63,10 @@
#define ABS(a) ((a) >= 0 ? (a) : -(a))
+#ifdef ASSERT
+#undef ASSERT
+#endif
+
#ifdef DEBUG
#define ASSERT(usr, x) \
diff --git a/display/res.c b/display/res.c
index 4e2cdfe..5dc6e10 100644
--- a/display/res.c
+++ b/display/res.c
@@ -627,7 +627,7 @@ QXLSurfaceCmd *SurfaceCmd(PDev *pdev, UINT8 type, UINT32 surface_id)
{
QXLSurfaceCmd *surface_cmd;
- ASSERT(pdev, pdev && area);
+ ASSERT(pdev, pdev);
surface_cmd = GetSurfaceCmd(pdev);
surface_cmd->surface_id = surface_id;
@@ -2141,7 +2141,7 @@ BOOL QXLGetBitmap(PDev *pdev, QXLDrawable *drawable, QXLPHYSICAL *image_phys, SU
alloc_size = sizeof(Resource) + sizeof(InternalImage);
image_res = AllocMem(pdev, MSPACE_TYPE_DEVRAM, alloc_size);
- ONDBG(pdev->num_bits_pages++);
+ ONDBG(pdev->Res->num_bits_pages++);
image_res->refs = 1;
image_res->free = FreeSurfaceImage;
@@ -2307,7 +2307,7 @@ BOOL QXLGetAlphaBitmap(PDev *pdev, QXLDrawable *drawable, QXLPHYSICAL *image_phy
alloc_size = sizeof(Resource) + sizeof(InternalImage);
image_res = AllocMem(pdev, MSPACE_TYPE_DEVRAM, alloc_size);
- ONDBG(pdev->num_bits_pages++);
+ ONDBG(pdev->Res->num_bits_pages++);
image_res->refs = 1;
image_res->free = FreeSurfaceImage;
commit aa3a580ae330987e447ade517b6c6259b97b8c48
Author: Alon Levy <alevy at redhat.com>
Date: Wed Mar 30 15:13:28 2011 +0200
display: use WAIT_FOR_EVENT everywhere
diff --git a/display/driver.c b/display/driver.c
index b129f52..dbe6978 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -1377,4 +1377,3 @@ BOOL APIENTRY DrvStrokeAndFillPath(
}
#endif
-
diff --git a/display/res.c b/display/res.c
index f8f9c71..4e2cdfe 100644
--- a/display/res.c
+++ b/display/res.c
@@ -174,22 +174,13 @@ static void WaitForCursorRing(PDev* pdev)
{
LARGE_INTEGER timeout; // 1 => 100 nanoseconds
timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative => relative // 1s
-#if (WINVER < 0x0501)
- pdev->WaitForEvent(pdev->cursor_event, &timeout);
-#else
- EngWaitForSingleObject(pdev->cursor_event, &timeout);
-#endif // (WINVER < 0x0501)
-
+ WAIT_FOR_EVENT(pdev, pdev->cursor_event, &timeout);
if (SPICE_RING_IS_FULL(pdev->cursor_ring)) {
DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
}
}
#else
-#if (WINVER < 0x0501)
- pdev->WaitForEvent(pdev->cursor_event, NULL);
-#else
- EngWaitForSingleObject(pdev->cursor_event, NULL);
-#endif // (WINVER < 0x0501)
+ WAIT_FOR_EVENT(pdev, pdev->cursor_event, NULL);
#endif //DBG
}
}
@@ -211,22 +202,13 @@ static void WaitForCmdRing(PDev* pdev)
{
LARGE_INTEGER timeout; // 1 => 100 nanoseconds
timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative => relative // 1s
-#if (WINVER < 0x0501)
- pdev->WaitForEvent(pdev->display_event, &timeout);
-#else
- EngWaitForSingleObject(pdev->display_event, &timeout);
-#endif // (WINVER < 0x0501)
-
+ WAIT_FOR_EVENT(pdev, pdev->display_event, &timeout);
if (SPICE_RING_IS_FULL(pdev->cmd_ring)) {
DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
}
}
#else
-#if (WINVER < 0x0501)
- pdev->WaitForEvent(pdev->display_event, NULL);
-#else
- EngWaitForSingleObject(pdev->display_event, NULL);
-#endif // (WINVER < 0x0501)
+ WAIT_FOR_EVENT(pdev, pdev->display_event, NULL);
#endif //DBG
}
}
@@ -2530,21 +2512,13 @@ void UpdateArea(PDev *pdev, RECTL *area, UINT32 surface_id)
{
LARGE_INTEGER timeout; // 1 => 100 nanoseconds
timeout.QuadPart = -1 * (1000 * 1000 * 10); //negative => relative // 1s
-#if (WINVER < 0x0501)
- pdev->WaitForEvent(pdev->display_event, &timeout);
-#else
- EngWaitForSingleObject(pdev->display_event, &timeout);
-#endif //(WINVER < 0x0501)
+ WAIT_FOR_EVENT(pdev, pdev->display_event, &timeout);
if (*pdev->dev_update_id != pdev->Res->update_id) {
DEBUG_PRINT((pdev, 0, "%s: 0x%lx: timeout\n", __FUNCTION__, pdev));
}
}
#else
-#if (WINVER < 0x0501)
- pdev->WaitForEvent(pdev->display_event, NULL);
-#else
- EngWaitForSingleObject(pdev->display_event, NULL);
-#endif //(WINVER < 0x0501)
+ WAIT_FOR_EVENT(pdev, pdev->display_event, NULL);
#endif // DEBUG
mb();
} while (*pdev->dev_update_id != pdev->Res->update_id);
More information about the Spice-commits
mailing list