summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Levy <alevy@redhat.com>2011-06-05 16:39:11 +0300
committerAlon Levy <alevy@redhat.com>2011-07-17 23:25:24 +0300
commit0f0e8046ce17e42091f291272d293957a5e4edc7 (patch)
treedd2ffa9dbe1daea2313c0cb1f10602caca8b887d
parent808e381bcfe02bfa946455298269aa854fd3e519 (diff)
display/surface: add DEVICE_BITMAP_ALLOCATION_TYPE_RAM, cleanup surface alloc/free code paths
This adds a third surface allocation type, allocation from guest memory using the windows ddk allocator. Not all code paths are used later - the creation is not done since copy-surfaces-to-ram allocates memory itself, and at the end we never allocate any surfaces when the device is disabled, we just punt the allocation to the gdi, but the code is still left in GetSurfaceMemory. Cc: Yonit Halperin <yhalperi@redhat.com>
-rw-r--r--display/driver.c6
-rw-r--r--display/res.c40
-rw-r--r--display/surface.c17
-rw-r--r--display/surface.h1
4 files changed, 43 insertions, 21 deletions
diff --git a/display/driver.c b/display/driver.c
index c19fcaa..d5f9d8c 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -1290,9 +1290,15 @@ VOID APIENTRY DrvDeleteDeviceBitmap(DHSURF dhsurf)
{
UINT32 surface_id;
SurfaceInfo *surface;
+ PDev *pdev;
surface = (SurfaceInfo *)dhsurf;
surface_id = GetSurfaceIdFromInfo(surface);
+ pdev = surface->u.pdev;
+
+ DEBUG_PRINT((pdev, 3, "%s: %p: %d\n", __FUNCTION__, pdev, surface_id));
+
+ ASSERT(pdev, surface_id < pdev->n_surfaces);
DeleteDeviceBitmap(surface->u.pdev, surface_id, DEVICE_BITMAP_ALLOCATION_TYPE_VRAM);
}
diff --git a/display/res.c b/display/res.c
index cc272be..c21b2f6 100644
--- a/display/res.c
+++ b/display/res.c
@@ -788,13 +788,21 @@ _inline void GetSurfaceMemory(PDev *pdev, UINT32 x, UINT32 y, UINT32 depth, UINT
*base_mem = AllocMem(pdev, MSPACE_TYPE_DEVRAM, (*stride) * y);
*phys_mem = PA(pdev, *base_mem, pdev->main_mem_slot);
break;
- case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM: {
+ case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM:
*stride = x * depth / 8;
*stride = ALIGN(*stride, 4);
*base_mem = __AllocMem(pdev, MSPACE_TYPE_VRAM, (*stride) * y, FALSE);
*phys_mem = PA(pdev, (PVOID)((UINT64)*base_mem), pdev->vram_mem_slot);
break;
- }
+ case DEVICE_BITMAP_ALLOCATION_TYPE_RAM:
+ /* used only before suspend to sleep (DrvAssertMode(FALSE)) and then released
+ * and copied back to VRAM */
+ *stride = x * depth / 8;
+ *stride = ALIGN(*stride, 4);
+ *base_mem = EngAllocMem(0 /* don't zero memory, will be copied over in a bit */,
+ (*stride) * y, ALLOC_TAG);
+ *phys_mem = (QXLPHYSICAL)NULL; /* make sure no one uses it */
+ break;
default:
PANIC(pdev, "No allocation type");
}
@@ -808,10 +816,18 @@ void QXLGetSurface(PDev *pdev, QXLPHYSICAL *surface_phys, UINT32 x, UINT32 y, UI
void QXLDelSurface(PDev *pdev, UINT8 *base_mem, UINT8 allocation_type)
{
- if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM) {
+ switch (allocation_type) {
+ case DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM:
FreeMem(pdev, MSPACE_TYPE_DEVRAM, base_mem);
- } else if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_VRAM) { // this wasn't there in the original code
- FreeMem(pdev, MSPACE_TYPE_VRAM, base_mem);
+ break;
+ case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM:
+ FreeMem(pdev, MSPACE_TYPE_VRAM, base_mem);
+ break;
+ case DEVICE_BITMAP_ALLOCATION_TYPE_RAM:
+ EngFreeMem(base_mem);
+ break;
+ default:
+ PANIC(pdev, "bad allocation type");
}
}
@@ -827,18 +843,8 @@ static void FreeDelSurface(PDev *pdev, Resource *res)
DEBUG_PRINT((pdev, 12, "%s\n", __FUNCTION__));
internal = (InternalDelSurface *)res->res;
- switch (internal->allocation_type) {
- case DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM:
- FreeMem(pdev, MSPACE_TYPE_DEVRAM,
- GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem);
- break;
- case DEVICE_BITMAP_ALLOCATION_TYPE_VRAM:
- FreeMem(pdev, MSPACE_TYPE_VRAM,
- GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem);
- break;
- default:
- PANIC(pdev, "bad allocation type");
- }
+ QXLDelSurface(pdev, GetSurfaceInfo(pdev, internal->surface_id)->draw_area.base_mem,
+ internal->allocation_type);
FreeSurfaceInfo(pdev, internal->surface_id);
FreeMem(pdev, MSPACE_TYPE_DEVRAM, res);
diff --git a/display/surface.c b/display/surface.c
index aabc31a..20fd950 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -159,10 +159,19 @@ VOID DeleteDeviceBitmap(PDev *pdev, UINT32 surface_id, UINT8 allocation_type)
if (allocation_type != DEVICE_BITMAP_ALLOCATION_TYPE_SURF0 &&
pdev->Res->surfaces_info[surface_id].draw_area.base_mem != NULL) {
- QXLSurfaceCmd *surface;
- surface = SurfaceCmd(pdev, QXL_SURFACE_CMD_DESTROY, surface_id);
- QXLGetDelSurface(pdev, surface, surface_id, allocation_type);
- PushSurfaceCmd(pdev, surface);
+ if (allocation_type == DEVICE_BITMAP_ALLOCATION_TYPE_RAM) {
+ /* server side this surface is already destroyed, just free it here */
+ ASSERT(pdev, pdev->Res->surfaces_info[surface_id].draw_area.base_mem ==
+ pdev->Res->surfaces_info[surface_id].copy);
+ QXLDelSurface(pdev, pdev->Res->surfaces_info[surface_id].draw_area.base_mem,
+ allocation_type);
+ FreeSurfaceInfo(pdev, surface_id);
+ } else {
+ QXLSurfaceCmd *surface_cmd;
+ surface_cmd = SurfaceCmd(pdev, QXL_SURFACE_CMD_DESTROY, surface_id);
+ QXLGetDelSurface(pdev, surface_cmd, surface_id, allocation_type);
+ PushSurfaceCmd(pdev, surface_cmd);
+ }
}
}
diff --git a/display/surface.h b/display/surface.h
index 0b7edb3..f723392 100644
--- a/display/surface.h
+++ b/display/surface.h
@@ -98,6 +98,7 @@ enum {
DEVICE_BITMAP_ALLOCATION_TYPE_SURF0,
DEVICE_BITMAP_ALLOCATION_TYPE_DEVRAM,
DEVICE_BITMAP_ALLOCATION_TYPE_VRAM,
+ DEVICE_BITMAP_ALLOCATION_TYPE_RAM,
};
HBITMAP CreateDeviceBitmap(PDev *pdev, SIZEL size, ULONG format, QXLPHYSICAL *phys_mem,