qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <marcandre.lureau@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@gmail.com>, kraxel@redhat.com
Subject: [Qemu-devel] [PATCH] console: remove refresh timer when using spice & QXL mode
Date: Tue,  4 Nov 2014 12:23:23 +0100	[thread overview]
Message-ID: <1415100203-20405-1-git-send-email-marcandre.lureau@gmail.com> (raw)

There is no need for the display refresh timer when using Spice with QXL
driver. The refresh is restored when entering VGA mode, or if any other
display listener requires refresh. This saves a few wakeups per seconds.

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=912763

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
---
 hw/display/qxl.c     | 14 ++++++++++++++
 include/ui/console.h |  3 +++
 ui/console.c         | 23 ++++++++++++++++++++---
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index b540dd6..34a6334 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1096,6 +1096,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
     d->mode = QXL_MODE_VGA;
     vga_dirty_log_start(&d->vga);
     graphic_hw_update(d->vga.con);
+    update_displaystate(d->ssd.dcl.ds);
 }
 
 static void qxl_exit_vga_mode(PCIQXLDevice *d)
@@ -1107,6 +1108,7 @@ static void qxl_exit_vga_mode(PCIQXLDevice *d)
     graphic_console_set_hwops(d->ssd.dcl.con, &qxl_ops, d);
     vga_dirty_log_stop(&d->vga);
     qxl_destroy_primary(d, QXL_SYNC);
+    update_displaystate(d->ssd.dcl.ds);
 }
 
 static void qxl_update_irq(PCIQXLDevice *d)
@@ -1868,11 +1870,23 @@ static void display_refresh(DisplayChangeListener *dcl)
     }
 }
 
+static bool display_need_refresh(DisplayChangeListener *dcl)
+{
+    PCIQXLDevice *qxl = container_of(dcl, PCIQXLDevice, ssd.dcl);
+
+    if (qxl->mode == QXL_MODE_VGA) {
+        return true;
+    }
+
+    return false;
+}
+
 static DisplayChangeListenerOps display_listener_ops = {
     .dpy_name        = "spice/qxl",
     .dpy_gfx_update  = display_update,
     .dpy_gfx_switch  = display_switch,
     .dpy_refresh     = display_refresh,
+    .dpy_need_refresh = display_need_refresh,
 };
 
 static void qxl_init_ramsize(PCIQXLDevice *qxl)
diff --git a/include/ui/console.h b/include/ui/console.h
index 22ef8ca..cd0afc5 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -152,6 +152,8 @@ void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask);
 typedef struct DisplayChangeListenerOps {
     const char *dpy_name;
 
+    bool (*dpy_need_refresh)(DisplayChangeListener *dcl);
+
     void (*dpy_refresh)(DisplayChangeListener *dcl);
 
     void (*dpy_gfx_update)(DisplayChangeListener *dcl,
@@ -185,6 +187,7 @@ struct DisplayChangeListener {
 };
 
 DisplayState *init_displaystate(void);
+void update_displaystate(DisplayState *ds);
 DisplaySurface *qemu_create_displaysurface_from(int width, int height,
                                                 pixman_format_code_t format,
                                                 int linesize, uint8_t *data);
diff --git a/ui/console.c b/ui/console.c
index 258af5d..9815667 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -180,6 +180,7 @@ static QEMUTimer *cursor_timer;
 
 static void text_console_do_init(CharDriverState *chr, DisplayState *ds);
 static void dpy_refresh(DisplayState *s);
+static bool dpy_need_refresh(DisplayState *s);
 static DisplayState *get_alloc_displaystate(void);
 static void text_console_update_cursor_timer(void);
 static void text_console_update_cursor(void *opaque);
@@ -216,7 +217,7 @@ static void gui_update(void *opaque)
     timer_mod(ds->gui_timer, ds->last_update + interval);
 }
 
-static void gui_setup_refresh(DisplayState *ds)
+void update_displaystate(DisplayState *ds)
 {
     DisplayChangeListener *dcl;
     bool need_timer = false;
@@ -235,6 +236,8 @@ static void gui_setup_refresh(DisplayState *ds)
         }
     }
 
+    need_timer &= dpy_need_refresh(ds);
+
     if (need_timer && ds->gui_timer == NULL) {
         ds->gui_timer = timer_new_ms(QEMU_CLOCK_REALTIME, gui_update, ds);
         timer_mod(ds->gui_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME));
@@ -1341,7 +1344,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
     trace_displaychangelistener_register(dcl, dcl->ops->dpy_name);
     dcl->ds = get_alloc_displaystate();
     QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next);
-    gui_setup_refresh(dcl->ds);
+    update_displaystate(dcl->ds);
     if (dcl->con) {
         dcl->con->dcls++;
         con = dcl->con;
@@ -1380,7 +1383,7 @@ void unregister_displaychangelistener(DisplayChangeListener *dcl)
         dcl->con->dcls--;
     }
     QLIST_REMOVE(dcl, next);
-    gui_setup_refresh(ds);
+    update_displaystate(ds);
 }
 
 int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info)
@@ -1450,6 +1453,20 @@ static void dpy_refresh(DisplayState *s)
     }
 }
 
+static bool dpy_need_refresh(DisplayState *s)
+{
+    DisplayChangeListener *dcl;
+
+    QLIST_FOREACH(dcl, &s->listeners, next) {
+        if (!dcl->ops->dpy_need_refresh ||
+            dcl->ops->dpy_need_refresh(dcl)) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 void dpy_gfx_copy(QemuConsole *con, int src_x, int src_y,
                   int dst_x, int dst_y, int w, int h)
 {
-- 
1.9.3

             reply	other threads:[~2014-11-04 11:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 11:23 Marc-André Lureau [this message]
2014-11-04 14:08 ` [Qemu-devel] [PATCH] console: remove refresh timer when using spice & QXL mode Gerd Hoffmann
2014-11-04 15:50   ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415100203-20405-1-git-send-email-marcandre.lureau@gmail.com \
    --to=marcandre.lureau@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).