qxl S3&S4 (suspend and hibernate) support
PATCH v3 1/1 qxl S3&S4 (suspend and hibernate) support
Based on Gerd's tree:
git://anongit.freedesktop.org/spice/qemu bz700134^
(i.e. without the last patch for latency measurement marked [debug])
Changes from v2:
1: patch uses V10 instead of 3.
2: handle EAGAIN/EINTR
3: fixes a deadlock because of usage of wlock for surface tracking. 4..end-2: The same as v2, but drop patch introducing primary_created.
end-1: Instead of adding a new primary_created tracking driver state, just
change to UNDEFINED when doing DESTROY_ALL_SURFACES.
end: allow io in UNDEFINED
Alon Levy (14):
async io: suggested fixes
async thread fix - handle EAGAIN/EINTR, remove fprintf
qxl: use track_lock instead of wlock for guest_surfaces
qxl: add mode to debugprint on destroy primary
qxl: allow QXL_IO_LOG also in vga
qxl: abort on panic instead of exit
qxl-logger: add timestamp to command log
qxl: update and add debug prints
qxl: add dev id to guest prints
qxl: add io_port_to_string
qxl: update revision to QXL_REVISION_STABLE_V10
qxl: add QXL_IO_FLUSH_{SURFACES,RELEASE} for guest S3&S4 support
qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{,_ASYNC}
qxl: only disallow specific io's in vga mode
hw/qxl-logger.c | 4 +- hw/qxl.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++-------- hw/qxl.h | 4 +- 3 files changed, 129 insertions(+), 22 deletions(-)
Signature · 1 line
1.7.5.4
PATCH v3 1/1 async io: suggested fixes
--- hw/qxl.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
hw/qxl.c +3 -2
@@ -1178,6 +1178,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)case QXL_IO_MEMSLOT_ADD_ASYNC :PANIC_ON (val >=NUM_MEMSLOTS );PANIC_ON (d->guest_slots[val].active); +dprint (d,1 ,"QXL_IO_MEMSLOT_ADD_ASYNC %d\n" , val); d->guest_slots[val].slot = d->ram->mem_slot; async =qemu_mallocz (sizeof (*async));qxl_add_memslot (d, val,0 , &async->memslot);
@@ -1715,7 +1716,7 @@ static PCIDeviceInfo qxl_info_primary = { .qdev.props = (Property[]) {DEFINE_PROP_UINT32 ("ram_size" , PCIQXLDevice, vga.vram_size,64 *1024 *1024 ),DEFINE_PROP_UINT32 ("vram_size" , PCIQXLDevice, vram_size,64 *1024 *1024 ), -DEFINE_PROP_UINT32 ("revision" , PCIQXLDevice, revision,3 ), +DEFINE_PROP_UINT32 ("revision" , PCIQXLDevice, revision,QXL_REVISION_STABLE_V10 ),DEFINE_PROP_UINT32 ("debug" , PCIQXLDevice, debug,0 ),DEFINE_PROP_UINT32 ("guestdebug" , PCIQXLDevice, guestdebug,0 ),DEFINE_PROP_UINT32 ("cmdlog" , PCIQXLDevice, cmdlog,0 ),
@@ -1735,7 +1736,7 @@ static PCIDeviceInfo qxl_info_secondary = { .qdev.props = (Property[]) {DEFINE_PROP_UINT32 ("ram_size" , PCIQXLDevice, vga.vram_size,64 *1024 *1024 ),DEFINE_PROP_UINT32 ("vram_size" , PCIQXLDevice, vram_size,64 *1024 *1024 ), -DEFINE_PROP_UINT32 ("revision" , PCIQXLDevice, revision,3 ), +DEFINE_PROP_UINT32 ("revision" , PCIQXLDevice, revision,QXL_REVISION_STABLE_V10 ),DEFINE_PROP_UINT32 ("debug" , PCIQXLDevice, debug,0 ),DEFINE_PROP_UINT32 ("guestdebug" , PCIQXLDevice, guestdebug,0 ),DEFINE_PROP_UINT32 ("cmdlog" , PCIQXLDevice, cmdlog,0 ),
Signature · 1 line
1.7.5.4
PATCH v3 1/1 async thread fix - handle EAGAIN/EINTR, remove fprintf
In reply to Alon Levy--- hw/qxl.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/qxl.c +3 -1
@@ -1025,13 +1025,15 @@ static void *ioport_write_async(void *arg)while (true) { ret =read (d->aio_pipe[0 ], &io,sizeof (io)); +if (ret <0 && (errno ==EAGAIN || errno ==EINTR )) { +continue ; + }if (ret !=sizeof (io)) {break ; } io_port = io->port; val = io->val; -fprintf (stderr,"%s: 0x%x\n" , __FUNCTION__, io_port);switch (io_port) {case QXL_IO_UPDATE_AREA_ASYNC : qxl_spice_update_area(d, io->update_surface,
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: use track_lock instead of wlock for guest_surfaces
In reply to Alon Levy--- hw/qxl.c | 7 +++++-- hw/qxl.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-)
hw/qxl.c +5 -2
@@ -150,10 +150,12 @@ void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,void qxl_spice_destroy_surface_wait (PCIQXLDevice *qxl,uint32_t id) {qemu_mutex_lock (&qxl->ssd.wlock); +qemu_mutex_lock (&qxl->track_lock);PANIC_ON (id >=NUM_SURFACES ); qxl->ssd.worker->destroy_surface_wait (qxl->ssd.worker, id); qxl->guest_surfaces.cmds[id] =0 ; qxl->guest_surfaces.count--; +qemu_mutex_unlock (&qxl->track_lock);qemu_mutex_unlock (&qxl->ssd.wlock); }
@@ -348,7 +350,7 @@ static void qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)QXLSurfaceCmd *cmd =qxl_phys2virt (qxl, ext->cmd.data, ext->group_id);uint32_t id =le32_to_cpu (cmd->surface_id);PANIC_ON (id >=NUM_SURFACES ); -qemu_mutex_lock (&qxl->ssd.wlock); +qemu_mutex_lock (&qxl->track_lock);if (cmd->type ==QXL_SURFACE_CMD_CREATE ) { qxl->guest_surfaces.cmds[id] = ext->cmd.data; qxl->guest_surfaces.count++;
@@ -359,7 +361,7 @@ static void qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext) qxl->guest_surfaces.cmds[id] =0 ; qxl->guest_surfaces.count--; } -qemu_mutex_unlock (&qxl->ssd.wlock); +qemu_mutex_unlock (&qxl->track_lock);break ; }case QXL_CMD_CURSOR :
@@ -1432,6 +1434,7 @@ static int qxl_init_common(PCIQXLDevice *qxl) qxl->generation =1 ; qxl->num_memslots =NUM_MEMSLOTS ; qxl->num_surfaces =NUM_SURFACES ; +qemu_mutex_init (&qxl->track_lock);switch (qxl->revision) {case 1 :/* spice 0.4 -- qxl-1 */
hw/qxl.h +2 -0
@@ -58,6 +58,8 @@ typedef struct PCIQXLDevice { } guest_surfaces;QXLPHYSICAL guest_cursor; +QemuMutex track_lock; +/* thread signaling */ pthread_t main;int pipe[2 ];
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: add mode to debugprint on destroy primary
In reply to Alon Levy--- hw/qxl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/qxl.c +1 -1
@@ -1167,7 +1167,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val) }case QXL_IO_DESTROY_PRIMARY :PANIC_ON (val !=0 ); -dprint (d,1 ,"QXL_IO_DESTROY_PRIMARY\n" ); +dprint (d,1 ,"QXL_IO_DESTROY_PRIMARY (%s)\n" ,qxl_mode_to_string (d->mode));if (d->mode !=QXL_MODE_UNDEFINED ) { d->mode =QXL_MODE_UNDEFINED ;qemu_spice_destroy_primary_surface (&d->ssd,0 );
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: allow QXL_IO_LOG also in vga
In reply to Alon LevyThe driver may change us to vga mode and still issue a QXL_IO_LOG, which we can easily support.
--- hw/qxl.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
hw/qxl.c +1 -0
@@ -1085,6 +1085,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)case QXL_IO_CREATE_PRIMARY :case QXL_IO_CREATE_PRIMARY_ASYNC :case QXL_IO_UPDATE_IRQ : +case QXL_IO_LOG :break ;default :if (d->mode ==QXL_MODE_NATIVE || d->mode ==QXL_MODE_COMPAT )
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: abort on panic instead of exit
In reply to Alon Levy--- hw/qxl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/qxl.h +1 -1
@@ -89,7 +89,7 @@ typedef struct PCIQXLDevice {#define PANIC_ON (x) if ((x)) { \ printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \ - exit(-1); \ + abort(); \ }#define dprint (_qxl, _level, _fmt, ...) \
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl-logger: add timestamp to command log
In reply to Alon Levy--- hw/qxl-logger.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/qxl-logger.c +3 -1
@@ -19,6 +19,7 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ +#include "qemu-timer.h" #include "qxl.h" static const char *qxl_type[] = {
@@ -223,7 +224,8 @@ void qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext)if (!qxl->cmdlog) {return ; } -fprintf (stderr,"qxl-%d/%s:" , qxl->id, ring); +fprintf (stderr,"%ld qxl-%d/%s:" ,qemu_get_clock_ns (vm_clock), + qxl->id, ring);fprintf (stderr," cmd @ 0x%" PRIx64" %s%s" , ext->cmd.data,qxl_name (qxl_type, ext->cmd.type), compat ?"(compat)" :"" );
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: update and add debug prints
In reply to Alon Levy--- hw/qxl.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
hw/qxl.c +7 -3
@@ -444,7 +444,7 @@ static int interface_get_command(QXLInstance *sin, struct QXLCommandExt *ext)switch (qxl->mode) {case QXL_MODE_VGA : -dprint (qxl,2 ,"%s: vga\n" , __FUNCTION__); +dprint (qxl,4 ,"%s: vga\n" , __FUNCTION__); ret = false;qemu_mutex_lock (&qxl->ssd.lock);if (qxl->ssd.update !=NULL ) {
@@ -783,7 +783,8 @@ static void qxl_hard_reset(PCIQXLDevice *d, int loadvm)qemu_spice_create_host_memslot (&d->ssd);qxl_soft_reset (d); -dprint (d,1 ,"%s: done\n" , __FUNCTION__); +dprint (d,1 ,"%s: done (num_free_res %d, %p)\n" , __FUNCTION__, + d->num_free_res, d->last_release); }static void qxl_reset_handler (DeviceState *dev)
@@ -1122,6 +1123,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val) }pthread_yield ();if (!SPICE_RING_IS_EMPTY (&d->ram->release_ring)) { +dprint (d,1 ,"QXL_IO_NOTIFY_OOM (return after pthread_yield)\n" );break ; } d->oom_running =1 ;
@@ -1138,7 +1140,8 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val) }break ;case QXL_IO_RESET : -dprint (d,1 ,"QXL_IO_RESET\n" ); +dprint (d,1 ,"QXL_IO_RESET %d (%p)\n" , d->num_free_res, + d->last_release);qxl_hard_reset (d,0 );break ;case QXL_IO_MEMSLOT_ADD :
@@ -1153,6 +1156,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)break ; }case QXL_IO_MEMSLOT_DEL : +dprint (d,1 ,"QXL_IO_MEMSLOT_DEL %d\n" , val);qxl_del_memslot (d, val);break ;case QXL_IO_CREATE_PRIMARY :
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: add dev id to guest prints
In reply to Alon Levy--- hw/qxl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
hw/qxl.c +2 -1
@@ -1136,7 +1136,8 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)break ;case QXL_IO_LOG :if (d->guestdebug) { -fprintf (stderr,"qxl/guest: %s" , d->ram->log_buf); +fprintf (stderr,"qxl/guest-%d: %ld: %s" , d->id, +qemu_get_clock_ns (vm_clock), d->ram->log_buf); }break ;case QXL_IO_RESET :
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: add io_port_to_string
In reply to Alon Levy--- hw/qxl.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 63 insertions(+), 1 deletions(-)
hw/qxl.c +63 -1
@@ -433,6 +433,67 @@ static const char *qxl_mode_to_string(int mode)return "INVALID" ; } +static const char *io_port_to_string (uint32_t io_port) +{ +if (io_port >=QXL_IO_RANGE_SIZE ) { +return "out of range" ; + } +switch (io_port) { +case QXL_IO_NOTIFY_CMD : +return "QXL_IO_NOTIFY_CMD" ; +case QXL_IO_NOTIFY_CURSOR : +return "QXL_IO_NOTIFY_CURSOR" ; +case QXL_IO_UPDATE_AREA : +return "QXL_IO_UPDATE_AREA" ; +case QXL_IO_UPDATE_IRQ : +return "QXL_IO_UPDATE_IRQ" ; +case QXL_IO_NOTIFY_OOM : +return "QXL_IO_NOTIFY_OOM" ; +case QXL_IO_RESET : +return "QXL_IO_RESET" ; +case QXL_IO_SET_MODE : +return "QXL_IO_SET_MODE" ; +case QXL_IO_LOG : +return "QXL_IO_LOG" ; +case QXL_IO_MEMSLOT_ADD : +return "QXL_IO_MEMSLOT_ADD" ; +case QXL_IO_MEMSLOT_DEL : +return "QXL_IO_MEMSLOT_DEL" ; +case QXL_IO_DETACH_PRIMARY : +return "QXL_IO_DETACH_PRIMARY" ; +case QXL_IO_ATTACH_PRIMARY : +return "QXL_IO_ATTACH_PRIMARY" ; +case QXL_IO_CREATE_PRIMARY : +return "QXL_IO_CREATE_PRIMARY" ; +case QXL_IO_DESTROY_PRIMARY : +return "QXL_IO_DESTROY_PRIMARY" ; +case QXL_IO_DESTROY_SURFACE_WAIT : +return "QXL_IO_DESTROY_SURFACE_WAIT" ; +case QXL_IO_DESTROY_ALL_SURFACES : +return "QXL_IO_DESTROY_ALL_SURFACES" ; +case QXL_IO_UPDATE_AREA_ASYNC : +return "QXL_IO_UPDATE_AREA_ASYNC" ; +case QXL_IO_NOTIFY_OOM_ASYNC : +return "QXL_IO_NOTIFY_OOM_ASYNC" ; +case QXL_IO_MEMSLOT_ADD_ASYNC : +return "QXL_IO_MEMSLOT_ADD_ASYNC" ; +case QXL_IO_CREATE_PRIMARY_ASYNC : +return "QXL_IO_CREATE_PRIMARY_ASYNC" ; +case QXL_IO_DESTROY_PRIMARY_ASYNC : +return "QXL_IO_DESTROY_PRIMARY_ASYNC" ; +case QXL_IO_DESTROY_SURFACE_ASYNC : +return "QXL_IO_DESTROY_SURFACE_ASYNC" ; +case QXL_IO_DESTROY_ALL_SURFACES_ASYNC : +return "QXL_IO_DESTROY_ALL_SURFACES_ASYNC" ; +case QXL_IO_FLUSH_SURFACES : +return "QXL_IO_FLUSH_SURFACES" ; +case QXL_IO_FLUSH_RELEASE : +return "QXL_IO_FLUSH_RELEASE" ; + } +// not reached? +return "error in io_port_to_string" ; +} +/* called from spice server thread context only */ static int interface_get_command (QXLInstance *sin,struct QXLCommandExt *ext) {
@@ -1091,7 +1152,8 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)default :if (d->mode ==QXL_MODE_NATIVE || d->mode ==QXL_MODE_COMPAT )break ; -dprint (d,1 ,"%s: unexpected port 0x%x in vga mode\n" , __FUNCTION__, io_port); +dprint (d,1 ,"%s: unexpected port 0x%x (%s) in vga mode\n" , + __FUNCTION__, io_port,io_port_to_string (io_port));/* be nice to buggy guest drivers */ if (io_port >=QXL_IO_UPDATE_AREA_ASYNC && io_port <=QXL_IO_DESTROY_ALL_SURFACES_ASYNC ) {
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: update revision to QXL_REVISION_STABLE_V10
In reply to Alon Levyalso errors if provided revision is wrong. 0 is reserved for experimental revision, the other valid values are as before:
1 - V04
2 - V06
And the new
3 - V10
--- hw/qxl.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-)
hw/qxl.c +9 -7
@@ -1494,8 +1494,8 @@ static DisplayChangeListener display_listener = {static int qxl_init_common (PCIQXLDevice *qxl) {uint8_t * config = qxl->pci.config; -uint32_t pci_device_id; -uint32_t pci_device_rev; +uint32_t pci_device_id =0 ; +uint32_t pci_device_rev =0 ;uint32_t io_size; qxl->mode =QXL_MODE_UNDEFINED ;
@@ -1505,22 +1505,24 @@ static int qxl_init_common(PCIQXLDevice *qxl)qemu_mutex_init (&qxl->track_lock);switch (qxl->revision) { -case 1 :/* spice 0.4 -- qxl-1 */ +case QXL_REVISION_STABLE_V04 :/* spice 0.4 -- qxl-1 */ pci_device_id =QXL_DEVICE_ID_STABLE ; pci_device_rev =QXL_REVISION_STABLE_V04 ;break ; -case 2 :/* spice 0.6 -- qxl-2 */ +case QXL_REVISION_STABLE_V06 :/* spice 0.6 -- qxl-2 */ pci_device_id =QXL_DEVICE_ID_STABLE ; pci_device_rev =QXL_REVISION_STABLE_V06 ;break ; -case 3 :/* qxl-3 */ +case QXL_REVISION_STABLE_V10 :/* spice 0.10 -- qxl-3 */ pci_device_id =QXL_DEVICE_ID_STABLE ; - pci_device_rev =3 ; + pci_device_rev =QXL_REVISION_STABLE_V10 ;break ; -default :/* experimental */ +case 0 :/* experimental */ pci_device_id =QXL_DEVICE_ID_DEVEL ; pci_device_rev =1 ;break ; +default : +error_report ("bad revision paramter" ); }pci_config_set_device_id (config, pci_device_id);
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: add QXL_IO_FLUSH_{SURFACES, RELEASE} for guest S3&S4 support
In reply to Alon LevyAdd two new IOs.
QXL_IO_FLUSH_SURFACES - equivalent to update area for all surfaces, used
to reduce vmexits from NumSurfaces to 1 on guest S3, S4 and resolution change (windows driver implementation is such that this is done on each of those occasions).
QXL_IO_FLUSH_RELEASE - used to ensure anything on last_release is put on the release ring
for the client to free.
--- hw/qxl.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
hw/qxl.c +24 -0
@@ -1247,6 +1247,30 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)case QXL_IO_DESTROY_ALL_SURFACES :qxl_spice_destroy_surfaces (d);break ; +case QXL_IO_FLUSH_SURFACES : +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES (%d) entry (%s, s#=%d, res#=%d)\n" , + val,qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res); +qemu_spice_stop (&d->ssd); +qemu_spice_start (&d->ssd); +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES exit (%s, s#=%d, res#=%d,%p)\n" , +qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res, d->last_release); +break ; +case QXL_IO_FLUSH_RELEASE : { +QXLReleaseRing *ring = &d->ram->release_ring; +if (ring->prod - ring->cons +1 == ring->num_items) { +// TODO - "return" a value to the guest and let it loop? +fprintf (stderr, +"ERROR: no flush, full release ring [p%d,%dc]\n" , + ring->prod, ring->cons); + } +qxl_push_free_res (d,1 /* flush */ ); +dprint (d,1 ,"QXL_IO_FLUSH_RELEASE exit (%s, s#=%d, res#=%d,%p)\n" , +qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res, d->last_release); +break ; + }case QXL_IO_MEMSLOT_ADD_ASYNC :PANIC_ON (val >=NUM_MEMSLOTS );PANIC_ON (d->guest_slots[val].active);
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{, _ASYNC}
In reply to Alon Levy--- hw/qxl.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
hw/qxl.c +3 -1
@@ -1245,6 +1245,7 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)qxl_spice_destroy_surface_wait (d, val);break ;case QXL_IO_DESTROY_ALL_SURFACES : + d->mode =QXL_MODE_UNDEFINED ;qxl_spice_destroy_surfaces (d);break ;case QXL_IO_FLUSH_SURFACES :
@@ -1302,9 +1303,10 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val) async->update_area = d->ram->update_area; async->update_surface = d->ram->update_surface; goto async_common; +case QXL_IO_DESTROY_ALL_SURFACES_ASYNC : + d->mode =QXL_MODE_UNDEFINED ;case QXL_IO_NOTIFY_OOM_ASYNC :case QXL_IO_DESTROY_SURFACE_ASYNC : -case QXL_IO_DESTROY_ALL_SURFACES_ASYNC : async =qemu_mallocz (sizeof (*async)); async_common: async->port = io_port;
Signature · 1 line
1.7.5.4
PATCH v3 1/1 qxl: only disallow specific io's in vga mode
In reply to Alon LevySince the driver is still operation also after moving to UNDEFINED, i.e. by destroying primary in any way.
--- hw/qxl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
hw/qxl.c +2 -1
@@ -1150,8 +1150,9 @@ static void ioport_write(void *opaque, uint32_t addr, uint32_t val)case QXL_IO_LOG :break ;default : -if (d->mode ==QXL_MODE_NATIVE || d->mode ==QXL_MODE_COMPAT ) +if (d->mode !=QXL_MODE_VGA ) {break ; + }dprint (d,1 ,"%s: unexpected port 0x%x (%s) in vga mode\n" , __FUNCTION__, io_port,io_port_to_string (io_port));/* be nice to buggy guest drivers */
Signature · 1 line
1.7.5.4
PATCH v3 1/1 (alon-local) symlink bios out of tree
In reply to Alon Levy--- pc-bios/bios.bin | Bin 131072 -> 26 bytes pc-bios/vgabios-qxl.bin | Bin 40448 -> 41 bytes 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 120000 pc-bios/bios.bin mode change 100644 => 120000 pc-bios/vgabios-qxl.bin
pc-bios/bios.bin deleted binary +0 -0
pc-bios/bios.bin new file +1 -0
@@ -0,0 +1 @@ +../../seabios/out/bios.bin
pc-bios/vgabios-qxl.bin deleted binary +0 -0
pc-bios/vgabios-qxl.bin new file +1 -0
@@ -0,0 +1 @@ +../../vgabios/VGABIOS-lgpl-latest.qxl.bin
Signature · 1 line
1.7.5.4
Re: [Qemu-devel] [PATCHv3] qxl: abort on panic instead of exit
In reply to Alon LevyQuoted 9 lines · Alon Levy
--- hw/qxl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/qxl.h +0
-0
hw/qxl.h typedef struct PCIQXLDevice { · line 93
Quoted 6 lines
hw/qxl.h +1
-1@@ -89,7 +89,7 @@ typedef struct PCIQXLDevice {#define PANIC_ON (x) if ((x)) { \ printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \ - exit(-1); \ + abort(); \ }
Not urgent, but I think this should change. A bunch of the PANIC_ON checks are guest-triggerable. Long-term I want invalid requests from the guest just be ignored by default. Keeping an option to do something else is fine (log a message, abort, write out guest dump, whatever), I see that this can be quite useful for guest driver debugging.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: update and add debug prints
In reply to Alon LevyHi,
hw/qxl.c static void qxl_hard_reset(PCIQXLDevice *d, int loadvm)
Quoted 8 lines
hw/qxl.c +4
-2-dprint (d,1 ,"%s: done\n" , __FUNCTION__); +dprint (d,1 ,"%s: done (num_free_res %d, %p)\n" , __FUNCTION__, + d->num_free_res, d->last_release);case QXL_IO_RESET : -dprint (d,1 ,"QXL_IO_RESET\n" ); +dprint (d,1 ,"QXL_IO_RESET %d (%p)\n" , d->num_free_res, + d->last_release);
Hmm, this looks pretty much like something added to debug a specific issue, not something useful for tracing in general ...
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add io_port_to_string
In reply to Alon LevyHi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1156
Quoted 3 lines
hw/qxl.c +2
-1-dprint (d,1 ,"%s: unexpected port 0x%x in vga mode\n" , __FUNCTION__, io_port); +dprint (d,1 ,"%s: unexpected port 0x%x (%s) in vga mode\n" , + __FUNCTION__, io_port,io_port_to_string (io_port));
Is this worth it? Should be a quite rare event ...
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add QXL_IO_FLUSH_{SURFACES, RELEASE} for guest S3&S4 support
In reply to Alon LevyHi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1259
Quoted 10 lines
hw/qxl.c +10
-0+case QXL_IO_FLUSH_SURFACES : +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES (%d) entry (%s, s#=%d, res#=%d)\n" , + val,qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res); +qemu_spice_stop (&d->ssd); +qemu_spice_start (&d->ssd); +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES exit (%s, s#=%d, res#=%d,%p)\n" , +qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res, d->last_release); +break ;
This should be async as we'll go sleep and wait for the spice server thread finish in qemu_spice_stop().
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1263
Quoted 4 lines
hw/qxl.c +4
-0+case QXL_IO_FLUSH_RELEASE : { +QXLReleaseRing *ring =&d->ram->release_ring; +if (ring->prod - ring->cons +1 == ring->num_items) { +// TODO - "return" a value to the guest and let it loop?
^^^^
Hmm.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{, _ASYNC}
In reply to Alon LevyHi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1307
Quoted 2 lines
hw/qxl.c +2
-0+case QXL_IO_DESTROY_ALL_SURFACES_ASYNC : + d->mode =QXL_MODE_UNDEFINED ;
Should go to the async thread.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] (alon-local) symlink bios out of tree
In reply to Alon LevyQuoted 6 lines · Alon Levy
--- pc-bios/bios.bin | Bin 131072 -> 26 bytes pc-bios/vgabios-qxl.bin | Bin 40448 -> 41 bytes 2 files changed, 0 insertions(+), 0 deletions(-)mode change 100644 => 120000 pc-bios/bios.bin mode change 100644 => 120000 pc-bios/vgabios-qxl.bin
That wasn't intentional, was it?
/me cherry-picked a bunch of patches, I'll go push an updated tree shortly.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: abort on panic instead of exit
In reply to Gerd HoffmannQuoted 11 lines · Gerd Hoffmann
Quoted 10 lines · Alon Levy
--- hw/qxl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)hw/qxl.h +0
-0@@ -89,7 +89,7 @@ typedef struct PCIQXLDevice {
Quoted 12 lines
hw/qxl.h typedef struct PCIQXLDevice { · line 93
Quoted 5 lines
hw/qxl.h +1
-1#define PANIC_ON (x) if ((x)) { \ printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \ - exit(-1); \ + abort(); \ }Not urgent, but I think this should change. A bunch of the
PANIC_ONchecks are guest-triggerable. Long-term I want invalid requests from the guest just be ignored by default. Keeping an option to do something else is fine (log a message, abort, write out guest dump, whatever), I see that this can be quite useful for guest driver debugging.
Agreed. So keep PANIC_ON but remove a lot of it's users, or add some wrapper that depends on a "guest_panic" parameter that defaults off.
Quoted 3 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: update and add debug prints
In reply to Gerd HoffmannQuoted 6 lines · Gerd Hoffmann
Hi,
Quoted 3 lines
hw/qxl.c +2
-1-dprint (d,1 ,"%s: done\n" , __FUNCTION__); +dprint (d,1 ,"%s: done (num_free_res %d, %p)\n" , __FUNCTION__, + d->num_free_res, d->last_release);
Quoted 7 lines
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1144
Quoted 4 lines
case
QXL_IO_RESET:hw/qxl.c +2
-1-dprint (d,1 ,"QXL_IO_RESET\n" ); +dprint (d,1 ,"QXL_IO_RESET %d (%p)\n" , d->num_free_res, + d->last_release);Hmm, this looks pretty much like something added to debug a specific issue, not something useful for tracing in general ...
ok. can you just drop it from the queue so I can avoid sending a v4?
Quoted 4 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add io_port_to_string
In reply to Gerd HoffmannQuoted 7 lines · Gerd Hoffmann
Hi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1156
Quoted 3 lines
hw/qxl.c +2
-1-dprint (d,1 ,"%s: unexpected port 0x%x in vga mode\n" , __FUNCTION__, io_port); +dprint (d,1 ,"%s: unexpected port 0x%x (%s) in vga mode\n" , + __FUNCTION__, io_port,io_port_to_string (io_port));Is this worth it? Should be a quite rare event ...
well, it's helpful for debugging, so I don't see why not. The extra code is not that large, and it's already written :)
Quoted 4 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add QXL_IO_FLUSH_{SURFACES, RELEASE} for guest S3&S4 support
In reply to Gerd HoffmannQuoted 13 lines · Gerd Hoffmann
Hi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1259
Quoted 10 lines
hw/qxl.c +10
-0+case QXL_IO_FLUSH_SURFACES : +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES (%d) entry (%s, s#=%d, res#=%d)\n" , + val,qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res); +qemu_spice_stop (&d->ssd); +qemu_spice_start (&d->ssd); +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES exit (%s, s#=%d, res#=%d,%p)\n" , +qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res, d->last_release); +break ;
Quoted 2 lines
This should be async as we'll go sleep and wait for the spice server thread finish in
qemu_spice_stop().
Yeah, I meant to do that, forgot, thanks for catching it.
Quoted 7 lines
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1263
Quoted 5 lines
hw/qxl.c +4
-0+case QXL_IO_FLUSH_RELEASE : { +QXLReleaseRing *ring =&d->ram->release_ring; +if (ring->prod - ring->cons +1 == ring->num_items) { +// TODO - "return" a value to the guest and let it loop? ^^^^Hmm.
So the story goes: I wrote this, but didn't actually see this happen in practice, particularily since the driver empties the release ring. The simplest would be to replace it with some fprintf(stderr)
Quoted 3 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{, _ASYNC}
In reply to Gerd HoffmannQuoted 6 lines · Gerd Hoffmann
Hi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1307
Quoted 2 lines
hw/qxl.c +2
-0+case QXL_IO_DESTROY_ALL_SURFACES_ASYNC : + d->mode =QXL_MODE_UNDEFINED ;Should go to the async thread.
doesn't it make more sense to do all state changes from the vcpu thread? async thread can run much later, if you have a QXL_IO_DESTROY_ALL_SURFACES_ASYNC followed by a QXL_IO_CREATE_PRIMARY_ASYNC where the driver did not wait for the completion of the ASYNC first, I would still like to support that, but it won't work if I move this to the async thread.
Quoted 3 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] (alon-local) symlink bios out of tree
In reply to Gerd HoffmannQuoted 10 lines · Gerd Hoffmann
Quoted 6 lines · Alon Levy
--- pc-bios/bios.bin | Bin 131072 -> 26 bytes pc-bios/vgabios-qxl.bin | Bin 40448 -> 41 bytes 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 120000 pc-bios/bios.bin mode change 100644 => 120000 pc-bios/vgabios-qxl.binThat wasn't intentional, was it?
No, I forgot to delete the file and did email *..
Quoted 1 line
/me cherry-picked a bunch of patches, I'll go push an updated tree shortly.
ok - so I guess I'll wait for that and then send the S3-S4 using ASYNC for the FLUSH_SURFACES patch separately. (I guess I'll call it FLUSH_SURFACES_ASYNC and FLUSH_RELEASE_ASYNC? or just the former ASYNC?
Quoted 4 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: abort on panic instead of exit
In reply to Alon LevyHi,
Quoted 2 lines
Agreed. So keep
PANIC_ONbut remove a lot of it's users, or add some wrapper that depends on a "guest_panic" parameter that defaults off.
Maybe keep PANIC_ON in case there are any which can trigger on qemu bugs only. Add a new one where the name makes clear this triggers on case the guest driver does something wrong, maybe qxl_guest_bug() or so. Note this isn't a simple search/replace as qemu continues execution, but still has to ignore the invalid request from the guest (and maybe raise an error irq)?
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: update and add debug prints
In reply to Alon LevyHi,
Quoted 4 lines
Quoted 2 lines
Hmm, this looks pretty much like something added to debug a specific issue, not something useful for tracing in general ...
ok. can you just drop it from the queue so I can avoid sending a v4?
Pushed a new bz700134 branch version with bits cherry-picked, just resend anything which isn't there yet, not the whole series.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add QXL_IO_FLUSH_{SURFACES, RELEASE} for guest S3&S4 support
In reply to Gerd HoffmannQuoted 13 lines · Gerd Hoffmann
Hi,
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1259
Quoted 10 lines
hw/qxl.c +10
-0+case QXL_IO_FLUSH_SURFACES : +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES (%d) entry (%s, s#=%d, res#=%d)\n" , + val,qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res); +qemu_spice_stop (&d->ssd); +qemu_spice_start (&d->ssd); +dprint (d,1 ,"QXL_IO_FLUSH_SURFACES exit (%s, s#=%d, res#=%d,%p)\n" , +qxl_mode_to_string (d->mode), d->guest_surfaces.count, + d->num_free_res, d->last_release); +break ;
Quoted 2 lines
This should be async as we'll go sleep and wait for the spice server thread finish in
qemu_spice_stop().
ok, so don't cherry-pick the ioport_to_string patch yet since I'm doing s/FLUSH_SURFACES/FLUSH_SURFACES_ASYNC/
Quoted 11 lines
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1263
Quoted 5 lines
hw/qxl.c +4
-0+case QXL_IO_FLUSH_RELEASE : { +QXLReleaseRing *ring =&d->ram->release_ring; +if (ring->prod - ring->cons +1 == ring->num_items) { +// TODO - "return" a value to the guest and let it loop? ^^^^Hmm.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add QXL_IO_FLUSH_{SURFACES, RELEASE} for guest S3&S4 support
In reply to Alon LevyQuoted 9 lines
Quoted 6 lines
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1263
Quoted 4 lines
hw/qxl.c +4
-0+case QXL_IO_FLUSH_RELEASE : { +QXLReleaseRing *ring =&d->ram->release_ring; +if (ring->prod - ring->cons +1 == ring->num_items) { +// TODO - "return" a value to the guest and let it loop? ^^^^Hmm.
So the story goes: I wrote this, but didn't actually see this happen in practice, particularily since the driver empties the release ring. The simplest would be to replace it with some fprintf(stderr)
How do you think this could happen? If there are no unprocessed requests in the pipeline (shouldn't be, all surfaces are flushed to device memory and destroyedv at that point) and the driver cares empty the release ring before calling this it should not happen, right?
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{, _ASYNC}
In reply to Alon LevyQuoted 6 lines · Alon Levy
Quoted 5 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
+ case
QXL_IO_DESTROY_ALL_SURFACES_ASYNC: +d->mode=QXL_MODE_UNDEFINED;
Quoted 8 lines
Quoted 1 line
Should go to the async thread.
doesn't it make more sense to do all state changes from the vcpu thread? async thread can run much later, if you have a
QXL_IO_DESTROY_ALL_SURFACES_ASYNCfollowed by aQXL_IO_CREATE_PRIMARY_ASYNCwhere the driver did not wait for the completion of the ASYNC first, I would still like to support that, but it won't work if I move this to the async thread.
I think we should disallow doing any I/O ops while one is in progress (except maybe QXL_IO_LOG). Most I/O commands are I/O commands because they either needed for device setup or must be synchronous anyway.
QXL_IO_CREATE_PRIMARY_ASYNC wasn't exactly clever designed I think. Would have been better to enter native mode with another I/O command, then send the create request for the primary through the rings like all other surface commands. But given it is a rare event it isn't that a big issue either.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] (alon-local) symlink bios out of tree
In reply to Alon LevyHi,
Quoted 3 lines
ok - so I guess I'll wait for that and then send the S3-S4 using ASYNC for the
FLUSH_SURFACESpatch separately. (I guess I'll call itFLUSH_SURFACES_ASYNCandFLUSH_RELEASE_ASYNC? or just the former ASYNC?
Just the surfaces. The release one doesn't go sleep.
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: add QXL_IO_FLUSH_{SURFACES, RELEASE} for guest S3&S4 support
In reply to Gerd HoffmannQuoted 10 lines · Gerd Hoffmann
Quoted 9 lines
Quoted 6 lines
hw/qxl.c static void ioport_write(void *opaque, uint32_t addr, uint32_t val) · line 1263
Quoted 4 lines
hw/qxl.c +4
-0+case QXL_IO_FLUSH_RELEASE : { +QXLReleaseRing *ring =&d->ram->release_ring; +if (ring->prod - ring->cons +1 == ring->num_items) { +// TODO - "return" a value to the guest and let it loop? ^^^^Hmm.
So the story goes: I wrote this, but didn't actually see this happen in practice, particularily since the driver empties the release ring. The simplest would be to replace it with some fprintf(stderr)
Quoted 5 lines
How do you think this could happen? If there are no unprocessed requests in the pipeline (shouldn't be, all surfaces are flushed to device memory and destroyedv at that point) and the driver cares empty the release ring before calling this it should not happen, right?
Yes. The point was to check anyway, it should never happen with our driver, but a check can catch an error I guess.
Quoted 4 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{, _ASYNC}
In reply to Gerd HoffmannQuoted 21 lines · Gerd Hoffmann
Quoted 6 lines · Alon Levy
Quoted 5 lines · Gerd Hoffmann
Hi,
Quoted 2 lines
+ case
QXL_IO_DESTROY_ALL_SURFACES_ASYNC: +d->mode=QXL_MODE_UNDEFINED;Quoted 8 lines
Quoted 1 line
Should go to the async thread.
doesn't it make more sense to do all state changes from the vcpu thread? async thread can run much later, if you have a
QXL_IO_DESTROY_ALL_SURFACES_ASYNCfollowed by aQXL_IO_CREATE_PRIMARY_ASYNCwhere the driver did not wait for the completion of the ASYNC first, I would still like to support that, but it won't work if I move this to the async thread.I think we should disallow doing any I/O ops while one is in progress (except maybe
QXL_IO_LOG). Most I/O commands are I/O commands because they either needed for device setup or must be synchronous anyway.
Quoted 6 lines
QXL_IO_CREATE_PRIMARY_ASYNCwasn't exactly clever designed I think. Would have been better to enter native mode with another I/O command, then send the create request for the primary through the rings like all other surface commands. But given it is a rare event it isn't that a big issue either.
So - leave or change? I prefer to leave..
Maybe add a "pending async" flag to catch such occasions?
Quoted 4 lines
cheers,
Gerd
Re: [Qemu-devel] [PATCHv3] qxl: move to UNDEFINED on DESTROY_ALL_SURFACES{, _ASYNC}
Hi,
Quoted 1 line
Maybe add a "pending async" flag to catch such occasions?
Yes, good idea.
cheers,
Gerd