Commit dddb3749 authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/awilliam/tags/vfio-updates-20181015.0' into staging



VFIO updates 2018-10-15

 - ramfb support for vfio-pci via new -nohotplug device variant
   (Gerd Hoffmann)

 - Preparation for generic DT pass-through in vfio-platform
   (Geert Uytterhoeven & Eric Auger)

 - vfio-pci QOM fixups (Li Qiang)

# gpg: Signature made Mon 15 Oct 2018 18:26:29 BST
# gpg:                using RSA key 239B9B6E3BB08B22
# gpg: Good signature from "Alex Williamson <alex.williamson@redhat.com>"
# gpg:                 aka "Alex Williamson <alex@shazbot.org>"
# gpg:                 aka "Alex Williamson <alwillia@redhat.com>"
# gpg:                 aka "Alex Williamson <alex.l.williamson@gmail.com>"
# Primary key fingerprint: 42F6 C04E 540B D1A9 9E7B  8A90 239B 9B6E 3BB0 8B22

* remotes/awilliam/tags/vfio-updates-20181015.0:
  vfio-pci: make vfio-pci device more QOM conventional
  hw/arm/virt: Allow dynamic vfio-platform devices again
  hw/arm/sysbus-fdt: Allow device matching with DT compatible value
  vfio/platform: Make the vfio-platform device non-abstract
  hw/vfio/display: add ramfb support
  stubs: add ramfb

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents ff56877e 2683ccd5
Loading
Loading
Loading
Loading
+47 −14
Original line number Diff line number Diff line
@@ -50,11 +50,13 @@ typedef struct PlatformBusFDTData {
    PlatformBusDevice *pbus;
} PlatformBusFDTData;

/* struct that associates a device type name and a node creation function */
typedef struct NodeCreationPair {
/* struct that allows to match a device and create its FDT node */
typedef struct BindingEntry {
    const char *typename;
    int (*add_fdt_node_fn)(SysBusDevice *sbdev, void *opaque);
} NodeCreationPair;
    const char *compat;
    int  (*add_fn)(SysBusDevice *sbdev, void *opaque);
    bool (*match_fn)(SysBusDevice *sbdev, const struct BindingEntry *combo);
} BindingEntry;

/* helpers */

@@ -413,6 +415,27 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev, void *opaque)
    return 0;
}

/* DT compatible matching */
static bool vfio_platform_match(SysBusDevice *sbdev,
                                const BindingEntry *entry)
{
    VFIOPlatformDevice *vdev = VFIO_PLATFORM_DEVICE(sbdev);
    const char *compat;
    unsigned int n;

    for (n = vdev->num_compat, compat = vdev->compat; n > 0;
         n--, compat += strlen(compat) + 1) {
        if (!strcmp(entry->compat, compat)) {
            return true;
        }
    }

    return false;
}

#define VFIO_PLATFORM_BINDING(compat, add_fn) \
    {TYPE_VFIO_PLATFORM, (compat), (add_fn), vfio_platform_match}

#endif /* CONFIG_LINUX */

static int no_fdt_node(SysBusDevice *sbdev, void *opaque)
@@ -420,14 +443,23 @@ static int no_fdt_node(SysBusDevice *sbdev, void *opaque)
    return 0;
}

/* list of supported dynamic sysbus devices */
static const NodeCreationPair add_fdt_node_functions[] = {
/* Device type based matching */
static bool type_match(SysBusDevice *sbdev, const BindingEntry *entry)
{
    return !strcmp(object_get_typename(OBJECT(sbdev)), entry->typename);
}

#define TYPE_BINDING(type, add_fn) {(type), NULL, (add_fn), type_match}

/* list of supported dynamic sysbus bindings */
static const BindingEntry bindings[] = {
#ifdef CONFIG_LINUX
    {TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node},
    {TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node},
    TYPE_BINDING(TYPE_VFIO_CALXEDA_XGMAC, add_calxeda_midway_xgmac_fdt_node),
    TYPE_BINDING(TYPE_VFIO_AMD_XGBE, add_amd_xgbe_fdt_node),
    VFIO_PLATFORM_BINDING("amd,xgbe-seattle-v1a", add_amd_xgbe_fdt_node),
#endif
    {TYPE_RAMFB_DEVICE, no_fdt_node},
    {"", NULL}, /* last element */
    TYPE_BINDING(TYPE_RAMFB_DEVICE, no_fdt_node),
    TYPE_BINDING("", NULL), /* last element */
};

/* Generic Code */
@@ -446,10 +478,11 @@ static void add_fdt_node(SysBusDevice *sbdev, void *opaque)
{
    int i, ret;

    for (i = 0; i < ARRAY_SIZE(add_fdt_node_functions); i++) {
        if (!strcmp(object_get_typename(OBJECT(sbdev)),
                    add_fdt_node_functions[i].typename)) {
            ret = add_fdt_node_functions[i].add_fdt_node_fn(sbdev, opaque);
    for (i = 0; i < ARRAY_SIZE(bindings); i++) {
        const BindingEntry *iter = &bindings[i];

        if (iter->match_fn(sbdev, iter)) {
            ret = iter->add_fn(sbdev, opaque);
            assert(!ret);
            return;
        }
+1 −0
Original line number Diff line number Diff line
@@ -1758,6 +1758,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_CALXEDA_XGMAC);
    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_AMD_XGBE);
    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_RAMFB_DEVICE);
    machine_class_allow_dynamic_sysbus_dev(mc, TYPE_VFIO_PLATFORM);
    mc->block_default_type = IF_VIRTIO;
    mc->no_cdrom = 1;
    mc->pci_allow_0_address = true;
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ static void amd_xgbe_realize(DeviceState *dev, Error **errp)
    VFIOAmdXgbeDeviceClass *k = VFIO_AMD_XGBE_DEVICE_GET_CLASS(dev);

    vdev->compat = g_strdup("amd,xgbe-seattle-v1a");
    vdev->num_compat = 1;

    k->parent_realize(dev, errp);
}
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ static void calxeda_xgmac_realize(DeviceState *dev, Error **errp)
    VFIOCalxedaXgmacDeviceClass *k = VFIO_CALXEDA_XGMAC_DEVICE_GET_CLASS(dev);

    vdev->compat = g_strdup("calxeda,hb-xgmac");
    vdev->num_compat = 1;

    k->parent_realize(dev, errp);
}
+12 −0
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@ static void vfio_display_dmabuf_update(void *opaque)

    primary = vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY);
    if (primary == NULL) {
        if (dpy->ramfb) {
            ramfb_display_update(dpy->con, dpy->ramfb);
        }
        return;
    }

@@ -181,6 +184,9 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev, Error **errp)
    vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
                                          &vfio_display_dmabuf_ops,
                                          vdev);
    if (vdev->enable_ramfb) {
        vdev->dpy->ramfb = ramfb_setup(errp);
    }
    return 0;
}

@@ -228,6 +234,9 @@ static void vfio_display_region_update(void *opaque)
        return;
    }
    if (!plane.drm_format || !plane.size) {
        if (dpy->ramfb) {
            ramfb_display_update(dpy->con, dpy->ramfb);
        }
        return;
    }
    format = qemu_drm_format_to_pixman(plane.drm_format);
@@ -300,6 +309,9 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp)
    vdev->dpy->con = graphic_console_init(DEVICE(vdev), 0,
                                          &vfio_display_region_ops,
                                          vdev);
    if (vdev->enable_ramfb) {
        vdev->dpy->ramfb = ramfb_setup(errp);
    }
    return 0;
}

Loading