[Spice-devel] [PATCH qxl-win] display/*: add debug helpers DUMP_VRAM_MSPACE and DUMP_DEVRAM_MSPACE

Alon Levy alevy at redhat.com
Mon Jun 20 03:59:37 PDT 2011


changes the passed user pointer to mspace from NULL to a proper pdev, so
it will be able to print using QXL_IO_LOG.
---
 display/qxldd.h |   25 +++++++++++++++++++++++++
 display/res.c   |   14 ++++++++------
 display/res.h   |    1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/display/qxldd.h b/display/qxldd.h
index 0f90af1..d819e51 100644
--- a/display/qxldd.h
+++ b/display/qxldd.h
@@ -396,4 +396,29 @@ static _inline RingItem *RingGetTail(PDev *pdev, Ring *ring)
     return ret;
 }
 
+#ifdef DBG
+#define DUMP_VRAM_MSPACE(pdev) \
+    do { \
+        DEBUG_PRINT((pdev, 0, "%s: dumping mspace vram (%p, %p)\n", __FUNCTION__, pdev, global_res ? global_res[pdev->dev_id] : NULL)); \
+        if (pdev && global_res && global_res[pdev->dev_id]) {  \
+            mspace_malloc_stats(global_res[pdev->dev_id]->mspaces[MSPACE_TYPE_VRAM]._mspace); \
+        } else { \
+            DEBUG_PRINT((pdev, 0, "nothing\n")); \
+        }\
+    } while (0)
+
+#define DUMP_DEVRAM_MSPACE(pdev) \
+    do { \
+        DEBUG_PRINT((pdev, 0, "%s: dumping mspace devram (%p, %p)\n", __FUNCTION__, pdev, global_res ? global_res[pdev->dev_id] : NULL)); \
+        if (pdev && global_res && global_res[pdev->dev_id]) {  \
+            mspace_malloc_stats(global_res[pdev->dev_id]->mspaces[MSPACE_TYPE_DEVRAM]._mspace); \
+        } else { \
+            DEBUG_PRINT((pdev, 0, "nothing\n")); \
+        }\
+    } while (0)
+#else
+#define DUMP_VRAM_MSPACE
+#define DUMP_DEVRAM_MSPACE
+#endif
+
 #endif
diff --git a/display/res.c b/display/res.c
index 8d4ae6e..db4a671 100644
--- a/display/res.c
+++ b/display/res.c
@@ -427,11 +427,13 @@ void InitGlobalRes()
     }
 }
 
-static void InitMspace(DevRes *res, UINT32 mspace_type, UINT8 *io_pages_virt, size_t capacity)
+static void InitMspace(PDev *pdev, UINT32 mspace_type, UINT8 *start, size_t capacity)
 {
-    res->mspaces[mspace_type]._mspace = create_mspace_with_base(io_pages_virt, capacity, 0, NULL);
-    res->mspaces[mspace_type].mspace_start = io_pages_virt;
-    res->mspaces[mspace_type].mspace_end = io_pages_virt + capacity;
+    DevRes *res = pdev->Res;
+
+    res->mspaces[mspace_type]._mspace = create_mspace_with_base(start, capacity, 0, pdev);
+    res->mspaces[mspace_type].mspace_start = start;
+    res->mspaces[mspace_type].mspace_end = start + capacity;
 }
 
 static void InitRes(PDev *pdev)
@@ -483,8 +485,8 @@ static void InitRes(PDev *pdev)
         PANIC(pdev, "Res cache sem creation failed\n");
     }
 
-    InitMspace(pdev->Res, MSPACE_TYPE_DEVRAM, pdev->io_pages_virt, pdev->num_io_pages * PAGE_SIZE);
-    InitMspace(pdev->Res, MSPACE_TYPE_VRAM, pdev->fb, pdev->fb_size);
+    InitMspace(pdev, MSPACE_TYPE_DEVRAM, pdev->io_pages_virt, pdev->num_io_pages * PAGE_SIZE);
+    InitMspace(pdev, MSPACE_TYPE_VRAM, pdev->fb, pdev->fb_size);
     pdev->Res->update_id = *pdev->dev_update_id;
 
     RtlZeroMemory(pdev->Res->image_key_lookup,
diff --git a/display/res.h b/display/res.h
index ae4ad14..769c02d 100644
--- a/display/res.h
+++ b/display/res.h
@@ -70,5 +70,6 @@ void ResDestroyGlobals();
 void CheckAndSetSSE2();
 #endif
 void ResetAllDevices();
+extern DevRes **global_res;
 
 #endif
-- 
1.7.5.2



More information about the Spice-devel mailing list