spice: use bottom half instead of refresh timer for cursor updates
PATCH 1/2 spice: use bottom half instead of refresh timer for cursor updates
Calling directly doesn't work due to the qxl-render code running in spice server thread context. Meanwhile bottom half scheduling is thread-safe though, so we can use that to kick a cursor update in main i/o thread context.
Cc Marc-André Lureau <[email protected]>
Signed-off-by Gerd Hoffmann <[email protected]>
--- hw/display/qxl-render.c | 2 ++ hw/display/qxl.c | 5 +---- include/ui/spice-display.h | 3 ++- ui/spice-display.c | 12 ++++++++++-- 4 files changed, 15 insertions(+), 7 deletions(-)
hw/display/qxl-render.c +2 -0
@@ -283,12 +283,14 @@ int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext) qxl->ssd.mouse_x = cmd->u.set.position.x; qxl->ssd.mouse_y = cmd->u.set.position.y;qemu_mutex_unlock (&qxl->ssd.lock); +qemu_bh_schedule (qxl->ssd.cursor_bh);break ;case QXL_CURSOR_MOVE :qemu_mutex_lock (&qxl->ssd.lock); qxl->ssd.mouse_x = cmd->u.position.x; qxl->ssd.mouse_y = cmd->u.position.y;qemu_mutex_unlock (&qxl->ssd.lock); +qemu_bh_schedule (qxl->ssd.cursor_bh);break ; }return 0 ;
hw/display/qxl.c +1 -4
@@ -1861,10 +1861,6 @@ static void display_refresh(DisplayChangeListener *dcl)if (qxl->mode ==QXL_MODE_VGA ) {qemu_spice_display_refresh (&qxl->ssd); - }else { -qemu_mutex_lock (&qxl->ssd.lock); -qemu_spice_cursor_refresh_unlocked (&qxl->ssd); -qemu_mutex_unlock (&qxl->ssd.lock); } }
@@ -2025,6 +2021,7 @@ static int qxl_init_common(PCIQXLDevice *qxl)qxl_reset_state (qxl); qxl->update_area_bh =qemu_bh_new (qxl_render_update_area_bh, qxl); + qxl->ssd.cursor_bh =qemu_bh_new (qemu_spice_cursor_refresh_bh, &qxl->ssd);return 0 ; }
include/ui/spice-display.h +2 -1
@@ -102,6 +102,7 @@ struct SimpleSpiceDisplay {/* cursor (with qxl): qxl local renderer -> displaychangelistener */ QEMUCursor *cursor;int mouse_x, mouse_y; +QEMUBH *cursor_bh; };struct SimpleSpiceUpdate {
@@ -134,7 +135,7 @@ void qemu_spice_display_update(SimpleSpiceDisplay *ssd,void qemu_spice_display_switch (SimpleSpiceDisplay *ssd,DisplaySurface *surface);void qemu_spice_display_refresh (SimpleSpiceDisplay *ssd); -void qemu_spice_cursor_refresh_unlocked (SimpleSpiceDisplay *ssd); +void qemu_spice_cursor_refresh_bh (void *opaque);void qemu_spice_add_memslot (SimpleSpiceDisplay *ssd,QXLDevMemSlot *memslot,qxl_async_io async);
ui/spice-display.c +10 -2
@@ -438,7 +438,7 @@ void qemu_spice_display_switch(SimpleSpiceDisplay *ssd, ssd->notify++; } -void qemu_spice_cursor_refresh_unlocked (SimpleSpiceDisplay *ssd) +static void qemu_spice_cursor_refresh_unlocked (SimpleSpiceDisplay *ssd) {if (ssd->cursor) {assert (ssd->dcl.con);
@@ -454,6 +454,15 @@ void qemu_spice_cursor_refresh_unlocked(SimpleSpiceDisplay *ssd) } } +void qemu_spice_cursor_refresh_bh (void *opaque) +{ +SimpleSpiceDisplay *ssd = opaque; + +qemu_mutex_lock (&ssd->lock); +qemu_spice_cursor_refresh_unlocked (ssd); +qemu_mutex_unlock (&ssd->lock); +} +void qemu_spice_display_refresh (SimpleSpiceDisplay *ssd) {dprint (3 ,"%s/%d:\n" , __func__, ssd->qxl.id);
@@ -464,7 +473,6 @@ void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd)qemu_spice_create_update (ssd); ssd->notify++; } -qemu_spice_cursor_refresh_unlocked (ssd);qemu_mutex_unlock (&ssd->lock);if (ssd->notify) {
Signature · 1 line
1.8.3.1
PATCH 2/2 spice: reduce refresh rate in native mode
Now that cursor updates are out of the way qxl needs the refresh timer only when when running in vga mode, for dirty bitmap checking. In native qxl mode the guest will notify us, so we don't need to poll and can use the idle interval (one refresh wakeup every few seconds).
Cc Marc-André Lureau <[email protected]>
Signed-off-by Gerd Hoffmann <[email protected]>
--- hw/display/qxl.c | 3 +++ 1 file changed, 3 insertions(+)
hw/display/qxl.c +3 -0
@@ -1092,6 +1092,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)spice_qxl_driver_unload (&d->ssd.qxl);#endif graphic_console_set_hwops (d->ssd.dcl.con, d->vga.hw_ops, &d->vga); +update_displaychangelistener (&d->ssd.dcl,GUI_REFRESH_INTERVAL_DEFAULT );qemu_spice_create_host_primary (&d->ssd); d->mode =QXL_MODE_VGA ;vga_dirty_log_start (&d->vga);
@@ -1105,6 +1106,7 @@ static void qxl_exit_vga_mode(PCIQXLDevice *d) }trace_qxl_exit_vga_mode (d->id);graphic_console_set_hwops (d->ssd.dcl.con, &qxl_ops, d); +update_displaychangelistener (&d->ssd.dcl,GUI_REFRESH_INTERVAL_IDLE );vga_dirty_log_stop (&d->vga);qxl_destroy_primary (d,QXL_SYNC ); }
@@ -1153,6 +1155,7 @@ static void qxl_soft_reset(PCIQXLDevice *d)qxl_enter_vga_mode (d); }else { d->mode =QXL_MODE_UNDEFINED ; +update_displaychangelistener (&d->ssd.dcl,GUI_REFRESH_INTERVAL_IDLE ); } }
Signature · 1 line
1.8.3.1