Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/kraxel/tags/fixes-20210326-pull…
Browse files Browse the repository at this point in the history
…-request' into staging

fixes for usb, virtio-gpu and vhost-gpu

# gpg: Signature made Fri 26 Mar 2021 12:49:14 GMT
# gpg:                using RSA key A0328CFFB93A17A79901FE7D4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full]
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>" [full]
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full]
# Primary key fingerprint: A032 8CFF B93A 17A7 9901  FE7D 4CB6 D8EE D3E8 7138

* remotes/kraxel/tags/fixes-20210326-pull-request:
  hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices
  s390x: modularize virtio-gpu-ccw
  s390x: add have_virtio_ccw
  s390x: move S390_ADAPTER_SUPPRESSIBLE
  hw/usb/hcd-ehci-sysbus: Free USBPacket on instance finalize()
  vhost-user-gpu: fix cursor move/update
  vhost-user-gpu: fix vugbm_device_init fallback
  vhost-user-gpu: glFlush before notifying clients
  usb: Remove "-usbdevice ccid"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Mar 26, 2021
2 parents 63ad23f + db0b034 commit 7b9a3c9
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 58 deletions.
2 changes: 1 addition & 1 deletion contrib/vhost-user-gpu/meson.build
Expand Up @@ -2,7 +2,7 @@ if 'CONFIG_TOOLS' in config_host and 'CONFIG_VIRGL' in config_host \
and 'CONFIG_GBM' in config_host and 'CONFIG_LINUX' in config_host \
and pixman.found()
executable('vhost-user-gpu', files('vhost-user-gpu.c', 'virgl.c', 'vugbm.c'),
dependencies: [qemuutil, pixman, gbm, virgl, vhost_user],
dependencies: [qemuutil, pixman, gbm, virgl, vhost_user, opengl],
install: true,
install_dir: get_option('libexecdir'))

Expand Down
24 changes: 13 additions & 11 deletions contrib/vhost-user-gpu/vhost-user-gpu.c
Expand Up @@ -892,11 +892,8 @@ update_cursor_data_simple(VuGpu *g, uint32_t resource_id, gpointer data)
static void
vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
{
bool move = cursor->hdr.type != VIRTIO_GPU_CMD_MOVE_CURSOR;

g_debug("%s move:%d\n", G_STRFUNC, move);

if (move) {
switch (cursor->hdr.type) {
case VIRTIO_GPU_CMD_MOVE_CURSOR: {
VhostUserGpuMsg msg = {
.request = cursor->resource_id ?
VHOST_USER_GPU_CURSOR_POS : VHOST_USER_GPU_CURSOR_POS_HIDE,
Expand All @@ -907,8 +904,11 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
.y = cursor->pos.y,
}
};
g_debug("%s: move", G_STRFUNC);
vg_send_msg(g, &msg, -1);
} else {
break;
}
case VIRTIO_GPU_CMD_UPDATE_CURSOR: {
VhostUserGpuMsg msg = {
.request = VHOST_USER_GPU_CURSOR_UPDATE,
.size = sizeof(VhostUserGpuCursorUpdate),
Expand All @@ -922,6 +922,7 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
.hot_y = cursor->hot_y,
}
};
g_debug("%s: update", G_STRFUNC);
if (g->virgl) {
vg_virgl_update_cursor_data(g, cursor->resource_id,
msg.payload.cursor_update.data);
Expand All @@ -930,6 +931,11 @@ vg_process_cursor_cmd(VuGpu *g, struct virtio_gpu_update_cursor *cursor)
msg.payload.cursor_update.data);
}
vg_send_msg(g, &msg, -1);
break;
}
default:
g_debug("%s: unknown cmd %d", G_STRFUNC, cursor->hdr.type);
break;
}
}

Expand Down Expand Up @@ -1186,11 +1192,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

if (g.drm_rnode_fd >= 0) {
if (!vugbm_device_init(&g.gdev, g.drm_rnode_fd)) {
g_warning("Failed to init DRM device, using fallback path");
}
}
vugbm_device_init(&g.gdev, g.drm_rnode_fd);

if ((!!opt_socket_path + (opt_fdnum != -1)) != 1) {
g_printerr("Please specify either --fd or --socket-path\n");
Expand Down
3 changes: 3 additions & 0 deletions contrib/vhost-user-gpu/virgl.c
Expand Up @@ -16,6 +16,8 @@
#include <virglrenderer.h>
#include "virgl.h"

#include <epoxy/gl.h>

void
vg_virgl_update_cursor_data(VuGpu *g, uint32_t resource_id,
gpointer data)
Expand Down Expand Up @@ -372,6 +374,7 @@ virgl_cmd_resource_flush(VuGpu *g,

VUGPU_FILL_CMD(rf);

glFlush();
if (!rf.resource_id) {
g_debug("bad resource id for flush..?");
return;
Expand Down
44 changes: 20 additions & 24 deletions contrib/vhost-user-gpu/vugbm.c
Expand Up @@ -199,55 +199,51 @@ vugbm_device_destroy(struct vugbm_device *dev)
dev->device_destroy(dev);
}

bool
void
vugbm_device_init(struct vugbm_device *dev, int fd)
{
dev->fd = fd;
assert(!dev->inited);

#ifdef CONFIG_GBM
dev->dev = gbm_create_device(fd);
#endif

if (0) {
/* nothing */
if (fd >= 0) {
dev->dev = gbm_create_device(fd);
}
#ifdef CONFIG_GBM
else if (dev->dev != NULL) {
if (dev->dev != NULL) {
dev->fd = fd;
dev->alloc_bo = alloc_bo;
dev->free_bo = free_bo;
dev->get_fd = get_fd;
dev->map_bo = map_bo;
dev->unmap_bo = unmap_bo;
dev->device_destroy = device_destroy;
dev->inited = true;
}
#endif
#ifdef CONFIG_MEMFD
else if (g_file_test("/dev/udmabuf", G_FILE_TEST_EXISTS)) {
if (!dev->inited && g_file_test("/dev/udmabuf", G_FILE_TEST_EXISTS)) {
dev->fd = open("/dev/udmabuf", O_RDWR);
if (dev->fd < 0) {
return false;
if (dev->fd >= 0) {
g_debug("Using experimental udmabuf backend");
dev->alloc_bo = udmabuf_alloc_bo;
dev->free_bo = udmabuf_free_bo;
dev->get_fd = udmabuf_get_fd;
dev->map_bo = udmabuf_map_bo;
dev->unmap_bo = udmabuf_unmap_bo;
dev->device_destroy = udmabuf_device_destroy;
dev->inited = true;
}
g_debug("Using experimental udmabuf backend");
dev->alloc_bo = udmabuf_alloc_bo;
dev->free_bo = udmabuf_free_bo;
dev->get_fd = udmabuf_get_fd;
dev->map_bo = udmabuf_map_bo;
dev->unmap_bo = udmabuf_unmap_bo;
dev->device_destroy = udmabuf_device_destroy;
}
#endif
else {
if (!dev->inited) {
g_debug("Using mem fallback");
dev->alloc_bo = mem_alloc_bo;
dev->free_bo = mem_free_bo;
dev->map_bo = mem_map_bo;
dev->unmap_bo = mem_unmap_bo;
dev->device_destroy = mem_device_destroy;
return false;
dev->inited = true;
}

dev->inited = true;
return true;
assert(dev->inited);
}

static bool
Expand Down
2 changes: 1 addition & 1 deletion contrib/vhost-user-gpu/vugbm.h
Expand Up @@ -54,7 +54,7 @@ struct vugbm_buffer {
uint32_t format;
};

bool vugbm_device_init(struct vugbm_device *dev, int fd);
void vugbm_device_init(struct vugbm_device *dev, int fd);
void vugbm_device_destroy(struct vugbm_device *dev);

bool vugbm_buffer_create(struct vugbm_buffer *buffer, struct vugbm_device *dev,
Expand Down
6 changes: 6 additions & 0 deletions docs/system/removed-features.rst
Expand Up @@ -120,6 +120,12 @@ Drives with interface types other than ``if=none`` are for onboard
devices. Drives the board doesn't pick up can no longer be used with
-device. Use ``if=none`` instead.

``-usbdevice ccid`` (removed in 6.0)
'''''''''''''''''''''''''''''''''''''

This option was undocumented and not used in the field.
Use `-device usb-ccid`` instead.


QEMU Machine Protocol (QMP) commands
------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion hw/s390x/meson.build
Expand Up @@ -34,7 +34,6 @@ virtio_ss.add(files('virtio-ccw.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_BALLOON', if_true: files('virtio-ccw-balloon.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_BLK', if_true: files('virtio-ccw-blk.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('virtio-ccw-crypto.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_GPU', if_true: files('virtio-ccw-gpu.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_INPUT', if_true: files('virtio-ccw-input.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio-ccw-net.c'))
virtio_ss.add(when: 'CONFIG_VIRTIO_RNG', if_true: files('virtio-ccw-rng.c'))
Expand All @@ -48,3 +47,10 @@ virtio_ss.add(when: 'CONFIG_VHOST_USER_FS', if_true: files('vhost-user-fs-ccw.c'
s390x_ss.add_all(when: 'CONFIG_VIRTIO_CCW', if_true: virtio_ss)

hw_arch += {'s390x': s390x_ss}

hw_s390x_modules = {}
virtio_gpu_ccw_ss = ss.source_set()
virtio_gpu_ccw_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_CCW'],
if_true: [files('virtio-ccw-gpu.c'), pixman])
hw_s390x_modules += {'virtio-gpu-ccw': virtio_gpu_ccw_ss}
modules += {'hw-s390x': hw_s390x_modules}
4 changes: 3 additions & 1 deletion hw/s390x/virtio-ccw-gpu.c
Expand Up @@ -62,7 +62,9 @@ static const TypeInfo virtio_ccw_gpu = {

static void virtio_ccw_gpu_register(void)
{
type_register_static(&virtio_ccw_gpu);
if (have_virtio_ccw) {
type_register_static(&virtio_ccw_gpu);
}
}

type_init(virtio_ccw_gpu_register)
2 changes: 2 additions & 0 deletions hw/s390x/virtio-ccw.c
Expand Up @@ -35,6 +35,8 @@

#define NR_CLASSIC_INDICATOR_BITS 64

bool have_virtio_ccw = true;

static int virtio_ccw_dev_post_load(void *opaque, int version_id)
{
VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(opaque);
Expand Down
5 changes: 5 additions & 0 deletions hw/s390x/virtio-ccw.h
Expand Up @@ -63,6 +63,11 @@ typedef struct VirtioBusClass VirtioCcwBusClass;
DECLARE_OBJ_CHECKERS(VirtioCcwBusState, VirtioCcwBusClass,
VIRTIO_CCW_BUS, TYPE_VIRTIO_CCW_BUS)

/*
* modules can reference this symbol to avoid being loaded
* into system emulators without ccw support
*/
extern bool have_virtio_ccw;

struct VirtIOCCWDeviceClass {
CCWDeviceClass parent_class;
Expand Down
1 change: 0 additions & 1 deletion hw/usb/dev-smartcard-reader.c
Expand Up @@ -1492,7 +1492,6 @@ static void ccid_register_types(void)
type_register_static(&ccid_bus_info);
type_register_static(&ccid_card_type_info);
type_register_static(&ccid_info);
usb_legacy_register(TYPE_USB_CCID_DEV, "ccid", NULL);
}

type_init(ccid_register_types)
9 changes: 9 additions & 0 deletions hw/usb/hcd-ehci-sysbus.c
Expand Up @@ -74,6 +74,14 @@ static void ehci_sysbus_init(Object *obj)
sysbus_init_mmio(d, &s->mem);
}

static void ehci_sysbus_finalize(Object *obj)
{
EHCISysBusState *i = SYS_BUS_EHCI(obj);
EHCIState *s = &i->ehci;

usb_ehci_finalize(s);
}

static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
Expand All @@ -94,6 +102,7 @@ static const TypeInfo ehci_type_info = {
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(EHCISysBusState),
.instance_init = ehci_sysbus_init,
.instance_finalize = ehci_sysbus_finalize,
.abstract = true,
.class_init = ehci_sysbus_class_init,
.class_size = sizeof(SysBusEHCIClass),
Expand Down
10 changes: 5 additions & 5 deletions hw/usb/hcd-ehci.c
Expand Up @@ -2514,6 +2514,11 @@ void usb_ehci_realize(EHCIState *s, DeviceState *dev, Error **errp)
return;
}

memory_region_add_subregion(&s->mem, s->capsbase, &s->mem_caps);
memory_region_add_subregion(&s->mem, s->opregbase, &s->mem_opreg);
memory_region_add_subregion(&s->mem, s->opregbase + s->portscbase,
&s->mem_ports);

usb_bus_new(&s->bus, sizeof(s->bus), s->companion_enable ?
&ehci_bus_ops_companion : &ehci_bus_ops_standalone, dev);
for (i = 0; i < s->portnr; i++) {
Expand Down Expand Up @@ -2581,11 +2586,6 @@ void usb_ehci_init(EHCIState *s, DeviceState *dev)
"operational", s->portscbase);
memory_region_init_io(&s->mem_ports, OBJECT(dev), &ehci_mmio_port_ops, s,
"ports", 4 * s->portnr);

memory_region_add_subregion(&s->mem, s->capsbase, &s->mem_caps);
memory_region_add_subregion(&s->mem, s->opregbase, &s->mem_opreg);
memory_region_add_subregion(&s->mem, s->opregbase + s->portscbase,
&s->mem_ports);
}

void usb_ehci_finalize(EHCIState *s)
Expand Down
7 changes: 0 additions & 7 deletions include/hw/s390x/css.h
Expand Up @@ -12,7 +12,6 @@
#ifndef CSS_H
#define CSS_H

#include "cpu.h"
#include "hw/s390x/adapter.h"
#include "hw/s390x/s390_flic.h"
#include "hw/s390x/ioinst.h"
Expand Down Expand Up @@ -233,12 +232,6 @@ uint32_t css_get_adapter_id(CssIoAdapterType type, uint8_t isc);
void css_register_io_adapters(CssIoAdapterType type, bool swap, bool maskable,
uint8_t flags, Error **errp);

#ifndef CONFIG_KVM
#define S390_ADAPTER_SUPPRESSIBLE 0x01
#else
#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE
#endif

#ifndef CONFIG_USER_ONLY
SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint8_t ssid,
uint16_t schid);
Expand Down
3 changes: 3 additions & 0 deletions include/hw/s390x/s390_flic.h
Expand Up @@ -134,6 +134,9 @@ void s390_flic_init(void);
S390FLICState *s390_get_flic(void);
QEMUS390FLICState *s390_get_qemu_flic(S390FLICState *fs);
S390FLICStateClass *s390_get_flic_class(S390FLICState *fs);
void s390_crw_mchk(void);
void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
uint32_t io_int_parm, uint32_t io_int_word);
bool ais_needed(void *opaque);

#endif /* HW_S390_FLIC_H */
3 changes: 0 additions & 3 deletions qemu-options.hx
Expand Up @@ -1743,9 +1743,6 @@ SRST
corresponding ``braille`` chardev automatically beside the
``usb-braille`` USB device).

``ccid``
Smartcard reader device

``keyboard``
Standard USB keyboard. Will override the PS/2 keyboard (if present).

Expand Down
9 changes: 6 additions & 3 deletions target/s390x/cpu.h
Expand Up @@ -40,6 +40,12 @@

#define S390_MAX_CPUS 248

#ifndef CONFIG_KVM
#define S390_ADAPTER_SUPPRESSIBLE 0x01
#else
#define S390_ADAPTER_SUPPRESSIBLE KVM_S390_ADAPTER_SUPPRESSIBLE
#endif

typedef struct PSW {
uint64_t mask;
uint64_t addr;
Expand Down Expand Up @@ -811,9 +817,6 @@ int cpu_s390x_signal_handler(int host_signum, void *pinfo, void *puc);


/* interrupt.c */
void s390_crw_mchk(void);
void s390_io_interrupt(uint16_t subchannel_id, uint16_t subchannel_nr,
uint32_t io_int_parm, uint32_t io_int_word);
#define RA_IGNORED 0
void s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra);
/* service interrupts are floating therefore we must not pass an cpustate */
Expand Down
1 change: 1 addition & 0 deletions util/module.c
Expand Up @@ -304,6 +304,7 @@ static struct {
{ "virtio-gpu-pci-base", "hw-", "display-virtio-gpu-pci" },
{ "virtio-gpu-pci", "hw-", "display-virtio-gpu-pci" },
{ "vhost-user-gpu-pci", "hw-", "display-virtio-gpu-pci" },
{ "virtio-gpu-ccw", "hw-", "s390x-virtio-gpu-ccw" },
{ "virtio-vga-base", "hw-", "display-virtio-vga" },
{ "virtio-vga", "hw-", "display-virtio-vga" },
{ "vhost-user-vga", "hw-", "display-virtio-vga" },
Expand Down

0 comments on commit 7b9a3c9

Please sign in to comment.