[Spice-devel] [PATCH] display: add FlushRelease and FlushSurfaces for alternative V06 (2) revision implementation

Alon Levy alevy at redhat.com
Wed Jul 6 05:35:06 PDT 2011


---
 display/driver.c |   44 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/display/driver.c b/display/driver.c
index 02ee8d0..37135aa 100644
--- a/display/driver.c
+++ b/display/driver.c
@@ -956,13 +956,53 @@ VOID DrvDisableSurface(DHPDEV in_pdev)
     DEBUG_PRINT((pdev, 1, "%s: 0x%lx exit\n", __FUNCTION__, pdev));
 }
 
+static void FlushSurfaces(PDev *pdev)
+{
+    UINT32 surface_id;
+    SurfaceInfo *surface_info;
+    SURFOBJ *surf_obj;
+    RECTL area = {0, 0, 0, 0};
+
+    if (pdev->pci_revision < QXL_REVISION_STABLE_V10) {
+        DEBUG_PRINT((pdev, 1, "%s: revision too old for QXL_IO_FLUSH_SURFACES", __FUNCTION__));
+        for (surface_id = pdev->n_surfaces - 1 ; surface_id > 0 ; --surface_id) {
+            surface_info = GetSurfaceInfo(pdev, surface_id);
+            if (!surface_info->draw_area.base_mem) {
+                continue;
+            }
+            surf_obj = surface_info->draw_area.surf_obj;
+            if (!surf_obj) {
+                continue;
+            }
+            area.right = surf_obj->sizlBitmap.cx;
+            area.bottom = surf_obj->sizlBitmap.cy;
+            UpdateArea(pdev, &area, surface_id);
+        }
+    } else {
+        WRITE_PORT_UCHAR(pdev->flush_surfaces_port, 0);
+    }
+}
+static void FlushRelease(PDev *pdev)
+{
+    if (pdev->pci_revision < QXL_REVISION_STABLE_V10) {
+        DEBUG_PRINT((pdev, 1, "%s: revision too old for QXL_IO_FLUSH_RELEASE", __FUNCTION__));
+        // ooming a few times causes the server to flush
+        // all releasable resources
+        WRITE_PORT_UCHAR(pdev->notify_oom_port, 0);
+        WRITE_PORT_UCHAR(pdev->notify_oom_port, 0);
+        WRITE_PORT_UCHAR(pdev->notify_oom_port, 0);
+    } else {
+        WRITE_PORT_UCHAR(pdev->flush_release_port, 0);
+    }
+}
+
 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);
-    WRITE_PORT_UCHAR(pdev->flush_surfaces_port, 0);
+    FlushSurfaces(pdev);
     WRITE_PORT_UCHAR(pdev->destroy_all_surfaces_port, 0);
     /* move all surfaces from device to system memory */
     if (!MoveAllSurfacesToRam(pdev)) {
@@ -972,7 +1012,7 @@ static BOOL AssertModeDisable(PDev *pdev)
     ReleaseCacheDeviceMemoryResources(pdev);
     EmptyReleaseRing(pdev);
     /* Get the last free list onto the release ring */
-    WRITE_PORT_UCHAR(pdev->flush_release_port, 0);
+    FlushRelease(pdev);
     DEBUG_PRINT((pdev, 4, "%s after FLUSH_RELEASE\n", __FUNCTION__));
     /* And release that. mspace allocators should be clean after. */
     EmptyReleaseRing(pdev);
-- 
1.7.5.4



More information about the Spice-devel mailing list