qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram
@ 2012-02-15  9:22 Yonit Halperin
  2012-02-15  9:22 ` [Qemu-devel] [PATCH v2 2/2] qxl: make sure primary surface is saved on migration also in compat mode Yonit Halperin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yonit Halperin @ 2012-02-15  9:22 UTC (permalink / raw)
  To: qemu-devel, spice-devel; +Cc: Yonit Halperin, kraxel

We used to assure the guest surfaces were saved before migration by
setting the whole vram dirty. This patch sets dirty only the areas
that are actually used in the vram.

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
---
 hw/qxl.c |   53 ++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index bc03c1d..df55de1 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1006,7 +1006,7 @@ static void qxl_reset_surfaces(PCIQXLDevice *d)
     qxl_spice_destroy_surfaces(d, QXL_SYNC);
 }
 
-/* called from spice server thread context only */
+/* can be also called from spice server thread context */
 void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
 {
     uint64_t phys   = le64_to_cpu(pqxl);
@@ -1465,6 +1465,46 @@ static void qxl_hw_text_update(void *opaque, console_ch_t *chardata)
     }
 }
 
+static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
+{
+    intptr_t vram_start;
+    int i;
+
+    if (qxl->mode != QXL_MODE_NATIVE) {
+        return;
+    }
+
+    /* dirty the primary surface */
+    qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,
+                  qxl->shadow_rom.surface0_area_size);
+
+    vram_start =  (intptr_t)memory_region_get_ram_ptr(&qxl->vram_bar);
+
+    /* dirty the off-screen surfaces */
+    for (i = 0; i < NUM_SURFACES; i++) {
+        QXLSurfaceCmd *cmd;
+        intptr_t surface_offset;
+        int surface_size;
+
+        if (qxl->guest_surfaces.cmds[i] == 0) {
+            continue;
+        }
+
+        cmd = qxl_phys2virt(qxl, qxl->guest_surfaces.cmds[i],
+                            MEMSLOT_GROUP_GUEST);
+        assert(cmd->type == QXL_SURFACE_CMD_CREATE);
+        surface_offset = (intptr_t)qxl_phys2virt(qxl,
+                                                 cmd->u.surface_create.data,
+                                                 MEMSLOT_GROUP_GUEST);
+        surface_offset -= vram_start;
+        surface_size = cmd->u.surface_create.height *
+                       abs(cmd->u.surface_create.stride);
+        dprint(qxl, 3, "%s: dirty surface %d, offset %d, size %d\n", __func__,
+               i, (int)surface_offset, surface_size);
+        qxl_set_dirty(&qxl->vram_bar, surface_offset, surface_size);
+    }
+}
+
 static void qxl_vm_change_state_handler(void *opaque, int running,
                                         RunState state)
 {
@@ -1478,14 +1518,9 @@ static void qxl_vm_change_state_handler(void *opaque, int running,
          * called
          */
          qxl_update_irq(qxl);
-    } else if (qxl->mode == QXL_MODE_NATIVE) {
-        /* dirty all vram (which holds surfaces) and devram (primary surface)
-         * to make sure they are saved */
-        /* FIXME #1: should go out during "live" stage */
-        /* FIXME #2: we only need to save the areas which are actually used */
-        qxl_set_dirty(&qxl->vram_bar, 0, qxl->vram_size);
-        qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,
-                      qxl->shadow_rom.surface0_area_size);
+    } else {
+        /* make sure surfaces are saved before migration */
+        qxl_dirty_surfaces(qxl);
     }
 }
 
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] qxl: make sure primary surface is saved on migration also in compat mode
  2012-02-15  9:22 [Qemu-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Yonit Halperin
@ 2012-02-15  9:22 ` Yonit Halperin
  2012-02-15  9:37 ` [Qemu-devel] [Spice-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Alon Levy
  2012-02-15 13:15 ` [Qemu-devel] " Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Yonit Halperin @ 2012-02-15  9:22 UTC (permalink / raw)
  To: qemu-devel, spice-devel; +Cc: Yonit Halperin, kraxel

RHBZ #790083

Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
---
 hw/qxl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index df55de1..10137f9 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -1470,7 +1470,7 @@ static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
     intptr_t vram_start;
     int i;
 
-    if (qxl->mode != QXL_MODE_NATIVE) {
+    if (qxl->mode != QXL_MODE_NATIVE && qxl->mode != QXL_MODE_COMPAT) {
         return;
     }
 
-- 
1.7.7.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Spice-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram
  2012-02-15  9:22 [Qemu-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Yonit Halperin
  2012-02-15  9:22 ` [Qemu-devel] [PATCH v2 2/2] qxl: make sure primary surface is saved on migration also in compat mode Yonit Halperin
@ 2012-02-15  9:37 ` Alon Levy
  2012-02-15 13:15 ` [Qemu-devel] " Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2012-02-15  9:37 UTC (permalink / raw)
  To: Yonit Halperin; +Cc: qemu-devel, spice-devel

On Wed, Feb 15, 2012 at 11:22:15AM +0200, Yonit Halperin wrote:
> We used to assure the guest surfaces were saved before migration by
> setting the whole vram dirty. This patch sets dirty only the areas
> that are actually used in the vram.
> 

Series is
Reviewed-by: Alon Levy <alevy@redhat.com>

> Signed-off-by: Yonit Halperin <yhalperi@redhat.com>
> ---
>  hw/qxl.c |   53 ++++++++++++++++++++++++++++++++++++++++++++---------
>  1 files changed, 44 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/qxl.c b/hw/qxl.c
> index bc03c1d..df55de1 100644
> --- a/hw/qxl.c
> +++ b/hw/qxl.c
> @@ -1006,7 +1006,7 @@ static void qxl_reset_surfaces(PCIQXLDevice *d)
>      qxl_spice_destroy_surfaces(d, QXL_SYNC);
>  }
>  
> -/* called from spice server thread context only */
> +/* can be also called from spice server thread context */
>  void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id)
>  {
>      uint64_t phys   = le64_to_cpu(pqxl);
> @@ -1465,6 +1465,46 @@ static void qxl_hw_text_update(void *opaque, console_ch_t *chardata)
>      }
>  }
>  
> +static void qxl_dirty_surfaces(PCIQXLDevice *qxl)
> +{
> +    intptr_t vram_start;
> +    int i;
> +
> +    if (qxl->mode != QXL_MODE_NATIVE) {
> +        return;
> +    }
> +
> +    /* dirty the primary surface */
> +    qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,
> +                  qxl->shadow_rom.surface0_area_size);
> +
> +    vram_start =  (intptr_t)memory_region_get_ram_ptr(&qxl->vram_bar);
> +
> +    /* dirty the off-screen surfaces */
> +    for (i = 0; i < NUM_SURFACES; i++) {
> +        QXLSurfaceCmd *cmd;
> +        intptr_t surface_offset;
> +        int surface_size;
> +
> +        if (qxl->guest_surfaces.cmds[i] == 0) {
> +            continue;
> +        }
> +
> +        cmd = qxl_phys2virt(qxl, qxl->guest_surfaces.cmds[i],
> +                            MEMSLOT_GROUP_GUEST);
> +        assert(cmd->type == QXL_SURFACE_CMD_CREATE);
> +        surface_offset = (intptr_t)qxl_phys2virt(qxl,
> +                                                 cmd->u.surface_create.data,
> +                                                 MEMSLOT_GROUP_GUEST);
> +        surface_offset -= vram_start;
> +        surface_size = cmd->u.surface_create.height *
> +                       abs(cmd->u.surface_create.stride);
> +        dprint(qxl, 3, "%s: dirty surface %d, offset %d, size %d\n", __func__,
> +               i, (int)surface_offset, surface_size);
> +        qxl_set_dirty(&qxl->vram_bar, surface_offset, surface_size);
> +    }
> +}
> +
>  static void qxl_vm_change_state_handler(void *opaque, int running,
>                                          RunState state)
>  {
> @@ -1478,14 +1518,9 @@ static void qxl_vm_change_state_handler(void *opaque, int running,
>           * called
>           */
>           qxl_update_irq(qxl);
> -    } else if (qxl->mode == QXL_MODE_NATIVE) {
> -        /* dirty all vram (which holds surfaces) and devram (primary surface)
> -         * to make sure they are saved */
> -        /* FIXME #1: should go out during "live" stage */
> -        /* FIXME #2: we only need to save the areas which are actually used */
> -        qxl_set_dirty(&qxl->vram_bar, 0, qxl->vram_size);
> -        qxl_set_dirty(&qxl->vga.vram, qxl->shadow_rom.draw_area_offset,
> -                      qxl->shadow_rom.surface0_area_size);
> +    } else {
> +        /* make sure surfaces are saved before migration */
> +        qxl_dirty_surfaces(qxl);
>      }
>  }
>  
> -- 
> 1.7.7.6
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram
  2012-02-15  9:22 [Qemu-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Yonit Halperin
  2012-02-15  9:22 ` [Qemu-devel] [PATCH v2 2/2] qxl: make sure primary surface is saved on migration also in compat mode Yonit Halperin
  2012-02-15  9:37 ` [Qemu-devel] [Spice-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Alon Levy
@ 2012-02-15 13:15 ` Gerd Hoffmann
  2 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2012-02-15 13:15 UTC (permalink / raw)
  To: Yonit Halperin; +Cc: qemu-devel, spice-devel

On 02/15/12 10:22, Yonit Halperin wrote:
> We used to assure the guest surfaces were saved before migration by
> setting the whole vram dirty. This patch sets dirty only the areas
> that are actually used in the vram.

Great.  Added both patches to the spice patch queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-15 13:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-15  9:22 [Qemu-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Yonit Halperin
2012-02-15  9:22 ` [Qemu-devel] [PATCH v2 2/2] qxl: make sure primary surface is saved on migration also in compat mode Yonit Halperin
2012-02-15  9:37 ` [Qemu-devel] [Spice-devel] [PATCH v2 1/2] qxl: set only off-screen surfaces dirty instead of the whole vram Alon Levy
2012-02-15 13:15 ` [Qemu-devel] " Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).