Blame SOURCES/kvm-s390x-ap-base-Adjunct-Processor-AP-object-model.patch

26ba25
From 375c8f51c7c5489f81cfd21cb289e44b4965d75d Mon Sep 17 00:00:00 2001
26ba25
From: Thomas Huth <thuth@redhat.com>
26ba25
Date: Mon, 15 Oct 2018 10:19:29 +0100
26ba25
Subject: [PATCH 4/6] s390x/ap: base Adjunct Processor (AP) object model
26ba25
26ba25
RH-Author: Thomas Huth <thuth@redhat.com>
26ba25
Message-id: <1539598771-16223-5-git-send-email-thuth@redhat.com>
26ba25
Patchwork-id: 82695
26ba25
O-Subject: [RHEL-8 qemu-kvm PATCH 4/6] s390x/ap: base Adjunct Processor (AP) object model
26ba25
Bugzilla: 1508142
26ba25
RH-Acked-by: David Hildenbrand <david@redhat.com>
26ba25
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
26ba25
RH-Acked-by: Jens Freimann <jfreimann@redhat.com>
26ba25
26ba25
From: Tony Krowiak <akrowiak@linux.ibm.com>
26ba25
26ba25
Introduces the base object model for virtualizing AP devices.
26ba25
26ba25
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
26ba25
Tested-by: Pierre Morel <pmorel@linux.ibm.com>
26ba25
Acked-by: David Hildenbrand <david@redhat.com>
26ba25
Reviewed-by: Thomas Huth <thuth@redhat.com>
26ba25
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
26ba25
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
26ba25
Message-Id: <20181010170309.12045-5-akrowiak@linux.ibm.com>
26ba25
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
26ba25
(cherry picked from commit a51b31535a8ec13997de29b357f7cc1dcd8a7f9c)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 MAINTAINERS                  | 12 +++++++
26ba25
 hw/s390x/Makefile.objs       |  2 ++
26ba25
 hw/s390x/ap-bridge.c         | 78 ++++++++++++++++++++++++++++++++++++++++++++
26ba25
 hw/s390x/ap-device.c         | 38 +++++++++++++++++++++
26ba25
 hw/s390x/s390-virtio-ccw.c   |  4 +++
26ba25
 include/hw/s390x/ap-bridge.h | 19 +++++++++++
26ba25
 include/hw/s390x/ap-device.h | 22 +++++++++++++
26ba25
 7 files changed, 175 insertions(+)
26ba25
 create mode 100644 hw/s390x/ap-bridge.c
26ba25
 create mode 100644 hw/s390x/ap-device.c
26ba25
 create mode 100644 include/hw/s390x/ap-bridge.h
26ba25
 create mode 100644 include/hw/s390x/ap-device.h
26ba25
26ba25
diff --git a/MAINTAINERS b/MAINTAINERS
26ba25
index 1e32116..31cf6ff 100644
26ba25
--- a/MAINTAINERS
26ba25
+++ b/MAINTAINERS
26ba25
@@ -1152,6 +1152,18 @@ F: include/hw/s390x/s390-ccw.h
26ba25
 T: git git://github.com/cohuck/qemu.git s390-next
26ba25
 L: qemu-s390x@nongnu.org
26ba25
 
26ba25
+vfio-ap
26ba25
+M: Christian Borntraeger <borntraeger@de.ibm.com>
26ba25
+M: Tony Krowiak <akrowiak@linux.ibm.com>
26ba25
+M: Halil Pasic <pasic@linux.ibm.com>
26ba25
+M: Pierre Morel <pmorel@linux.ibm.com>
26ba25
+S: Supported
26ba25
+F: hw/s390x/ap-device.c
26ba25
+F: hw/s390x/ap-bridge.c
26ba25
+F: include/hw/s390x/ap-device.h
26ba25
+F: include/hw/s390x/ap-bridge.h
26ba25
+L: qemu-s390x@nongnu.org
26ba25
+
26ba25
 vhost
26ba25
 M: Michael S. Tsirkin <mst@redhat.com>
26ba25
 S: Supported
26ba25
diff --git a/hw/s390x/Makefile.objs b/hw/s390x/Makefile.objs
26ba25
index dc704b5..655d1ac 100644
26ba25
--- a/hw/s390x/Makefile.objs
26ba25
+++ b/hw/s390x/Makefile.objs
26ba25
@@ -17,3 +17,5 @@ obj-y += s390-stattrib.o
26ba25
 obj-$(CONFIG_KVM) += s390-skeys-kvm.o
26ba25
 obj-$(CONFIG_KVM) += s390-stattrib-kvm.o
26ba25
 obj-y += s390-ccw.o
26ba25
+obj-y += ap-device.o
26ba25
+obj-y += ap-bridge.o
26ba25
diff --git a/hw/s390x/ap-bridge.c b/hw/s390x/ap-bridge.c
26ba25
new file mode 100644
26ba25
index 0000000..3795d30
26ba25
--- /dev/null
26ba25
+++ b/hw/s390x/ap-bridge.c
26ba25
@@ -0,0 +1,78 @@
26ba25
+/*
26ba25
+ * ap bridge
26ba25
+ *
26ba25
+ * Copyright 2018 IBM Corp.
26ba25
+ *
26ba25
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
26ba25
+ * your option) any later version. See the COPYING file in the top-level
26ba25
+ * directory.
26ba25
+ */
26ba25
+#include "qemu/osdep.h"
26ba25
+#include "qapi/error.h"
26ba25
+#include "hw/sysbus.h"
26ba25
+#include "qemu/bitops.h"
26ba25
+#include "hw/s390x/ap-bridge.h"
26ba25
+#include "cpu.h"
26ba25
+
26ba25
+static char *ap_bus_get_dev_path(DeviceState *dev)
26ba25
+{
26ba25
+    /* at most one */
26ba25
+    return g_strdup_printf("/1");
26ba25
+}
26ba25
+
26ba25
+static void ap_bus_class_init(ObjectClass *oc, void *data)
26ba25
+{
26ba25
+    BusClass *k = BUS_CLASS(oc);
26ba25
+
26ba25
+    k->get_dev_path = ap_bus_get_dev_path;
26ba25
+    /* More than one ap device does not make sense */
26ba25
+    k->max_dev = 1;
26ba25
+}
26ba25
+
26ba25
+static const TypeInfo ap_bus_info = {
26ba25
+    .name = TYPE_AP_BUS,
26ba25
+    .parent = TYPE_BUS,
26ba25
+    .instance_size = 0,
26ba25
+    .class_init = ap_bus_class_init,
26ba25
+};
26ba25
+
26ba25
+void s390_init_ap(void)
26ba25
+{
26ba25
+    DeviceState *dev;
26ba25
+
26ba25
+    /* If no AP instructions then no need for AP bridge */
26ba25
+    if (!s390_has_feat(S390_FEAT_AP)) {
26ba25
+        return;
26ba25
+    }
26ba25
+
26ba25
+    /* Create bridge device */
26ba25
+    dev = qdev_create(NULL, TYPE_AP_BRIDGE);
26ba25
+    object_property_add_child(qdev_get_machine(), TYPE_AP_BRIDGE,
26ba25
+                              OBJECT(dev), NULL);
26ba25
+    qdev_init_nofail(dev);
26ba25
+
26ba25
+    /* Create bus on bridge device */
26ba25
+    qbus_create(TYPE_AP_BUS, dev, TYPE_AP_BUS);
26ba25
+ }
26ba25
+
26ba25
+static void ap_bridge_class_init(ObjectClass *oc, void *data)
26ba25
+{
26ba25
+    DeviceClass *dc = DEVICE_CLASS(oc);
26ba25
+
26ba25
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
26ba25
+}
26ba25
+
26ba25
+static const TypeInfo ap_bridge_info = {
26ba25
+    .name          = TYPE_AP_BRIDGE,
26ba25
+    .parent        = TYPE_SYS_BUS_DEVICE,
26ba25
+    .instance_size = 0,
26ba25
+    .class_init    = ap_bridge_class_init,
26ba25
+};
26ba25
+
26ba25
+static void ap_register(void)
26ba25
+{
26ba25
+    type_register_static(&ap_bridge_info);
26ba25
+    type_register_static(&ap_bus_info);
26ba25
+}
26ba25
+
26ba25
+type_init(ap_register)
26ba25
diff --git a/hw/s390x/ap-device.c b/hw/s390x/ap-device.c
26ba25
new file mode 100644
26ba25
index 0000000..f5ac8db
26ba25
--- /dev/null
26ba25
+++ b/hw/s390x/ap-device.c
26ba25
@@ -0,0 +1,38 @@
26ba25
+/*
26ba25
+ * Adjunct Processor (AP) matrix device
26ba25
+ *
26ba25
+ * Copyright 2018 IBM Corp.
26ba25
+ *
26ba25
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
26ba25
+ * your option) any later version. See the COPYING file in the top-level
26ba25
+ * directory.
26ba25
+ */
26ba25
+#include "qemu/osdep.h"
26ba25
+#include "qemu/module.h"
26ba25
+#include "qapi/error.h"
26ba25
+#include "hw/qdev.h"
26ba25
+#include "hw/s390x/ap-device.h"
26ba25
+
26ba25
+static void ap_class_init(ObjectClass *klass, void *data)
26ba25
+{
26ba25
+    DeviceClass *dc = DEVICE_CLASS(klass);
26ba25
+
26ba25
+    dc->desc = "AP device class";
26ba25
+    dc->hotpluggable = false;
26ba25
+}
26ba25
+
26ba25
+static const TypeInfo ap_device_info = {
26ba25
+    .name = AP_DEVICE_TYPE,
26ba25
+    .parent = TYPE_DEVICE,
26ba25
+    .instance_size = sizeof(APDevice),
26ba25
+    .class_size = sizeof(DeviceClass),
26ba25
+    .class_init = ap_class_init,
26ba25
+    .abstract = true,
26ba25
+};
26ba25
+
26ba25
+static void ap_device_register(void)
26ba25
+{
26ba25
+    type_register_static(&ap_device_info);
26ba25
+}
26ba25
+
26ba25
+type_init(ap_device_register)
26ba25
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
26ba25
index bf039a1..43a8213 100644
26ba25
--- a/hw/s390x/s390-virtio-ccw.c
26ba25
+++ b/hw/s390x/s390-virtio-ccw.c
26ba25
@@ -32,6 +32,7 @@
26ba25
 #include "ipl.h"
26ba25
 #include "hw/s390x/s390-virtio-ccw.h"
26ba25
 #include "hw/s390x/css-bridge.h"
26ba25
+#include "hw/s390x/ap-bridge.h"
26ba25
 #include "migration/register.h"
26ba25
 #include "cpu_models.h"
26ba25
 #include "hw/nmi.h"
26ba25
@@ -305,6 +306,9 @@ static void ccw_init(MachineState *machine)
26ba25
     /* init the SIGP facility */
26ba25
     s390_init_sigp();
26ba25
 
26ba25
+    /* create AP bridge and bus(es) */
26ba25
+    s390_init_ap();
26ba25
+
26ba25
     /* get a BUS */
26ba25
     css_bus = virtual_css_bus_init();
26ba25
     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
26ba25
diff --git a/include/hw/s390x/ap-bridge.h b/include/hw/s390x/ap-bridge.h
26ba25
new file mode 100644
26ba25
index 0000000..470e439
26ba25
--- /dev/null
26ba25
+++ b/include/hw/s390x/ap-bridge.h
26ba25
@@ -0,0 +1,19 @@
26ba25
+/*
26ba25
+ * ap bridge
26ba25
+ *
26ba25
+ * Copyright 2018 IBM Corp.
26ba25
+ *
26ba25
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
26ba25
+ * your option) any later version. See the COPYING file in the top-level
26ba25
+ * directory.
26ba25
+ */
26ba25
+
26ba25
+#ifndef HW_S390X_AP_BRIDGE_H
26ba25
+#define HW_S390X_AP_BRIDGE_H
26ba25
+
26ba25
+#define TYPE_AP_BRIDGE "ap-bridge"
26ba25
+#define TYPE_AP_BUS "ap-bus"
26ba25
+
26ba25
+void s390_init_ap(void);
26ba25
+
26ba25
+#endif
26ba25
diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h
26ba25
new file mode 100644
26ba25
index 0000000..765e908
26ba25
--- /dev/null
26ba25
+++ b/include/hw/s390x/ap-device.h
26ba25
@@ -0,0 +1,22 @@
26ba25
+/*
26ba25
+ * Adjunct Processor (AP) matrix device interfaces
26ba25
+ *
26ba25
+ * Copyright 2018 IBM Corp.
26ba25
+ *
26ba25
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
26ba25
+ * your option) any later version. See the COPYING file in the top-level
26ba25
+ * directory.
26ba25
+ */
26ba25
+#ifndef HW_S390X_AP_DEVICE_H
26ba25
+#define HW_S390X_AP_DEVICE_H
26ba25
+
26ba25
+#define AP_DEVICE_TYPE       "ap-device"
26ba25
+
26ba25
+typedef struct APDevice {
26ba25
+    DeviceState parent_obj;
26ba25
+} APDevice;
26ba25
+
26ba25
+#define AP_DEVICE(obj) \
26ba25
+    OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE)
26ba25
+
26ba25
+#endif /* HW_S390X_AP_DEVICE_H */
26ba25
-- 
26ba25
1.8.3.1
26ba25