Hi,
I forgot some more things about this patch:

On 07/07/2011 05:00 PM, Yonit Halperin wrote:

+static BOOL AssertModeDisable(PDev *pdev)
+{
+ DEBUG_PRINT((pdev, 3, "%s entry\n", __FUNCTION__));
+ /* flush command ring and update all surfaces */
+ WRITE_PORT_UCHAR(pdev->notify_cmd_port, 0);
+ WRITE_PORT_UCHAR(pdev->notify_cursor_port, 0);
don't think the above two IOs are needed. flush_surface will do the job.
+ WRITE_PORT_UCHAR(pdev->flush_surfaces_port, 0);
+ WRITE_PORT_UCHAR(pdev->destroy_all_surfaces_port, 0);
+ /* move all surfaces from device to system memory */
+ if (!MoveAllSurfacesToRam(pdev)) {
+ return FALSE;
+ }
If MoveAllSurfacesToRam we need to redo changes we done:
we either need to send surface create command for the surfaces that are still in the vram, or, we need to call destroy_all_surfaces_port only if MoveAllSurfacesToRam succeeds, and if MoveAllSurfacesToRam fails it needs to move all the surfaces it moved to RAM back to video ram

+ /* Free release ring contents */
+ ReleaseCacheDeviceMemoryResources(pdev);
+ EmptyReleaseRing(pdev);
+ /* Get the last free list onto the release ring */
+ WRITE_PORT_UCHAR(pdev->flush_release_port, 0);
+ DEBUG_PRINT((pdev, 4, "%s after FLUSH_RELEASE\n", __FUNCTION__));
+ /* And release that. mspace allocators should be clean after. */
+ EmptyReleaseRing(pdev);
+ RemoveVRamSlot(pdev);
+ DebugCountAliveSurfaces(pdev);
+ DEBUG_PRINT((pdev, 4, "%s: [%d,%d] [%d,%d] [%d,%d] %lx\n",
__FUNCTION__,
+ pdev->cmd_ring->prod, pdev->cmd_ring->cons,
+ pdev->cursor_ring->prod, pdev->cursor_ring->cons,
+ pdev->release_ring->prod, pdev->release_ring->cons,
+ pdev->Res->free_outputs));
+ DEBUG_PRINT((pdev, 4, "%s exit\n", __FUNCTION__));
+ return TRUE;
+}
+
+static void AssertModeEnable(PDev *pdev)
+{
+ InitResources(pdev);
+ InitDeviceMemoryResources(pdev);
+ DEBUG_PRINT((pdev, 3, "%s: [%d,%d] [%d,%d] [%d,%d] %lx\n",
__FUNCTION__,
+ pdev->cmd_ring->prod, pdev->cmd_ring->cons,
+ pdev->cursor_ring->prod, pdev->cursor_ring->cons,
+ pdev->release_ring->prod, pdev->release_ring->cons,
+ pdev->Res->free_outputs));
+ EnableQXLPrimarySurface(pdev);
+ CreateVRamSlot(pdev);
+ DebugCountAliveSurfaces(pdev);
+ MoveAllSurfacesToVideoRam(pdev);
+ DebugCountAliveSurfaces(pdev);
}

BOOL DrvAssertMode(DHPDEV in_pdev, BOOL enable)
{
PDev* pdev = (PDev*)in_pdev;
+ BOOL ret = TRUE;

DEBUG_PRINT((pdev, 1, "%s: 0x%lx %d\n", __FUNCTION__, pdev, enable));

+ if (pdev->enabled == enable) {
+ DEBUG_PRINT((pdev, 1, "%s: called twice with same argument (%d)\n",
__FUNCTION__,
+ enable));
+ return TRUE;
+ }
+ pdev->enabled = enable;
if (enable) {
- InitResources(pdev);
- EnableQXLPrimarySurface(pdev);
- CreateVRamSlot(pdev);

+ AssertModeEnable(pdev);
} else {
- DisableQXLPrimarySurface(pdev, 0);
- RemoveVRamSlot(pdev);
again, needs redo if AsserModeDiable fails
+ ret = AssertModeDisable(pdev);

I'm not sure about changing pdev->enabled if AssertModeDisable fails
(which means part of the surfaces are still on the vram)
}
DEBUG_PRINT((pdev, 1, "%s: 0x%lx exit %d\n", __FUNCTION__, pdev,
enable));
- return TRUE;
+ return ret;
}

ULONG DrvGetModes(HANDLE driver, ULONG dev_modes_size, DEVMODEW
*dev_modes)
diff --git a/display/surface.c b/display/surface.c
index 8f7aae1..b8628fe 100644
--- a/display/surface.c
+++ b/display/surface.c
@@ -249,6 +249,7 @@ BOOL MoveSurfaceToVideoRam(PDev *pdev, UINT32
surface_id)
surface_info->phys_mem = phys_mem;
surface_info->draw_area.base_mem = base_mem;
surface = SurfaceCmd(pdev, QXL_SURFACE_CMD_CREATE, surface_id);
+ surface->flags |= QXL_SURF_FLAG_KEEP_DATA;
surface->u.surface_create.format = surface_format;
surface->u.surface_create.width = cx;
surface->u.surface_create.height = cy;

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to